@paraspell/sdk-core 13.4.1 → 13.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +1394 -1333
  2. package/dist/index.mjs +654 -646
  3. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { blake2b } from '@noble/hashes/blake2.js';
2
- import { isChainEvm, getAssetsObject, InvalidCurrencyError, extractAssetLocation, isTAsset, findAssetInfoOrThrow, findNativeAssetInfoOrThrow, findAssetInfo, findAssetOnDestOrThrow, findAssetInfoOnDest, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, isOverrideLocationSpecifier, isSymbolSpecifier, getRelayChainSymbol, normalizeLocation, getNativeAssetSymbol, getEdFromAssetOrThrow, isSymbolMatch, getExistentialDepositOrThrow, hasDryRunSupport, findNativeAssetInfo, isAssetXcEqual, normalizeSymbol, Native, hasXcmPaymentApiSupport, getOtherAssets } from '@paraspell/assets';
2
+ import { isChainEvm, getAssetsObject, InvalidCurrencyError, isOverrideLocationSpecifier, extractAssetLocation, isTAsset, findAssetInfoOrThrow, findNativeAssetInfoOrThrow, findAssetInfo, findAssetOnDestOrThrow, findAssetInfoOnDest, isAssetEqual, isStableCoinAsset, isBridgedSystemAsset, isSymbolSpecifier, getRelayChainSymbol, normalizeLocation, getNativeAssetSymbol, getEdFromAssetOrThrow, isSymbolMatch, getExistentialDepositOrThrow, hasDryRunSupport, findNativeAssetInfo, isAssetXcEqual, normalizeSymbol, Native, hasXcmPaymentApiSupport, getOtherAssets } from '@paraspell/assets';
3
3
  export * from '@paraspell/assets';
4
4
  import { base58 } from '@scure/base';
5
5
  import { isAddress, isHex, pad, toHex, getAddress, concat, keccak256, createPublicClient, http, getContract, formatUnits as formatUnits$1, parseUnits as parseUnits$1 } from 'viem';
6
- import { Version, isTLocation, replaceBigInt, isExternalChain, hasJunction, getJunctionValue, isRelayChain, deepEqual, Parents, isSnowbridge, isBridge, isSubstrateBridge, PARACHAINS, RELAYCHAINS, isTrustedChain } from '@paraspell/sdk-common';
6
+ import { Version, isTLocation, replaceBigInt, isExternalChain, getJunctionValue, isRelayChain, deepEqual, Parents, hasJunction, isSnowbridge, isBridge, isSubstrateBridge, PARACHAINS, RELAYCHAINS, isTrustedChain } from '@paraspell/sdk-common';
7
7
  export * from '@paraspell/sdk-common';
8
8
  import { getSupportedPallets, getNativeAssetsPallet, getOtherAssetsPallets, getXcmPallet, getSupportedPalletsDetails, hasPallet } from '@paraspell/pallets';
9
9
  export * from '@paraspell/pallets';
@@ -505,14 +505,18 @@ var DryRunFailedError = /*#__PURE__*/function (_Error) {
505
505
  *
506
506
  * @param reason - The reason why the dry run failed.
507
507
  * @param dryRunType - Optional. Specifies if the error is related to the 'origin' or 'destination' dry run.
508
+ * @param prefix - Optional. A short sentence prepended to the message
508
509
  */
509
- function DryRunFailedError(reason, dryRunType) {
510
+ function DryRunFailedError(reason, dryRunType, prefix) {
510
511
  var _this;
511
512
  _classCallCheck(this, DryRunFailedError);
512
513
  var message = "Dry run failed: ".concat(reason);
513
514
  if (dryRunType) {
514
515
  message = "Dry run on ".concat(dryRunType, " failed: ").concat(reason);
515
516
  }
517
+ if (prefix) {
518
+ message = "".concat(prefix, " ").concat(message);
519
+ }
516
520
  _this = _callSuper(this, DryRunFailedError, [message]);
517
521
  _this.name = 'DryRunFailedError';
518
522
  _this.reason = reason;
@@ -961,20 +965,29 @@ var createClientPoolHelpers = function createClientPoolHelpers(clientPool, creat
961
965
  };
962
966
  };
963
967
 
964
- // PayFees instruction is removed temporarily in favor of BuyExecution everywhere,
965
- // but we keep this function for now in case we need to add it back in the future
966
- var createPayFees = function createPayFees(_version, asset, weight) {
968
+ var createPayFees = function createPayFees(version, asset, weight) {
969
+ var includeRefundSurplus = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
970
+ var forceBuyExecution = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
971
+ if (forceBuyExecution || version < Version.V5) {
972
+ return [{
973
+ BuyExecution: {
974
+ fees: asset,
975
+ weight_limit: weight ? {
976
+ Limited: {
977
+ ref_time: weight.refTime,
978
+ proof_size: weight.proofSize
979
+ }
980
+ } : 'Unlimited'
981
+ }
982
+ }];
983
+ }
967
984
  return [{
968
- BuyExecution: {
969
- fees: asset,
970
- weight_limit: weight ? {
971
- Limited: {
972
- ref_time: weight.refTime,
973
- proof_size: weight.proofSize
974
- }
975
- } : 'Unlimited'
985
+ PayFees: {
986
+ asset: asset
976
987
  }
977
- }];
988
+ }].concat(_toConsumableArray(includeRefundSurplus ? [{
989
+ RefundSurplus: undefined
990
+ }] : []));
978
991
  };
979
992
 
980
993
  var resolveTx = /*#__PURE__*/function () {
@@ -1138,11 +1151,28 @@ var assertSender = function assertSender(address) {
1138
1151
  throw new MissingParameterError('sender');
1139
1152
  }
1140
1153
  };
1154
+ var assertEvmAddress = function assertEvmAddress(address) {
1155
+ if (!isAddress(address)) {
1156
+ throw new InvalidAddressError(address);
1157
+ }
1158
+ };
1141
1159
  var assertHasId = function assertHasId(asset) {
1142
1160
  if (asset.assetId === undefined) {
1143
1161
  throw new InvalidCurrencyError("Asset ".concat(JSON.stringify(asset, replaceBigInt), " has no assetId"));
1144
1162
  }
1145
1163
  };
1164
+ var assertCurrencyCore = function assertCurrencyCore(value) {
1165
+ if (value === undefined) return;
1166
+ if (value === null) {
1167
+ throw new InvalidCurrencyError('A currency selector is required.');
1168
+ }
1169
+ if (Array.isArray(value)) {
1170
+ throw new InvalidCurrencyError('Multi-asset currency input is not supported here. Provide a single currency selector ({ symbol }, { id }, or { location }).');
1171
+ }
1172
+ if (_typeof(value) === 'object' && 'location' in value && isOverrideLocationSpecifier(value.location)) {
1173
+ throw new InvalidCurrencyError('Override location specifier is not supported here. Provide a regular location.');
1174
+ }
1175
+ };
1146
1176
  var assertSenderSource = function assertSenderSource(sender) {
1147
1177
  if (sender === undefined) {
1148
1178
  throw new InvalidAddressError('Sender address needs to be a derivation path or signer to sign and submit transaction using this method.');
@@ -1177,7 +1207,12 @@ var assertExtensionInstalled = function assertExtensionInstalled(extension, exte
1177
1207
  };
1178
1208
 
1179
1209
  var getAssetReserveChain = function getAssetReserveChain(chain, assetLocation) {
1180
- var hasGlobalConsensusJunction = hasJunction(assetLocation, 'GlobalConsensus');
1210
+ var resolveExternalReserve = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1211
+ var globalConsensus = getJunctionValue(assetLocation, 'GlobalConsensus');
1212
+ if (resolveExternalReserve && globalConsensus && 'Ethereum' in globalConsensus) {
1213
+ var _relaychain = getRelayChainOf(chain);
1214
+ return _relaychain === 'Westend' || _relaychain === 'Paseo' ? 'EthereumTestnet' : 'Ethereum';
1215
+ }
1181
1216
  var paraId = getJunctionValue(assetLocation, 'Parachain');
1182
1217
  if (paraId) {
1183
1218
  var resolvedChain = getTChain(paraId, getRelayChainOf(chain));
@@ -1189,7 +1224,7 @@ var getAssetReserveChain = function getAssetReserveChain(chain, assetLocation) {
1189
1224
  if (isRelayChain(chain)) return chain;
1190
1225
  var relaychain = getRelayChainOf(chain);
1191
1226
  var ahChain = "AssetHub".concat(relaychain);
1192
- if (hasGlobalConsensusJunction) {
1227
+ if (globalConsensus) {
1193
1228
  return ahChain;
1194
1229
  }
1195
1230
  if (deepEqual(assetLocation, {
@@ -2868,7 +2903,7 @@ var resolveHopAsset = function resolveHopAsset(_ref) {
2868
2903
 
2869
2904
  var getEthereumJunction = function getEthereumJunction(chain) {
2870
2905
  var useBigInt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
2871
- var relayChain = getRelayChainOf(chain);
2906
+ var relayChain = !isExternalChain(chain) ? getRelayChainOf(chain) : undefined;
2872
2907
  var isTestnet = relayChain === 'Westend' || relayChain === 'Paseo';
2873
2908
  var chainId = isTestnet ? ETH_TESTNET_PARA_ID : ETH_MAINNET_PARA_ID;
2874
2909
  return {
@@ -3578,6 +3613,7 @@ var normalizeAmountAll = /*#__PURE__*/function () {
3578
3613
  buildTx = builderWithMinAmount['createTxFactory']();
3579
3614
  assertToIsString(options.to);
3580
3615
  assertSender(options.sender);
3616
+ assertCurrencyCore(currency);
3581
3617
  if (!swapOptions) {
3582
3618
  _context.n = 3;
3583
3619
  break;
@@ -4066,6 +4102,31 @@ var GeneralBuilder = /*#__PURE__*/function () {
4066
4102
  }
4067
4103
  return build;
4068
4104
  }()
4105
+ /**
4106
+ * Builds an unsigned EIP-1559 transaction (viem `TransactionSerializableEIP1559`) for an
4107
+ * EVM-compatible origin. `nonce`, `gas`, and fees are populated from the origin chain's RPC.
4108
+ */
4109
+ )
4110
+ }, {
4111
+ key: "buildEvm",
4112
+ value: (function () {
4113
+ var _buildEvm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
4114
+ var _this$prepareEvmDispa, ext, options;
4115
+ return _regenerator().w(function (_context4) {
4116
+ while (1) switch (_context4.n) {
4117
+ case 0:
4118
+ _this$prepareEvmDispa = this.prepareEvmDispatch(), ext = _this$prepareEvmDispa.ext, options = _this$prepareEvmDispa.options;
4119
+ return _context4.a(2, ext.buildTransfer(_objectSpread2(_objectSpread2({}, options), {}, {
4120
+ sender: this._options.sender
4121
+ })));
4122
+ }
4123
+ }, _callee4, this);
4124
+ }));
4125
+ function buildEvm() {
4126
+ return _buildEvm.apply(this, arguments);
4127
+ }
4128
+ return buildEvm;
4129
+ }()
4069
4130
  /**
4070
4131
  * Builds and returns multiple transfer or swap extrinsics
4071
4132
  *
@@ -4075,21 +4136,21 @@ var GeneralBuilder = /*#__PURE__*/function () {
4075
4136
  }, {
4076
4137
  key: "buildAll",
4077
4138
  value: (function () {
4078
- var _buildAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
4139
+ var _buildAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
4079
4140
  var _this$_options4, from, senderSource, _yield$this$buildComm2, txContexts;
4080
- return _regenerator().w(function (_context4) {
4081
- while (1) switch (_context4.n) {
4141
+ return _regenerator().w(function (_context5) {
4142
+ while (1) switch (_context5.n) {
4082
4143
  case 0:
4083
4144
  _this$_options4 = this._options, from = _this$_options4.from, senderSource = _this$_options4.senderSource;
4084
4145
  assertNotEvmTransfer(from, senderSource);
4085
- _context4.n = 1;
4146
+ _context5.n = 1;
4086
4147
  return this.buildCommonAll();
4087
4148
  case 1:
4088
- _yield$this$buildComm2 = _context4.v;
4149
+ _yield$this$buildComm2 = _context5.v;
4089
4150
  txContexts = _yield$this$buildComm2.txContexts;
4090
- return _context4.a(2, txContexts);
4151
+ return _context5.a(2, txContexts);
4091
4152
  }
4092
- }, _callee4, this);
4153
+ }, _callee5, this);
4093
4154
  }));
4094
4155
  function buildAll() {
4095
4156
  return _buildAll.apply(this, arguments);
@@ -4106,42 +4167,42 @@ var GeneralBuilder = /*#__PURE__*/function () {
4106
4167
  }, {
4107
4168
  key: "buildCommon",
4108
4169
  value: function () {
4109
- var _buildCommon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
4170
+ var _buildCommon = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
4110
4171
  var isCalledInternally,
4111
4172
  _yield$this$prepareNo,
4112
4173
  normalizedOptions,
4113
4174
  from,
4114
4175
  substrateOptions,
4115
4176
  tx,
4116
- _args5 = arguments;
4117
- return _regenerator().w(function (_context5) {
4118
- while (1) switch (_context5.n) {
4177
+ _args6 = arguments;
4178
+ return _regenerator().w(function (_context6) {
4179
+ while (1) switch (_context6.n) {
4119
4180
  case 0:
4120
- isCalledInternally = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : false;
4181
+ isCalledInternally = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : false;
4121
4182
  this.validateBatchState(isCalledInternally);
4122
- _context5.n = 1;
4183
+ _context6.n = 1;
4123
4184
  return this.prepareNormalizedOptions(this._options);
4124
4185
  case 1:
4125
- _yield$this$prepareNo = _context5.v;
4186
+ _yield$this$prepareNo = _context6.v;
4126
4187
  normalizedOptions = _yield$this$prepareNo.normalizedOptions;
4127
4188
  from = normalizedOptions.from;
4128
4189
  assertSubstrateOrigin(from);
4129
4190
  substrateOptions = _objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4130
4191
  from: from
4131
4192
  });
4132
- _context5.n = 2;
4193
+ _context6.n = 2;
4133
4194
  return createTransferOrSwap(substrateOptions);
4134
4195
  case 2:
4135
- tx = _context5.v;
4136
- _context5.n = 3;
4196
+ tx = _context6.v;
4197
+ _context6.n = 3;
4137
4198
  return this.maybePerformXcmFormatCheck(tx, substrateOptions, isCalledInternally);
4138
4199
  case 3:
4139
- return _context5.a(2, {
4200
+ return _context6.a(2, {
4140
4201
  tx: tx,
4141
4202
  options: normalizedOptions
4142
4203
  });
4143
4204
  }
4144
- }, _callee5, this);
4205
+ }, _callee6, this);
4145
4206
  }));
4146
4207
  function buildCommon() {
4147
4208
  return _buildCommon.apply(this, arguments);
@@ -4151,39 +4212,39 @@ var GeneralBuilder = /*#__PURE__*/function () {
4151
4212
  }, {
4152
4213
  key: "buildCommonAll",
4153
4214
  value: function () {
4154
- var _buildCommonAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
4215
+ var _buildCommonAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
4155
4216
  var isCalledInternally,
4156
4217
  _yield$this$prepareNo2,
4157
4218
  normalizedOptions,
4158
4219
  from,
4159
4220
  substrateOptions,
4160
4221
  txContexts,
4161
- _args6 = arguments;
4162
- return _regenerator().w(function (_context6) {
4163
- while (1) switch (_context6.n) {
4222
+ _args7 = arguments;
4223
+ return _regenerator().w(function (_context7) {
4224
+ while (1) switch (_context7.n) {
4164
4225
  case 0:
4165
- isCalledInternally = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : false;
4226
+ isCalledInternally = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : false;
4166
4227
  this.validateBatchState(isCalledInternally);
4167
- _context6.n = 1;
4228
+ _context7.n = 1;
4168
4229
  return this.prepareNormalizedOptions(this._options);
4169
4230
  case 1:
4170
- _yield$this$prepareNo2 = _context6.v;
4231
+ _yield$this$prepareNo2 = _context7.v;
4171
4232
  normalizedOptions = _yield$this$prepareNo2.normalizedOptions;
4172
4233
  from = normalizedOptions.from;
4173
4234
  assertSubstrateOrigin(from);
4174
4235
  substrateOptions = _objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4175
4236
  from: from
4176
4237
  });
4177
- _context6.n = 2;
4238
+ _context7.n = 2;
4178
4239
  return createTransferOrSwapAll(substrateOptions);
4179
4240
  case 2:
4180
- txContexts = _context6.v;
4181
- return _context6.a(2, {
4241
+ txContexts = _context7.v;
4242
+ return _context7.a(2, {
4182
4243
  txContexts: txContexts,
4183
4244
  options: normalizedOptions
4184
4245
  });
4185
4246
  }
4186
- }, _callee6, this);
4247
+ }, _callee7, this);
4187
4248
  }));
4188
4249
  function buildCommonAll() {
4189
4250
  return _buildCommonAll.apply(this, arguments);
@@ -4193,35 +4254,35 @@ var GeneralBuilder = /*#__PURE__*/function () {
4193
4254
  }, {
4194
4255
  key: "maybePerformXcmFormatCheck",
4195
4256
  value: function () {
4196
- var _maybePerformXcmFormatCheck = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(tx, options, isCalledInternally) {
4257
+ var _maybePerformXcmFormatCheck = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(tx, options, isCalledInternally) {
4197
4258
  var sender, config, dryRunResult;
4198
- return _regenerator().w(function (_context7) {
4199
- while (1) switch (_context7.n) {
4259
+ return _regenerator().w(function (_context8) {
4260
+ while (1) switch (_context8.n) {
4200
4261
  case 0:
4201
4262
  sender = options.sender;
4202
4263
  config = this.api.config;
4203
4264
  if (!(isConfig(config) && config.xcmFormatCheck && !isCalledInternally)) {
4204
- _context7.n = 2;
4265
+ _context8.n = 2;
4205
4266
  break;
4206
4267
  }
4207
4268
  assertSender(sender);
4208
- _context7.n = 1;
4269
+ _context8.n = 1;
4209
4270
  return buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
4210
4271
  sender: sender
4211
4272
  }), {
4212
4273
  sentAssetMintMode: 'bypass'
4213
4274
  });
4214
4275
  case 1:
4215
- dryRunResult = _context7.v;
4276
+ dryRunResult = _context8.v;
4216
4277
  if (!dryRunResult.failureReason) {
4217
- _context7.n = 2;
4278
+ _context8.n = 2;
4218
4279
  break;
4219
4280
  }
4220
- throw new DryRunFailedError(dryRunResult.failureReason, dryRunResult.failureChain);
4281
+ throw new DryRunFailedError(dryRunResult.failureReason, dryRunResult.failureChain, 'XCM format check failed.');
4221
4282
  case 2:
4222
- return _context7.a(2);
4283
+ return _context8.a(2);
4223
4284
  }
4224
- }, _callee7, this);
4285
+ }, _callee8, this);
4225
4286
  }));
4226
4287
  function maybePerformXcmFormatCheck(_x3, _x4, _x5) {
4227
4288
  return _maybePerformXcmFormatCheck.apply(this, arguments);
@@ -4231,18 +4292,18 @@ var GeneralBuilder = /*#__PURE__*/function () {
4231
4292
  }, {
4232
4293
  key: "dryRun",
4233
4294
  value: function () {
4234
- var _dryRun = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
4295
+ var _dryRun = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9() {
4235
4296
  var _this$_options5, from, senderSource, swapOptions, _yield$this$buildInte, tx, options;
4236
- return _regenerator().w(function (_context8) {
4237
- while (1) switch (_context8.n) {
4297
+ return _regenerator().w(function (_context9) {
4298
+ while (1) switch (_context9.n) {
4238
4299
  case 0:
4239
4300
  _this$_options5 = this._options, from = _this$_options5.from, senderSource = _this$_options5.senderSource, swapOptions = _this$_options5.swapOptions;
4240
4301
  assertNotEvmTransfer(from, senderSource);
4241
4302
  if (!swapOptions) {
4242
- _context8.n = 1;
4303
+ _context9.n = 1;
4243
4304
  break;
4244
4305
  }
4245
- return _context8.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4306
+ return _context9.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4246
4307
  from: from,
4247
4308
  api: this.api,
4248
4309
  swapOptions: swapOptions
@@ -4250,17 +4311,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
4250
4311
  return builder.dryRun();
4251
4312
  }));
4252
4313
  case 1:
4253
- _context8.n = 2;
4314
+ _context9.n = 2;
4254
4315
  return this.buildInternal();
4255
4316
  case 2:
4256
- _yield$this$buildInte = _context8.v;
4317
+ _yield$this$buildInte = _context9.v;
4257
4318
  tx = _yield$this$buildInte.tx;
4258
4319
  options = _yield$this$buildInte.options;
4259
- return _context8.a(2, buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
4320
+ return _context9.a(2, buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
4260
4321
  from: from
4261
4322
  })));
4262
4323
  }
4263
- }, _callee8, this);
4324
+ }, _callee9, this);
4264
4325
  }));
4265
4326
  function dryRun() {
4266
4327
  return _dryRun.apply(this, arguments);
@@ -4270,28 +4331,39 @@ var GeneralBuilder = /*#__PURE__*/function () {
4270
4331
  }, {
4271
4332
  key: "dryRunPreview",
4272
4333
  value: function () {
4273
- var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(dryRunOptions) {
4334
+ var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(dryRunOptions) {
4274
4335
  var _this$_options6, from, senderSource, swapOptions, _yield$this$buildInte2, tx, options;
4275
- return _regenerator().w(function (_context9) {
4276
- while (1) switch (_context9.n) {
4336
+ return _regenerator().w(function (_context0) {
4337
+ while (1) switch (_context0.n) {
4277
4338
  case 0:
4278
4339
  _this$_options6 = this._options, from = _this$_options6.from, senderSource = _this$_options6.senderSource, swapOptions = _this$_options6.swapOptions;
4279
4340
  assertNotEvmTransfer(from, senderSource);
4280
- assertSwapSupport(swapOptions);
4281
- _context9.n = 1;
4282
- return this.buildInternal();
4341
+ if (!swapOptions) {
4342
+ _context0.n = 1;
4343
+ break;
4344
+ }
4345
+ return _context0.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4346
+ from: from,
4347
+ api: this.api,
4348
+ swapOptions: swapOptions
4349
+ }), function (builder) {
4350
+ return builder.dryRunPreview(dryRunOptions);
4351
+ }));
4283
4352
  case 1:
4284
- _yield$this$buildInte2 = _context9.v;
4353
+ _context0.n = 2;
4354
+ return this.buildInternal();
4355
+ case 2:
4356
+ _yield$this$buildInte2 = _context0.v;
4285
4357
  tx = _yield$this$buildInte2.tx;
4286
4358
  options = _yield$this$buildInte2.options;
4287
- return _context9.a(2, buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
4359
+ return _context0.a(2, buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
4288
4360
  from: from
4289
4361
  }), {
4290
4362
  sentAssetMintMode: 'preview',
4291
4363
  mintFeeAssets: dryRunOptions === null || dryRunOptions === void 0 ? void 0 : dryRunOptions.mintFeeAssets
4292
4364
  }));
4293
4365
  }
4294
- }, _callee9, this);
4366
+ }, _callee0, this);
4295
4367
  }));
4296
4368
  function dryRunPreview(_x6) {
4297
4369
  return _dryRunPreview.apply(this, arguments);
@@ -4316,18 +4388,18 @@ var GeneralBuilder = /*#__PURE__*/function () {
4316
4388
  }, {
4317
4389
  key: "getXcmFee",
4318
4390
  value: (function () {
4319
- var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
4391
+ var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(options) {
4320
4392
  var _options$disableFallb;
4321
4393
  var disableFallback, senderSource, _yield$this$prepareNo3, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4322
- return _regenerator().w(function (_context0) {
4323
- while (1) switch (_context0.n) {
4394
+ return _regenerator().w(function (_context1) {
4395
+ while (1) switch (_context1.n) {
4324
4396
  case 0:
4325
4397
  disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
4326
4398
  senderSource = this._options.senderSource;
4327
- _context0.n = 1;
4399
+ _context1.n = 1;
4328
4400
  return this.prepareNormalizedOptions(this._options);
4329
4401
  case 1:
4330
- _yield$this$prepareNo3 = _context0.v;
4402
+ _yield$this$prepareNo3 = _context1.v;
4331
4403
  normalizedOptions = _yield$this$prepareNo3.normalizedOptions;
4332
4404
  buildTx = _yield$this$prepareNo3.buildTx;
4333
4405
  api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, sender = normalizedOptions.sender, recipient = normalizedOptions.recipient, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
@@ -4335,17 +4407,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
4335
4407
  assertAddressIsString(recipient);
4336
4408
  assertNotEvmTransfer(from, senderSource);
4337
4409
  if (!swapOptions) {
4338
- _context0.n = 2;
4410
+ _context1.n = 2;
4339
4411
  break;
4340
4412
  }
4341
- return _context0.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4413
+ return _context1.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4342
4414
  from: from,
4343
4415
  swapOptions: swapOptions
4344
4416
  }), function (builder) {
4345
4417
  return builder.getXcmFees(options);
4346
4418
  }));
4347
4419
  case 2:
4348
- return _context0.a(2, getXcmFee({
4420
+ return _context1.a(2, getXcmFee({
4349
4421
  api: api,
4350
4422
  buildTx: buildTx,
4351
4423
  origin: from,
@@ -4358,7 +4430,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4358
4430
  disableFallback: disableFallback
4359
4431
  }));
4360
4432
  }
4361
- }, _callee0, this);
4433
+ }, _callee1, this);
4362
4434
  }));
4363
4435
  function getXcmFee$1(_x7) {
4364
4436
  return _getXcmFee2.apply(this, arguments);
@@ -4374,41 +4446,36 @@ var GeneralBuilder = /*#__PURE__*/function () {
4374
4446
  }, {
4375
4447
  key: "getOriginXcmFee",
4376
4448
  value: (function () {
4377
- var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
4378
- var _ref,
4379
- disableFallback,
4380
- senderSource,
4381
- _yield$this$prepareNo4,
4382
- normalizedOptions,
4383
- buildTx,
4384
- api,
4385
- from,
4386
- to,
4387
- sender,
4388
- currency,
4389
- feeAsset,
4390
- version,
4391
- swapOptions,
4392
- _args1 = arguments;
4393
- return _regenerator().w(function (_context1) {
4394
- while (1) switch (_context1.p = _context1.n) {
4449
+ var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
4450
+ var _options$disableFallb2;
4451
+ var disableFallback, senderSource, _yield$this$prepareNo4, normalizedOptions, buildTx, api, from, to, sender, currency, feeAsset, version, swapOptions;
4452
+ return _regenerator().w(function (_context10) {
4453
+ while (1) switch (_context10.p = _context10.n) {
4395
4454
  case 0:
4396
- _ref = _args1.length > 0 && _args1[0] !== undefined ? _args1[0] : {
4397
- disableFallback: false
4398
- }, disableFallback = _ref.disableFallback;
4455
+ disableFallback = (_options$disableFallb2 = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb2 !== void 0 ? _options$disableFallb2 : false;
4399
4456
  senderSource = this._options.senderSource;
4400
- _context1.n = 1;
4457
+ _context10.n = 1;
4401
4458
  return this.prepareNormalizedOptions(this._options);
4402
4459
  case 1:
4403
- _yield$this$prepareNo4 = _context1.v;
4460
+ _yield$this$prepareNo4 = _context10.v;
4404
4461
  normalizedOptions = _yield$this$prepareNo4.normalizedOptions;
4405
4462
  buildTx = _yield$this$prepareNo4.buildTx;
4406
4463
  api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, sender = normalizedOptions.sender, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
4407
4464
  assertToIsString(to);
4408
- assertSwapSupport(swapOptions);
4409
4465
  assertNotEvmTransfer(from, senderSource);
4410
- _context1.p = 2;
4411
- _context1.n = 3;
4466
+ if (!swapOptions) {
4467
+ _context10.n = 2;
4468
+ break;
4469
+ }
4470
+ return _context10.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4471
+ from: from,
4472
+ swapOptions: swapOptions
4473
+ }), function (builder) {
4474
+ return builder.getOriginXcmFee(options);
4475
+ }));
4476
+ case 2:
4477
+ _context10.p = 2;
4478
+ _context10.n = 3;
4412
4479
  return getOriginXcmFee({
4413
4480
  api: api,
4414
4481
  buildTx: buildTx,
@@ -4421,19 +4488,19 @@ var GeneralBuilder = /*#__PURE__*/function () {
4421
4488
  disableFallback: disableFallback
4422
4489
  });
4423
4490
  case 3:
4424
- return _context1.a(2, _context1.v);
4491
+ return _context10.a(2, _context10.v);
4425
4492
  case 4:
4426
- _context1.p = 4;
4427
- _context1.n = 5;
4493
+ _context10.p = 4;
4494
+ _context10.n = 5;
4428
4495
  return this.api.disconnect();
4429
4496
  case 5:
4430
- return _context1.f(4);
4497
+ return _context10.f(4);
4431
4498
  case 6:
4432
- return _context1.a(2);
4499
+ return _context10.a(2);
4433
4500
  }
4434
- }, _callee1, this, [[2,, 4, 6]]);
4501
+ }, _callee10, this, [[2,, 4, 6]]);
4435
4502
  }));
4436
- function getOriginXcmFee$1() {
4503
+ function getOriginXcmFee$1(_x8) {
4437
4504
  return _getOriginXcmFee2.apply(this, arguments);
4438
4505
  }
4439
4506
  return getOriginXcmFee$1;
@@ -4447,33 +4514,33 @@ var GeneralBuilder = /*#__PURE__*/function () {
4447
4514
  }, {
4448
4515
  key: "getTransferableAmount",
4449
4516
  value: (function () {
4450
- var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
4517
+ var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
4451
4518
  var senderSource, _yield$this$prepareNo5, normalizedOptions, buildTx, api, from, to, sender, currency, feeAsset, version, swapOptions;
4452
- return _regenerator().w(function (_context10) {
4453
- while (1) switch (_context10.n) {
4519
+ return _regenerator().w(function (_context11) {
4520
+ while (1) switch (_context11.n) {
4454
4521
  case 0:
4455
4522
  senderSource = this._options.senderSource;
4456
- _context10.n = 1;
4523
+ _context11.n = 1;
4457
4524
  return this.prepareNormalizedOptions(this._options);
4458
4525
  case 1:
4459
- _yield$this$prepareNo5 = _context10.v;
4526
+ _yield$this$prepareNo5 = _context11.v;
4460
4527
  normalizedOptions = _yield$this$prepareNo5.normalizedOptions;
4461
4528
  buildTx = _yield$this$prepareNo5.buildTx;
4462
4529
  api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, sender = normalizedOptions.sender, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
4463
4530
  assertToIsString(to);
4464
4531
  assertNotEvmTransfer(from, senderSource);
4465
4532
  if (!swapOptions) {
4466
- _context10.n = 2;
4533
+ _context11.n = 2;
4467
4534
  break;
4468
4535
  }
4469
- return _context10.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4536
+ return _context11.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4470
4537
  from: from,
4471
4538
  swapOptions: swapOptions
4472
4539
  }), function (builder) {
4473
4540
  return builder.getTransferableAmount();
4474
4541
  }));
4475
4542
  case 2:
4476
- return _context10.a(2, getTransferableAmount({
4543
+ return _context11.a(2, getTransferableAmount({
4477
4544
  api: api,
4478
4545
  buildTx: buildTx,
4479
4546
  origin: from,
@@ -4484,7 +4551,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4484
4551
  currency: currency
4485
4552
  }));
4486
4553
  }
4487
- }, _callee10, this);
4554
+ }, _callee11, this);
4488
4555
  }));
4489
4556
  function getTransferableAmount$1() {
4490
4557
  return _getTransferableAmount2.apply(this, arguments);
@@ -4500,16 +4567,16 @@ var GeneralBuilder = /*#__PURE__*/function () {
4500
4567
  }, {
4501
4568
  key: "getMinTransferableAmount",
4502
4569
  value: (function () {
4503
- var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
4570
+ var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
4504
4571
  var senderSource, _yield$this$prepareNo6, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4505
- return _regenerator().w(function (_context11) {
4506
- while (1) switch (_context11.n) {
4572
+ return _regenerator().w(function (_context12) {
4573
+ while (1) switch (_context12.n) {
4507
4574
  case 0:
4508
4575
  senderSource = this._options.senderSource;
4509
- _context11.n = 1;
4576
+ _context12.n = 1;
4510
4577
  return this.prepareNormalizedOptions(this._options);
4511
4578
  case 1:
4512
- _yield$this$prepareNo6 = _context11.v;
4579
+ _yield$this$prepareNo6 = _context12.v;
4513
4580
  normalizedOptions = _yield$this$prepareNo6.normalizedOptions;
4514
4581
  buildTx = _yield$this$prepareNo6.buildTx;
4515
4582
  api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, sender = normalizedOptions.sender, recipient = normalizedOptions.recipient, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
@@ -4517,17 +4584,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
4517
4584
  assertAddressIsString(recipient);
4518
4585
  assertNotEvmTransfer(from, senderSource);
4519
4586
  if (!swapOptions) {
4520
- _context11.n = 2;
4587
+ _context12.n = 2;
4521
4588
  break;
4522
4589
  }
4523
- return _context11.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4590
+ return _context12.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4524
4591
  from: from,
4525
4592
  swapOptions: swapOptions
4526
4593
  }), function (builder) {
4527
4594
  return builder.getMinTransferableAmount();
4528
4595
  }));
4529
4596
  case 2:
4530
- return _context11.a(2, getMinTransferableAmount({
4597
+ return _context12.a(2, getMinTransferableAmount({
4531
4598
  api: api,
4532
4599
  buildTx: buildTx,
4533
4600
  origin: from,
@@ -4540,7 +4607,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4540
4607
  builder: this
4541
4608
  }));
4542
4609
  }
4543
- }, _callee11, this);
4610
+ }, _callee12, this);
4544
4611
  }));
4545
4612
  function getMinTransferableAmount$1() {
4546
4613
  return _getMinTransferableAmount2.apply(this, arguments);
@@ -4556,16 +4623,16 @@ var GeneralBuilder = /*#__PURE__*/function () {
4556
4623
  }, {
4557
4624
  key: "verifyEdOnDestination",
4558
4625
  value: (function () {
4559
- var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
4626
+ var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
4560
4627
  var senderSource, _yield$this$prepareNo7, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4561
- return _regenerator().w(function (_context12) {
4562
- while (1) switch (_context12.n) {
4628
+ return _regenerator().w(function (_context13) {
4629
+ while (1) switch (_context13.n) {
4563
4630
  case 0:
4564
4631
  senderSource = this._options.senderSource;
4565
- _context12.n = 1;
4632
+ _context13.n = 1;
4566
4633
  return this.prepareNormalizedOptions(this._options);
4567
4634
  case 1:
4568
- _yield$this$prepareNo7 = _context12.v;
4635
+ _yield$this$prepareNo7 = _context13.v;
4569
4636
  normalizedOptions = _yield$this$prepareNo7.normalizedOptions;
4570
4637
  buildTx = _yield$this$prepareNo7.buildTx;
4571
4638
  api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, sender = normalizedOptions.sender, recipient = normalizedOptions.recipient, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
@@ -4573,7 +4640,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4573
4640
  assertAddressIsString(recipient);
4574
4641
  assertSwapSupport(swapOptions);
4575
4642
  assertNotEvmTransfer(from, senderSource);
4576
- return _context12.a(2, verifyEdOnDestination({
4643
+ return _context13.a(2, verifyEdOnDestination({
4577
4644
  api: api,
4578
4645
  buildTx: buildTx,
4579
4646
  origin: from,
@@ -4585,7 +4652,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4585
4652
  currency: currency
4586
4653
  }));
4587
4654
  }
4588
- }, _callee12, this);
4655
+ }, _callee13, this);
4589
4656
  }));
4590
4657
  function verifyEdOnDestination$1() {
4591
4658
  return _verifyEdOnDestination2.apply(this, arguments);
@@ -4601,24 +4668,35 @@ var GeneralBuilder = /*#__PURE__*/function () {
4601
4668
  }, {
4602
4669
  key: "getTransferInfo",
4603
4670
  value: (function () {
4604
- var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
4671
+ var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
4605
4672
  var senderSource, _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, recipient, currency, ahAddress, sender, feeAsset, version, swapOptions;
4606
- return _regenerator().w(function (_context13) {
4607
- while (1) switch (_context13.n) {
4673
+ return _regenerator().w(function (_context14) {
4674
+ while (1) switch (_context14.n) {
4608
4675
  case 0:
4609
4676
  senderSource = this._options.senderSource;
4610
- _context13.n = 1;
4677
+ _context14.n = 1;
4611
4678
  return this.prepareNormalizedOptions(this._options);
4612
4679
  case 1:
4613
- _yield$this$prepareNo8 = _context13.v;
4680
+ _yield$this$prepareNo8 = _context14.v;
4614
4681
  normalizedOptions = _yield$this$prepareNo8.normalizedOptions;
4615
4682
  buildTx = _yield$this$prepareNo8.buildTx;
4616
4683
  api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, recipient = normalizedOptions.recipient, currency = normalizedOptions.currency, ahAddress = normalizedOptions.ahAddress, sender = normalizedOptions.sender, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
4617
4684
  assertToIsString(to);
4618
4685
  assertAddressIsString(recipient);
4619
- assertSwapSupport(swapOptions);
4620
4686
  assertNotEvmTransfer(from, senderSource);
4621
- return _context13.a(2, getTransferInfo({
4687
+ if (!swapOptions) {
4688
+ _context14.n = 2;
4689
+ break;
4690
+ }
4691
+ return _context14.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4692
+ from: from,
4693
+ swapOptions: swapOptions
4694
+ }), function (builder) {
4695
+ return builder.getSwapInfo();
4696
+ }));
4697
+ case 2:
4698
+ assertCurrencyCore(feeAsset);
4699
+ return _context14.a(2, getTransferInfo({
4622
4700
  api: api,
4623
4701
  buildTx: buildTx,
4624
4702
  origin: from,
@@ -4631,7 +4709,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4631
4709
  feeAsset: feeAsset
4632
4710
  }));
4633
4711
  }
4634
- }, _callee13, this);
4712
+ }, _callee14, this);
4635
4713
  }));
4636
4714
  function getTransferInfo$1() {
4637
4715
  return _getTransferInfo2.apply(this, arguments);
@@ -4648,25 +4726,25 @@ var GeneralBuilder = /*#__PURE__*/function () {
4648
4726
  }, {
4649
4727
  key: "getReceivableAmount",
4650
4728
  value: (function () {
4651
- var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
4729
+ var _getReceivableAmount = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
4652
4730
  var _yield$this$getTransf, receivedAmount;
4653
- return _regenerator().w(function (_context14) {
4654
- while (1) switch (_context14.n) {
4731
+ return _regenerator().w(function (_context15) {
4732
+ while (1) switch (_context15.n) {
4655
4733
  case 0:
4656
- _context14.n = 1;
4734
+ _context15.n = 1;
4657
4735
  return this.getTransferInfo();
4658
4736
  case 1:
4659
- _yield$this$getTransf = _context14.v;
4737
+ _yield$this$getTransf = _context15.v;
4660
4738
  receivedAmount = _yield$this$getTransf.destination.receivedCurrency.receivedAmount;
4661
4739
  if (!(receivedAmount instanceof UnableToComputeError)) {
4662
- _context14.n = 2;
4740
+ _context15.n = 2;
4663
4741
  break;
4664
4742
  }
4665
4743
  throw receivedAmount;
4666
4744
  case 2:
4667
- return _context14.a(2, receivedAmount);
4745
+ return _context15.a(2, receivedAmount);
4668
4746
  }
4669
- }, _callee14, this);
4747
+ }, _callee15, this);
4670
4748
  }));
4671
4749
  function getReceivableAmount() {
4672
4750
  return _getReceivableAmount.apply(this, arguments);
@@ -4676,14 +4754,14 @@ var GeneralBuilder = /*#__PURE__*/function () {
4676
4754
  }, {
4677
4755
  key: "getBestAmountOut",
4678
4756
  value: function () {
4679
- var _getBestAmountOut = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
4757
+ var _getBestAmountOut = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
4680
4758
  var _this$_options7, from, senderSource, swapOptions;
4681
- return _regenerator().w(function (_context15) {
4682
- while (1) switch (_context15.n) {
4759
+ return _regenerator().w(function (_context16) {
4760
+ while (1) switch (_context16.n) {
4683
4761
  case 0:
4684
4762
  _this$_options7 = this._options, from = _this$_options7.from, senderSource = _this$_options7.senderSource, swapOptions = _this$_options7.swapOptions;
4685
4763
  assertNotEvmTransfer(from, senderSource);
4686
- return _context15.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4764
+ return _context16.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4687
4765
  from: from,
4688
4766
  api: this.api,
4689
4767
  swapOptions: swapOptions
@@ -4691,7 +4769,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4691
4769
  return builder.getBestAmountOut();
4692
4770
  }));
4693
4771
  }
4694
- }, _callee15, this);
4772
+ }, _callee16, this);
4695
4773
  }));
4696
4774
  function getBestAmountOut() {
4697
4775
  return _getBestAmountOut.apply(this, arguments);
@@ -4701,31 +4779,31 @@ var GeneralBuilder = /*#__PURE__*/function () {
4701
4779
  }, {
4702
4780
  key: "signAndSubmit",
4703
4781
  value: function () {
4704
- var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
4782
+ var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
4705
4783
  var _this$_options8, from, senderSource, swapOptions, txHashes, _yield$this$buildInte3, tx;
4706
- return _regenerator().w(function (_context16) {
4707
- while (1) switch (_context16.n) {
4784
+ return _regenerator().w(function (_context17) {
4785
+ while (1) switch (_context17.n) {
4708
4786
  case 0:
4709
4787
  _this$_options8 = this._options, from = _this$_options8.from, senderSource = _this$_options8.senderSource, swapOptions = _this$_options8.swapOptions;
4710
4788
  assertSenderSource(senderSource);
4711
4789
  if (!isViemSigner(senderSource)) {
4712
- _context16.n = 1;
4790
+ _context17.n = 1;
4713
4791
  break;
4714
4792
  }
4715
- return _context16.a(2, this.executeWithEvmSigner(senderSource));
4793
+ return _context17.a(2, this.executeWithEvmSigner(senderSource));
4716
4794
  case 1:
4717
4795
  assertSubstrateOrigin(from);
4718
4796
  if (!swapOptions) {
4719
- _context16.n = 4;
4797
+ _context17.n = 4;
4720
4798
  break;
4721
4799
  }
4722
4800
  if (isSenderSigner(senderSource)) {
4723
- _context16.n = 2;
4801
+ _context17.n = 2;
4724
4802
  break;
4725
4803
  }
4726
4804
  throw new UnsupportedOperationError('Swap operations do not support local accounts yet. Please provider a signer');
4727
4805
  case 2:
4728
- _context16.n = 3;
4806
+ _context17.n = 3;
4729
4807
  return executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4730
4808
  from: from,
4731
4809
  swapOptions: swapOptions,
@@ -4734,17 +4812,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
4734
4812
  return builder.signer(senderSource).signAndSubmit();
4735
4813
  });
4736
4814
  case 3:
4737
- txHashes = _context16.v;
4738
- return _context16.a(2, txHashes[0]);
4815
+ txHashes = _context17.v;
4816
+ return _context17.a(2, txHashes[0]);
4739
4817
  case 4:
4740
- _context16.n = 5;
4818
+ _context17.n = 5;
4741
4819
  return this.buildInternal();
4742
4820
  case 5:
4743
- _yield$this$buildInte3 = _context16.v;
4821
+ _yield$this$buildInte3 = _context17.v;
4744
4822
  tx = _yield$this$buildInte3.tx;
4745
- return _context16.a(2, this.api.signAndSubmit(tx, senderSource));
4823
+ return _context17.a(2, this.api.signAndSubmit(tx, senderSource));
4746
4824
  }
4747
- }, _callee16, this);
4825
+ }, _callee17, this);
4748
4826
  }));
4749
4827
  function signAndSubmit() {
4750
4828
  return _signAndSubmit.apply(this, arguments);
@@ -4754,35 +4832,35 @@ var GeneralBuilder = /*#__PURE__*/function () {
4754
4832
  }, {
4755
4833
  key: "signAndSubmitAll",
4756
4834
  value: function () {
4757
- var _signAndSubmitAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
4835
+ var _signAndSubmitAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
4758
4836
  var _this$_options9, from, senderSource, swapOptions, hash, _yield$this$buildInte4, tx, txHash;
4759
- return _regenerator().w(function (_context17) {
4760
- while (1) switch (_context17.n) {
4837
+ return _regenerator().w(function (_context18) {
4838
+ while (1) switch (_context18.n) {
4761
4839
  case 0:
4762
4840
  _this$_options9 = this._options, from = _this$_options9.from, senderSource = _this$_options9.senderSource, swapOptions = _this$_options9.swapOptions;
4763
4841
  assertSenderSource(senderSource);
4764
4842
  if (!isViemSigner(senderSource)) {
4765
- _context17.n = 2;
4843
+ _context18.n = 2;
4766
4844
  break;
4767
4845
  }
4768
- _context17.n = 1;
4846
+ _context18.n = 1;
4769
4847
  return this.executeWithEvmSigner(senderSource);
4770
4848
  case 1:
4771
- hash = _context17.v;
4772
- return _context17.a(2, [hash]);
4849
+ hash = _context18.v;
4850
+ return _context18.a(2, [hash]);
4773
4851
  case 2:
4774
4852
  assertSubstrateOrigin(from);
4775
4853
  if (!swapOptions) {
4776
- _context17.n = 4;
4854
+ _context18.n = 4;
4777
4855
  break;
4778
4856
  }
4779
4857
  if (isSenderSigner(senderSource)) {
4780
- _context17.n = 3;
4858
+ _context18.n = 3;
4781
4859
  break;
4782
4860
  }
4783
4861
  throw new UnsupportedOperationError('Swap operations do not support local accounts yet. Please provider a signer');
4784
4862
  case 3:
4785
- return _context17.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4863
+ return _context18.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4786
4864
  from: from,
4787
4865
  swapOptions: swapOptions,
4788
4866
  api: this.api
@@ -4790,18 +4868,18 @@ var GeneralBuilder = /*#__PURE__*/function () {
4790
4868
  return builder.signer(senderSource).signAndSubmit();
4791
4869
  }));
4792
4870
  case 4:
4793
- _context17.n = 5;
4871
+ _context18.n = 5;
4794
4872
  return this.buildInternal();
4795
4873
  case 5:
4796
- _yield$this$buildInte4 = _context17.v;
4874
+ _yield$this$buildInte4 = _context18.v;
4797
4875
  tx = _yield$this$buildInte4.tx;
4798
- _context17.n = 6;
4876
+ _context18.n = 6;
4799
4877
  return this.api.signAndSubmit(tx, senderSource);
4800
4878
  case 6:
4801
- txHash = _context17.v;
4802
- return _context17.a(2, [txHash]);
4879
+ txHash = _context18.v;
4880
+ return _context18.a(2, [txHash]);
4803
4881
  }
4804
- }, _callee17, this);
4882
+ }, _callee18, this);
4805
4883
  }));
4806
4884
  function signAndSubmitAll() {
4807
4885
  return _signAndSubmitAll.apply(this, arguments);
@@ -4811,45 +4889,47 @@ var GeneralBuilder = /*#__PURE__*/function () {
4811
4889
  }, {
4812
4890
  key: "executeWithEvmSigner",
4813
4891
  value: function () {
4814
- var _executeWithEvmSigner = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(signer) {
4815
- var _this$_options0, from, to, currency, recipient, ahAddress;
4816
- return _regenerator().w(function (_context18) {
4817
- while (1) switch (_context18.n) {
4892
+ var _executeWithEvmSigner = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(signer) {
4893
+ var _this$prepareEvmDispa2, ext, options;
4894
+ return _regenerator().w(function (_context19) {
4895
+ while (1) switch (_context19.n) {
4818
4896
  case 0:
4819
- _this$_options0 = this._options, from = _this$_options0.from, to = _this$_options0.to, currency = _this$_options0.currency, recipient = _this$_options0.recipient, ahAddress = _this$_options0.ahAddress;
4820
- assertToIsString(to);
4821
- assertAddressIsString(recipient);
4822
- if (!isExternalChain(from)) {
4823
- _context18.n = 1;
4824
- break;
4825
- }
4826
- return _context18.a(2, getEvmSnowbridgeExtensionOrThrow().executeEvmSnowbridgeTransfer({
4827
- api: this.api,
4828
- from: from,
4829
- to: to,
4830
- currency: currency,
4831
- recipient: recipient,
4832
- ahAddress: ahAddress,
4833
- signer: signer
4834
- }));
4835
- case 1:
4836
- return _context18.a(2, getEvmExtensionOrThrow().executeEvmTransfer({
4837
- api: this.api,
4838
- from: from,
4839
- to: to,
4840
- currency: currency,
4841
- recipient: recipient,
4842
- ahAddress: ahAddress,
4897
+ _this$prepareEvmDispa2 = this.prepareEvmDispatch(), ext = _this$prepareEvmDispa2.ext, options = _this$prepareEvmDispa2.options;
4898
+ return _context19.a(2, ext.executeTransfer(_objectSpread2(_objectSpread2({}, options), {}, {
4843
4899
  signer: signer
4844
- }));
4900
+ })));
4845
4901
  }
4846
- }, _callee18, this);
4902
+ }, _callee19, this);
4847
4903
  }));
4848
- function executeWithEvmSigner(_x8) {
4904
+ function executeWithEvmSigner(_x9) {
4849
4905
  return _executeWithEvmSigner.apply(this, arguments);
4850
4906
  }
4851
4907
  return executeWithEvmSigner;
4852
4908
  }()
4909
+ }, {
4910
+ key: "prepareEvmDispatch",
4911
+ value: function prepareEvmDispatch() {
4912
+ var _this$_options0 = this._options,
4913
+ from = _this$_options0.from,
4914
+ to = _this$_options0.to,
4915
+ currency = _this$_options0.currency,
4916
+ recipient = _this$_options0.recipient,
4917
+ ahAddress = _this$_options0.ahAddress;
4918
+ assertToIsString(to);
4919
+ assertAddressIsString(recipient);
4920
+ var ext = isExternalChain(from) ? getEvmSnowbridgeExtensionOrThrow() : getEvmExtensionOrThrow();
4921
+ return {
4922
+ ext: ext,
4923
+ options: {
4924
+ api: this.api,
4925
+ from: from,
4926
+ to: to,
4927
+ currency: currency,
4928
+ recipient: recipient,
4929
+ ahAddress: ahAddress
4930
+ }
4931
+ };
4932
+ }
4853
4933
  /**
4854
4934
  * Returns the API instance used by the builder.
4855
4935
  *
@@ -6417,6 +6497,23 @@ var localizeLocation = function localizeLocation(chain, location, origin) {
6417
6497
  }
6418
6498
  var isOriginRelayHere = deepEqual(location, RELAY_LOCATION);
6419
6499
  var hasGlobalConsensus = hasJunction(location, 'GlobalConsensus');
6500
+ if (origin && isExternalChain(chain) && originRelay !== undefined && isOriginRelayHere && !hasGlobalConsensus) {
6501
+ return {
6502
+ parents: Parents.ONE,
6503
+ interior: {
6504
+ X1: [{
6505
+ GlobalConsensus: _defineProperty({}, originRelay, null)
6506
+ }]
6507
+ }
6508
+ };
6509
+ }
6510
+ if (isExternalChain(chain) && location.parents === Parents.TWO && RELAYCHAINS.some(function (relay) {
6511
+ return deepEqual(getJunctionValue(location, 'GlobalConsensus'), _defineProperty({}, relay.toLowerCase(), null));
6512
+ })) {
6513
+ return _objectSpread2(_objectSpread2({}, location), {}, {
6514
+ parents: Parents.ONE
6515
+ });
6516
+ }
6420
6517
  if (origin && ecosystemDiffers && isOriginRelayHere && !hasGlobalConsensus && originRelay !== undefined) {
6421
6518
  return {
6422
6519
  parents: Parents.TWO,
@@ -7006,6 +7103,7 @@ var dryRunInternal = /*#__PURE__*/function () {
7006
7103
  while (1) switch (_context2.n) {
7007
7104
  case 0:
7008
7105
  api = options.api, origin = options.origin, destination = options.destination, currency = options.currency, tx = options.tx, sender = options.sender, feeAsset = options.feeAsset, swapConfig = options.swapConfig, version = options.version, bypassOptions = options.bypassOptions, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi;
7106
+ assertCurrencyCore(currency);
7009
7107
  asset = findAssetInfoOrThrow(origin, currency, destination);
7010
7108
  resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
7011
7109
  amount = abstractDecimals(currency.amount, asset.decimals, api);
@@ -7261,6 +7359,9 @@ var dryRunOrigin = /*#__PURE__*/function () {
7261
7359
  var parseUnits = parseUnits$1;
7262
7360
  var formatUnits = formatUnits$1;
7263
7361
 
7362
+ var resolveBypassMintAmount = function resolveBypassMintAmount(chain) {
7363
+ return HIGH_BYPASS_MINT_CHAINS.includes(chain) ? HIGH_BYPASS_MINT_AMOUNT : BYPASS_MINT_AMOUNT;
7364
+ };
7264
7365
  var pickOtherPallet = function pickOtherPallet(asset, pallets) {
7265
7366
  if (!asset.isNative && (!asset.assetId || asset.assetId.startsWith('0x'))) {
7266
7367
  var _pallets$find;
@@ -7326,7 +7427,7 @@ var mintBonusForSent = function mintBonusForSent(chain, sent, feeAsset, mintFeeA
7326
7427
  });
7327
7428
  return preminted.some(function (a) {
7328
7429
  return isAssetXcEqual(a, sent);
7329
- }) ? parseUnits(BYPASS_MINT_AMOUNT, sent.decimals) : 0n;
7430
+ }) ? parseUnits(resolveBypassMintAmount(chain), sent.decimals) : 0n;
7330
7431
  };
7331
7432
  var wrapTxBypass = /*#__PURE__*/function () {
7332
7433
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(dryRunOptions) {
@@ -7338,6 +7439,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
7338
7439
  feeAsset,
7339
7440
  tx,
7340
7441
  mintFeeAssets,
7442
+ bypassMintAmount,
7341
7443
  relayCurrency,
7342
7444
  nativeInfo,
7343
7445
  relayInfo,
@@ -7366,6 +7468,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
7366
7468
  };
7367
7469
  api = dryRunOptions.api, chain = dryRunOptions.chain, address = dryRunOptions.address, asset = dryRunOptions.asset, feeAsset = dryRunOptions.feeAsset, tx = dryRunOptions.tx;
7368
7470
  mintFeeAssets = options.mintFeeAssets;
7471
+ bypassMintAmount = resolveBypassMintAmount(chain);
7369
7472
  relayCurrency = {
7370
7473
  location: {
7371
7474
  parents: Parents.ONE,
@@ -7382,7 +7485,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
7382
7485
  break;
7383
7486
  }
7384
7487
  _context.n = 1;
7385
- return createRequiredMintTxs(chain, findNativeAssetInfoOrThrow(chain), BYPASS_MINT_AMOUNT, 0n, address, api);
7488
+ return createRequiredMintTxs(chain, findNativeAssetInfoOrThrow(chain), bypassMintAmount, 0n, address, api);
7386
7489
  case 1:
7387
7490
  _t = _context.v;
7388
7491
  _context.n = 3;
@@ -7396,7 +7499,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
7396
7499
  break;
7397
7500
  }
7398
7501
  _context.n = 4;
7399
- return createOptionalMintTxs(chain, relayCurrency, BYPASS_MINT_AMOUNT, 0n, address, api);
7502
+ return createOptionalMintTxs(chain, relayCurrency, bypassMintAmount, 0n, address, api);
7400
7503
  case 4:
7401
7504
  _t2 = _context.v;
7402
7505
  _context.n = 6;
@@ -7409,7 +7512,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
7409
7512
  _context.n = 8;
7410
7513
  break;
7411
7514
  }
7412
- amount = parseUnits(BYPASS_MINT_AMOUNT, feeAsset.decimals);
7515
+ amount = parseUnits(bypassMintAmount, feeAsset.decimals);
7413
7516
  _context.n = 7;
7414
7517
  return createMintTxs(chain, _objectSpread2(_objectSpread2({}, feeAsset), {}, {
7415
7518
  amount: amount
@@ -7428,7 +7531,7 @@ var wrapTxBypass = /*#__PURE__*/function () {
7428
7531
  balance = _context.v;
7429
7532
  bonus = mintBonusForSent(chain, asset, feeAsset, !!mintFeeAssets);
7430
7533
  if ((options === null || options === void 0 ? void 0 : options.sentAssetMintMode) === 'bypass') {
7431
- mintAmount = parseUnits(BYPASS_MINT_AMOUNT, asset.decimals) + asset.amount;
7534
+ mintAmount = parseUnits(bypassMintAmount, asset.decimals) + asset.amount;
7432
7535
  } else {
7433
7536
  missing = (_calcPreviewMintAmoun = calcPreviewMintAmount(balance, asset.amount)) !== null && _calcPreviewMintAmoun !== void 0 ? _calcPreviewMintAmoun : 0n;
7434
7537
  total = missing + bonus;
@@ -8307,6 +8410,20 @@ var getXcmFee = /*#__PURE__*/function () {
8307
8410
  };
8308
8411
  }();
8309
8412
 
8413
+ var aggregateHopFees = function aggregateHopFees(hops, matchAsset) {
8414
+ var totalHopFee = hops.reduce(function (acc, hop) {
8415
+ var _hop$result$fee;
8416
+ return isAssetXcEqual(hop.result.asset, matchAsset) ? acc + ((_hop$result$fee = hop.result.fee) !== null && _hop$result$fee !== void 0 ? _hop$result$fee : 0n) : acc;
8417
+ }, 0n);
8418
+ var bridgeHop = hops.find(function (hop) {
8419
+ return hop.chain.startsWith('BridgeHub');
8420
+ });
8421
+ return {
8422
+ totalHopFee: totalHopFee,
8423
+ bridgeFee: bridgeHop === null || bridgeHop === void 0 ? void 0 : bridgeHop.result.fee
8424
+ };
8425
+ };
8426
+
8310
8427
  var buildDestInfo = /*#__PURE__*/function () {
8311
8428
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
8312
8429
  var api, origin, destination, recipient, currency, originFee, isFeeAssetAh, destFeeDetail, totalHopFee, bridgeFee, destApi, destAsset, edDest, destBalance, destAmount, destFeeAssetEqual, effectiveDestFee, effectiveAmountForBalance, destBalanceSufficient, destBalanceAfter, createUnableToComputeError, isUnableToCompute, destbalanceAfterResult, destBalanceSufficientResult, receivedAmount, isSubBridge, nativeAssetOfOriginSymbol, isOriginAssetNative, destXcmFeeBalance, isDestFeeInNativeCurrency, destRecipientNativeBalance, destXcmFeeBalanceAfter;
@@ -8409,7 +8526,7 @@ var buildDestInfo = /*#__PURE__*/function () {
8409
8526
 
8410
8527
  var buildHopInfo = /*#__PURE__*/function () {
8411
8528
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
8412
- var api, chain, fee, originChain, asset, currency, hopApi, xcmFeeDetails, isBridgeHub, nativeAsset, hopAsset, ed;
8529
+ var api, chain, fee, originChain, asset, currency, hopApi, xcmFeeDetails, isBridgeHub, nativeAsset, hopAsset;
8413
8530
  return _regenerator().w(function (_context) {
8414
8531
  while (1) switch (_context.p = _context.n) {
8415
8532
  case 0:
@@ -8436,12 +8553,8 @@ var buildHopInfo = /*#__PURE__*/function () {
8436
8553
  });
8437
8554
  case 3:
8438
8555
  hopAsset = findAssetOnDestOrThrow(originChain, chain, currency);
8439
- ed = getExistentialDepositOrThrow(chain, {
8440
- location: hopAsset.location
8441
- });
8442
8556
  return _context.a(2, {
8443
8557
  asset: hopAsset,
8444
- existentialDeposit: ed,
8445
8558
  xcmFee: xcmFeeDetails
8446
8559
  });
8447
8560
  case 4:
@@ -8461,20 +8574,73 @@ var buildHopInfo = /*#__PURE__*/function () {
8461
8574
  };
8462
8575
  }();
8463
8576
 
8464
- var getTransferInfo = /*#__PURE__*/function () {
8465
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
8466
- var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, originAsset, amount, originBalance, edOrigin, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, originBalanceFee, isFeeAssetAh, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient, builtHops, totalHopFee, bridgeHop, destinationInfo;
8467
- return _regenerator().w(function (_context2) {
8468
- while (1) switch (_context2.p = _context2.n) {
8577
+ var buildOriginInfo = /*#__PURE__*/function () {
8578
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
8579
+ var api, origin, sender, currency, originAsset, amount, originFee, originFeeAsset, isFeeAssetAh, originBalance, edOrigin, originBalanceFee, originBalanceAfter, originBalanceFeeAfter, originBalanceNativeSufficient, originBalanceSufficient;
8580
+ return _regenerator().w(function (_context) {
8581
+ while (1) switch (_context.n) {
8469
8582
  case 0:
8470
- api = _ref.api, buildTx = _ref.buildTx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, ahAddress = _ref.ahAddress, recipient = _ref.recipient, currency = _ref.currency, feeAsset = _ref.feeAsset, version = _ref.version;
8471
- if (!(isChainEvm(origin) && !ahAddress)) {
8472
- _context2.n = 1;
8473
- break;
8474
- }
8475
- throw new MissingParameterError('ahAddress', "ahAddress is required for EVM origin ".concat(origin, "."));
8476
- case 1:
8477
- resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
8583
+ api = _ref.api, origin = _ref.origin, sender = _ref.sender, currency = _ref.currency, originAsset = _ref.originAsset, amount = _ref.amount, originFee = _ref.originFee, originFeeAsset = _ref.originFeeAsset, isFeeAssetAh = _ref.isFeeAssetAh;
8584
+ _context.n = 1;
8585
+ return getAssetBalanceInternal({
8586
+ api: api,
8587
+ address: sender,
8588
+ chain: origin,
8589
+ asset: originAsset
8590
+ });
8591
+ case 1:
8592
+ originBalance = _context.v;
8593
+ edOrigin = getExistentialDepositOrThrow(origin, currency);
8594
+ _context.n = 2;
8595
+ return getAssetBalanceInternal({
8596
+ api: api,
8597
+ address: sender,
8598
+ chain: origin,
8599
+ asset: originFeeAsset
8600
+ });
8601
+ case 2:
8602
+ originBalanceFee = _context.v;
8603
+ originBalanceAfter = originBalance - amount;
8604
+ originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
8605
+ originBalanceNativeSufficient = originBalanceFee >= originFee;
8606
+ originBalanceSufficient = originBalanceAfter >= edOrigin;
8607
+ return _context.a(2, {
8608
+ selectedCurrency: {
8609
+ sufficient: originBalanceSufficient,
8610
+ balance: originBalance,
8611
+ balanceAfter: originBalanceAfter,
8612
+ asset: originAsset
8613
+ },
8614
+ xcmFee: {
8615
+ sufficient: originBalanceNativeSufficient,
8616
+ fee: originFee,
8617
+ balance: originBalanceFee,
8618
+ balanceAfter: originBalanceFeeAfter,
8619
+ asset: originFeeAsset
8620
+ }
8621
+ });
8622
+ }
8623
+ }, _callee);
8624
+ }));
8625
+ return function buildOriginInfo(_x) {
8626
+ return _ref2.apply(this, arguments);
8627
+ };
8628
+ }();
8629
+
8630
+ var getTransferInfo = /*#__PURE__*/function () {
8631
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(_ref) {
8632
+ var api, buildTx, origin, destination, sender, ahAddress, recipient, currency, feeAsset, version, resolvedFeeAsset, originAsset, amount, _yield$getXcmFeeInter, _yield$getXcmFeeInter2, originFee, originFeeAsset, destFeeDetail, hops, isFeeAssetAh, originInfo, builtHops, _aggregateHopFees, totalHopFee, bridgeFee, destinationInfo;
8633
+ return _regenerator().w(function (_context2) {
8634
+ while (1) switch (_context2.p = _context2.n) {
8635
+ case 0:
8636
+ api = _ref.api, buildTx = _ref.buildTx, origin = _ref.origin, destination = _ref.destination, sender = _ref.sender, ahAddress = _ref.ahAddress, recipient = _ref.recipient, currency = _ref.currency, feeAsset = _ref.feeAsset, version = _ref.version;
8637
+ if (!(isChainEvm(origin) && !ahAddress)) {
8638
+ _context2.n = 1;
8639
+ break;
8640
+ }
8641
+ throw new MissingParameterError('ahAddress', "ahAddress is required for EVM origin ".concat(origin, "."));
8642
+ case 1:
8643
+ resolvedFeeAsset = feeAsset ? resolveFeeAsset(feeAsset, origin, destination, currency) : undefined;
8478
8644
  _context2.n = 2;
8479
8645
  return api.init(origin);
8480
8646
  case 2:
@@ -8483,16 +8649,6 @@ var getTransferInfo = /*#__PURE__*/function () {
8483
8649
  originAsset = findAssetInfoOrThrow(origin, currency, destination);
8484
8650
  amount = abstractDecimals(currency.amount, originAsset.decimals, api);
8485
8651
  _context2.n = 4;
8486
- return getAssetBalanceInternal({
8487
- api: api,
8488
- address: sender,
8489
- chain: origin,
8490
- asset: originAsset
8491
- });
8492
- case 4:
8493
- originBalance = _context2.v;
8494
- edOrigin = getExistentialDepositOrThrow(origin, currency);
8495
- _context2.n = 5;
8496
8652
  return getXcmFee({
8497
8653
  api: api,
8498
8654
  buildTx: buildTx,
@@ -8505,33 +8661,34 @@ var getTransferInfo = /*#__PURE__*/function () {
8505
8661
  version: version,
8506
8662
  disableFallback: false
8507
8663
  });
8508
- case 5:
8664
+ case 4:
8509
8665
  _yield$getXcmFeeInter = _context2.v;
8510
8666
  _yield$getXcmFeeInter2 = _yield$getXcmFeeInter.origin;
8511
8667
  originFee = _yield$getXcmFeeInter2.fee;
8512
8668
  originFeeAsset = _yield$getXcmFeeInter2.asset;
8513
8669
  destFeeDetail = _yield$getXcmFeeInter.destination;
8514
8670
  hops = _yield$getXcmFeeInter.hops;
8515
- _context2.n = 6;
8516
- return getAssetBalanceInternal({
8671
+ isFeeAssetAh = origin === 'AssetHubPolkadot' && !!resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
8672
+ _context2.n = 5;
8673
+ return buildOriginInfo({
8517
8674
  api: api,
8518
- address: sender,
8519
- chain: origin,
8520
- asset: originFeeAsset
8675
+ origin: origin,
8676
+ sender: sender,
8677
+ currency: currency,
8678
+ originAsset: originAsset,
8679
+ amount: amount,
8680
+ originFee: originFee,
8681
+ originFeeAsset: originFeeAsset,
8682
+ isFeeAssetAh: isFeeAssetAh
8521
8683
  });
8522
- case 6:
8523
- originBalanceFee = _context2.v;
8524
- isFeeAssetAh = origin === 'AssetHubPolkadot' && resolvedFeeAsset && isAssetEqual(resolvedFeeAsset, originAsset);
8525
- originBalanceAfter = originBalance - amount;
8526
- originBalanceFeeAfter = isFeeAssetAh ? originBalanceFee - amount : originBalanceFee - originFee;
8527
- originBalanceNativeSufficient = originBalanceFee >= originFee;
8528
- originBalanceSufficient = originBalanceAfter >= edOrigin;
8684
+ case 5:
8685
+ originInfo = _context2.v;
8529
8686
  builtHops = [];
8530
8687
  if (!(hops && hops.length > 0)) {
8531
- _context2.n = 8;
8688
+ _context2.n = 7;
8532
8689
  break;
8533
8690
  }
8534
- _context2.n = 7;
8691
+ _context2.n = 6;
8535
8692
  return Promise.all(hops.map(/*#__PURE__*/function () {
8536
8693
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(hop) {
8537
8694
  var result;
@@ -8562,16 +8719,11 @@ var getTransferInfo = /*#__PURE__*/function () {
8562
8719
  return _ref3.apply(this, arguments);
8563
8720
  };
8564
8721
  }()));
8565
- case 7:
8722
+ case 6:
8566
8723
  builtHops = _context2.v;
8567
- case 8:
8568
- totalHopFee = hops.reduce(function (acc, hop) {
8569
- return isAssetXcEqual(hop.result.asset, originAsset) ? acc + hop.result.fee : acc;
8570
- }, 0n);
8571
- bridgeHop = hops.find(function (hop) {
8572
- return hop.chain.startsWith('BridgeHub');
8573
- });
8574
- _context2.n = 9;
8724
+ case 7:
8725
+ _aggregateHopFees = aggregateHopFees(hops, originAsset), totalHopFee = _aggregateHopFees.totalHopFee, bridgeFee = _aggregateHopFees.bridgeFee;
8726
+ _context2.n = 8;
8575
8727
  return buildDestInfo({
8576
8728
  api: api,
8577
8729
  origin: origin,
@@ -8581,12 +8733,12 @@ var getTransferInfo = /*#__PURE__*/function () {
8581
8733
  amount: amount
8582
8734
  }),
8583
8735
  originFee: originFee,
8584
- isFeeAssetAh: !!isFeeAssetAh,
8736
+ isFeeAssetAh: isFeeAssetAh,
8585
8737
  destFeeDetail: destFeeDetail,
8586
8738
  totalHopFee: totalHopFee,
8587
- bridgeFee: bridgeHop === null || bridgeHop === void 0 ? void 0 : bridgeHop.result.fee
8739
+ bridgeFee: bridgeFee
8588
8740
  });
8589
- case 9:
8741
+ case 8:
8590
8742
  destinationInfo = _context2.v;
8591
8743
  return _context2.a(2, {
8592
8744
  chain: {
@@ -8594,35 +8746,21 @@ var getTransferInfo = /*#__PURE__*/function () {
8594
8746
  destination: destination,
8595
8747
  ecosystem: getRelayChainSymbol(origin)
8596
8748
  },
8597
- origin: {
8598
- selectedCurrency: {
8599
- sufficient: originBalanceSufficient,
8600
- balance: originBalance,
8601
- balanceAfter: originBalanceAfter,
8602
- asset: originAsset
8603
- },
8604
- xcmFee: {
8605
- sufficient: originBalanceNativeSufficient,
8606
- fee: originFee,
8607
- balance: originBalanceFee,
8608
- balanceAfter: originBalanceFeeAfter,
8609
- asset: originFeeAsset
8610
- }
8611
- },
8749
+ origin: originInfo,
8612
8750
  hops: builtHops,
8613
8751
  destination: destinationInfo
8614
8752
  });
8615
- case 10:
8616
- _context2.p = 10;
8753
+ case 9:
8754
+ _context2.p = 9;
8617
8755
  api.disconnectAllowed = true;
8618
- _context2.n = 11;
8756
+ _context2.n = 10;
8619
8757
  return api.disconnect();
8758
+ case 10:
8759
+ return _context2.f(9);
8620
8760
  case 11:
8621
- return _context2.f(10);
8622
- case 12:
8623
8761
  return _context2.a(2);
8624
8762
  }
8625
- }, _callee2, null, [[3,, 10, 12]]);
8763
+ }, _callee2, null, [[3,, 9, 11]]);
8626
8764
  }));
8627
8765
  return function getTransferInfo(_x) {
8628
8766
  return _ref2.apply(this, arguments);
@@ -8960,15 +9098,16 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
8960
9098
  reserve = context.reserve,
8961
9099
  dest = context.dest,
8962
9100
  assetInfo = context.assetInfo,
9101
+ bridgeHopChain = context.bridgeHopChain,
8963
9102
  _context$options = context.options,
8964
9103
  version = _context$options.version,
8965
9104
  pallet = _context$options.pallet,
8966
9105
  method = _context$options.method,
8967
9106
  overriddenAsset = _context$options.overriddenAsset;
8968
9107
  var feeAssetLocation = !isDotAsset ? RELAY_LOCATION : assetInfo.location;
8969
- var finalDest = origin.chain === reserve.chain ? dest.chain : reserve.chain;
9108
+ var finalDest = bridgeHopChain !== null && bridgeHopChain !== void 0 ? bridgeHopChain : origin.chain === reserve.chain ? dest.chain : reserve.chain;
8970
9109
  var destLocation = createDestination(version, origin.chain, finalDest, getParaId(finalDest));
8971
- var transferType = resolveTransferType(context);
9110
+ var transferType = bridgeHopChain ? 'DestinationReserve' : resolveTransferType(context);
8972
9111
  var feeAsset = Array.isArray(overriddenAsset) ? overriddenAsset.find(function (a) {
8973
9112
  return a.isFeeAsset;
8974
9113
  }) : null;
@@ -8991,34 +9130,31 @@ var buildTypeAndThenCall = function buildTypeAndThenCall(context, isDotAsset, cu
8991
9130
  };
8992
9131
 
8993
9132
  var getBridgeReserve = function getBridgeReserve(chain, destination, location) {
8994
- var isExternal = isExternalChain(destination);
8995
- var destRelay = isExternal ? destination : getRelayChainOf(destination).toLowerCase();
8996
- var expectedConsensus = isExternal ? getEthereumJunction(chain, false).GlobalConsensus : _defineProperty({}, destRelay, null);
9133
+ var expectedConsensus = isExternalChain(destination) ? getEthereumJunction(chain, false).GlobalConsensus : _defineProperty({}, getRelayChainOf(destination).toLowerCase(), null);
8997
9134
  var isDestReserve = deepEqual(getJunctionValue(location, 'GlobalConsensus'), expectedConsensus);
8998
9135
  return isDestReserve ? destination : chain;
8999
9136
  };
9000
- var resolveReserveChain = function resolveReserveChain(chain, destination, assetLocation, isSubBridge, isSnowbridge, overrideReserve) {
9001
- if (isSubBridge || isSnowbridge) {
9137
+ var resolveReserveChain = function resolveReserveChain(chain, destination, assetLocation, isSubBridge, overrideReserve) {
9138
+ if (isSubBridge) {
9002
9139
  return getBridgeReserve(chain, destination, assetLocation);
9003
9140
  }
9004
9141
  if (overrideReserve !== undefined) {
9005
9142
  return overrideReserve;
9006
9143
  }
9007
- return getAssetReserveChain(chain, assetLocation);
9144
+ return getAssetReserveChain(chain, assetLocation, true);
9008
9145
  };
9009
9146
  var createTypeAndThenCallContext = /*#__PURE__*/function () {
9010
9147
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, overrides) {
9011
9148
  var _overrides$noFeeAsset;
9012
- var api, chain, destination, assetInfo, destinationChain, isSubBridge, isSb, reserveChain, NO_FEE_ASSET_LOCS, systemAsset, isRelayAsset, destApi, reserveApi;
9149
+ var api, chain, destination, assetInfo, isSubBridge, isSb, reserveChain, NO_FEE_ASSET_LOCS, systemAsset, assetGlobalConsensus, originRelayChain, isAssetHubToExternal, isForeignRelayToExternal, isRelayAsset, bridgeHopChain, destApi, reserveApi;
9013
9150
  return _regenerator().w(function (_context) {
9014
9151
  while (1) switch (_context.n) {
9015
9152
  case 0:
9016
9153
  api = options.api, chain = options.chain, destination = options.destination, assetInfo = options.assetInfo;
9017
9154
  assertToIsString(destination);
9018
- destinationChain = destination;
9019
- isSubBridge = isSubstrateBridge(chain, destinationChain);
9020
- isSb = isSnowbridge(chain, destinationChain);
9021
- reserveChain = resolveReserveChain(chain, destinationChain, assetInfo.location, isSubBridge, isSb, overrides.reserveChain);
9155
+ isSubBridge = isSubstrateBridge(chain, destination);
9156
+ isSb = isSnowbridge(chain, destination);
9157
+ reserveChain = resolveReserveChain(chain, destination, assetInfo.location, isSubBridge, overrides.reserveChain);
9022
9158
  NO_FEE_ASSET_LOCS = [RELAY_LOCATION, {
9023
9159
  parents: 2,
9024
9160
  interior: {
@@ -9046,14 +9182,21 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
9046
9182
  }
9047
9183
  }];
9048
9184
  systemAsset = findNativeAssetInfoOrThrow(getRelayChainOf(chain));
9049
- isRelayAsset = NO_FEE_ASSET_LOCS.some(function (loc) {
9185
+ assetGlobalConsensus = getJunctionValue(assetInfo.location, 'GlobalConsensus');
9186
+ originRelayChain = getRelayChainOf(chain);
9187
+ isAssetHubToExternal = chain.startsWith('AssetHub') && isExternalChain(destination);
9188
+ isForeignRelayToExternal = isExternalChain(destination) && !chain.startsWith('AssetHub') && assetInfo.location.parents === 2 && RELAYCHAINS.some(function (relay) {
9189
+ return relay !== originRelayChain && deepEqual(assetGlobalConsensus, _defineProperty({}, relay.toLowerCase(), null));
9190
+ });
9191
+ isRelayAsset = !isForeignRelayToExternal && (isAssetHubToExternal || NO_FEE_ASSET_LOCS.some(function (loc) {
9050
9192
  return deepEqual(assetInfo.location, loc);
9051
- }) || isSubBridge || ((_overrides$noFeeAsset = overrides.noFeeAsset) !== null && _overrides$noFeeAsset !== void 0 ? _overrides$noFeeAsset : false);
9193
+ }) || isSubBridge || ((_overrides$noFeeAsset = overrides.noFeeAsset) !== null && _overrides$noFeeAsset !== void 0 ? _overrides$noFeeAsset : false));
9194
+ bridgeHopChain = !chain.startsWith('AssetHub') && assetGlobalConsensus !== undefined ? "AssetHub".concat(originRelayChain) : undefined;
9052
9195
  destApi = api.clone();
9053
9196
  _context.n = 1;
9054
- return destApi.init(destinationChain);
9197
+ return destApi.init(destination);
9055
9198
  case 1:
9056
- reserveApi = reserveChain === chain ? api : reserveChain === destinationChain ? destApi : api.clone();
9199
+ reserveApi = reserveChain === chain ? api : reserveChain === destination ? destApi : api.clone();
9057
9200
  _context.n = 2;
9058
9201
  return reserveApi.init(reserveChain);
9059
9202
  case 2:
@@ -9064,7 +9207,7 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
9064
9207
  },
9065
9208
  dest: {
9066
9209
  api: destApi,
9067
- chain: destinationChain
9210
+ chain: destination
9068
9211
  },
9069
9212
  reserve: {
9070
9213
  api: reserveApi,
@@ -9075,7 +9218,8 @@ var createTypeAndThenCallContext = /*#__PURE__*/function () {
9075
9218
  isRelayAsset: isRelayAsset,
9076
9219
  assetInfo: assetInfo,
9077
9220
  options: options,
9078
- systemAsset: systemAsset
9221
+ systemAsset: systemAsset,
9222
+ bridgeHopChain: bridgeHopChain
9079
9223
  });
9080
9224
  }
9081
9225
  }, _callee);
@@ -9097,24 +9241,39 @@ var resolveBuyExecutionAmount = function resolveBuyExecutionAmount(_ref, isForFe
9097
9241
  // We have actual fees, calculate exact buy execution amount
9098
9242
  return isRelayAsset ? assetInfo.amount - hopFees : destFee;
9099
9243
  };
9244
+ var resolveSnowbridgeMessageId = function resolveSnowbridgeMessageId(_ref3) {
9245
+ var origin = _ref3.origin,
9246
+ isSnowbridge = _ref3.isSnowbridge,
9247
+ assetInfo = _ref3.assetInfo,
9248
+ _ref3$options = _ref3.options,
9249
+ sender = _ref3$options.sender,
9250
+ recipient = _ref3$options.recipient;
9251
+ if (!isSnowbridge) return Promise.resolve(null);
9252
+ assertSender(sender);
9253
+ return generateMessageId(origin.api, sender, getParaId(origin.chain), JSON.stringify(assetInfo.location), JSON.stringify(recipient), assetInfo.amount);
9254
+ };
9100
9255
  var createCustomXcm = /*#__PURE__*/function () {
9101
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, assetCount, isForFeeCalc, systemAssetAmount, refundInstruction) {
9256
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context, assetCount, isForFeeCalc, systemAssetAmount) {
9102
9257
  var fees,
9103
9258
  origin,
9104
9259
  dest,
9105
9260
  reserve,
9106
9261
  isSubBridge,
9107
- isSnowbridge,
9108
9262
  isRelayAsset,
9109
9263
  assetInfo,
9264
+ bridgeHopChain,
9110
9265
  options,
9111
9266
  destination,
9112
9267
  version,
9113
- sender,
9114
9268
  recipient,
9115
9269
  paraIdTo,
9270
+ sender,
9271
+ ahAddress,
9272
+ buildRefundInstruction,
9116
9273
  hopFees,
9117
9274
  destFee,
9275
+ messageId,
9276
+ setTopic,
9118
9277
  feeAssetLocation,
9119
9278
  feeLocLocalized,
9120
9279
  assetLocLocalized,
@@ -9122,22 +9281,59 @@ var createCustomXcm = /*#__PURE__*/function () {
9122
9281
  allOfSelector,
9123
9282
  depositInstruction,
9124
9283
  assetsFilter,
9284
+ isAssetEthereumNative,
9125
9285
  buyExecutionAmount,
9126
9286
  filter,
9287
+ buyExecutionAsset,
9127
9288
  buyExecution,
9128
9289
  destLoc,
9129
- messageId,
9290
+ _refund,
9291
+ buyExecutionAtReserve,
9292
+ _refund2,
9293
+ refund,
9130
9294
  _args = arguments;
9131
9295
  return _regenerator().w(function (_context) {
9132
9296
  while (1) switch (_context.n) {
9133
9297
  case 0:
9134
- fees = _args.length > 5 && _args[5] !== undefined ? _args[5] : {
9298
+ fees = _args.length > 4 && _args[4] !== undefined ? _args[4] : {
9135
9299
  hopFees: 0n,
9136
9300
  destFee: 0n
9137
9301
  };
9138
- origin = context.origin, dest = context.dest, reserve = context.reserve, isSubBridge = context.isSubBridge, isSnowbridge = context.isSnowbridge, isRelayAsset = context.isRelayAsset, assetInfo = context.assetInfo, options = context.options;
9139
- destination = options.destination, version = options.version, sender = options.sender, recipient = options.recipient, paraIdTo = options.paraIdTo;
9302
+ origin = context.origin, dest = context.dest, reserve = context.reserve, isSubBridge = context.isSubBridge, isRelayAsset = context.isRelayAsset, assetInfo = context.assetInfo, bridgeHopChain = context.bridgeHopChain, options = context.options;
9303
+ destination = options.destination, version = options.version, recipient = options.recipient, paraIdTo = options.paraIdTo, sender = options.sender, ahAddress = options.ahAddress;
9304
+ buildRefundInstruction = function buildRefundInstruction() {
9305
+ if (!sender || isSubBridge) return null;
9306
+ var resolveRefundAddress = function resolveRefundAddress() {
9307
+ if (ahAddress) return ahAddress;
9308
+ if (!isChainEvm(origin.chain)) return sender;
9309
+ if (!isChainEvm(dest.chain)) return recipient;
9310
+ throw new MissingParameterError('ahAddress');
9311
+ };
9312
+ return {
9313
+ SetAppendix: [{
9314
+ DepositAsset: {
9315
+ assets: {
9316
+ Wild: {
9317
+ AllCounted: assetCount
9318
+ }
9319
+ },
9320
+ beneficiary: createBeneficiaryLocation({
9321
+ api: origin.api,
9322
+ address: resolveRefundAddress(),
9323
+ version: version
9324
+ })
9325
+ }
9326
+ }]
9327
+ };
9328
+ };
9140
9329
  hopFees = fees.hopFees, destFee = fees.destFee;
9330
+ _context.n = 1;
9331
+ return resolveSnowbridgeMessageId(context);
9332
+ case 1:
9333
+ messageId = _context.v;
9334
+ setTopic = messageId ? [{
9335
+ SetTopic: messageId
9336
+ }] : [];
9141
9337
  feeAssetLocation = !isRelayAsset ? RELAY_LOCATION : assetInfo.location;
9142
9338
  feeLocLocalized = localizeLocation(dest.chain, feeAssetLocation, origin.chain);
9143
9339
  assetLocLocalized = localizeLocation(dest.chain, assetInfo.location, origin.chain);
@@ -9163,19 +9359,20 @@ var createCustomXcm = /*#__PURE__*/function () {
9163
9359
  }
9164
9360
  };
9165
9361
  assetsFilter = [];
9166
- if (!isRelayAsset) assetsFilter.push(createAsset(version, hopFees + destFee, localizeLocation(reserve.chain, RELAY_LOCATION)));
9362
+ if (!isRelayAsset && !isExternalChain(dest.chain)) assetsFilter.push(createAsset(version, hopFees + destFee, localizeLocation(reserve.chain, RELAY_LOCATION)));
9167
9363
  assetsFilter.push(createAsset(version, assetInfo.amount, normalizeLocation(localizeLocation(reserve.chain, assetInfo.location), version)));
9168
- if (!(isSubBridge || origin.chain !== reserve.chain && dest.chain !== reserve.chain)) {
9169
- _context.n = 4;
9364
+ isAssetEthereumNative = deepEqual(getJunctionValue(assetInfo.location, 'GlobalConsensus'), getEthereumJunction(origin.chain, false).GlobalConsensus);
9365
+ if (!(isSubBridge || bridgeHopChain || origin.chain !== reserve.chain && dest.chain !== reserve.chain)) {
9366
+ _context.n = 6;
9170
9367
  break;
9171
9368
  }
9172
- buyExecutionAmount = resolveBuyExecutionAmount(context, isForFeeCalc, fees, systemAssetAmount);
9369
+ buyExecutionAmount = isExternalChain(dest.chain) ? 1n : resolveBuyExecutionAmount(context, isForFeeCalc, fees, systemAssetAmount);
9173
9370
  if (!(buyExecutionAmount < 0n && !isForFeeCalc)) {
9174
- _context.n = 1;
9371
+ _context.n = 2;
9175
9372
  break;
9176
9373
  }
9177
9374
  throw new AmountTooLowError();
9178
- case 1:
9375
+ case 2:
9179
9376
  filter = isForFeeCalc ? {
9180
9377
  Wild: {
9181
9378
  AllCounted: assetCount
@@ -9183,81 +9380,78 @@ var createCustomXcm = /*#__PURE__*/function () {
9183
9380
  } : {
9184
9381
  Definite: assetsFilter
9185
9382
  };
9383
+ buyExecutionAsset = isExternalChain(dest.chain) ? createAsset(version, buyExecutionAmount, assetLocLocalized) : createAsset(version, normalizeAmount(buyExecutionAmount), feeLocLocalized);
9186
9384
  buyExecution = {
9187
9385
  BuyExecution: {
9188
- fees: createAsset(version, normalizeAmount(buyExecutionAmount), feeLocLocalized),
9386
+ fees: buyExecutionAsset,
9189
9387
  weight_limit: 'Unlimited'
9190
9388
  }
9191
9389
  };
9192
9390
  if (!isSubBridge) {
9193
- _context.n = 2;
9391
+ _context.n = 3;
9194
9392
  break;
9195
9393
  }
9196
9394
  return _context.a(2, [buyExecution, depositInstruction]);
9197
- case 2:
9395
+ case 3:
9198
9396
  destLoc = createDestination(version, origin.chain, destination, paraIdTo); // If both reserve (B) and destination (C) are trusted chains,
9199
9397
  // use teleport instead of DepositReserveAsset
9200
9398
  if (!(isTrustedChain(reserve.chain) && isTrustedChain(dest.chain))) {
9201
- _context.n = 3;
9399
+ _context.n = 4;
9202
9400
  break;
9203
9401
  }
9204
- return _context.a(2, [].concat(_toConsumableArray(refundInstruction ? [refundInstruction] : []), [{
9402
+ _refund = buildRefundInstruction();
9403
+ return _context.a(2, [].concat(_toConsumableArray(_refund ? [_refund] : []), [{
9205
9404
  InitiateTeleport: {
9206
9405
  assets: filter,
9207
9406
  dest: destLoc,
9208
- xcm: [buyExecution, depositInstruction]
9209
- }
9210
- }]));
9211
- case 3:
9212
- return _context.a(2, [].concat(_toConsumableArray(refundInstruction ? [refundInstruction] : []), [{
9213
- DepositReserveAsset: {
9214
- assets: filter,
9215
- dest: destLoc,
9216
- xcm: [buyExecution, depositInstruction]
9407
+ xcm: [buyExecution, depositInstruction].concat(setTopic)
9217
9408
  }
9218
- }]));
9409
+ }], setTopic));
9219
9410
  case 4:
9220
- if (!isSnowbridge) {
9221
- _context.n = 6;
9411
+ if (!(isExternalChain(dest.chain) && (isAssetEthereumNative || origin.chain === 'Mythos'))) {
9412
+ _context.n = 5;
9222
9413
  break;
9223
9414
  }
9224
- assertSender(sender);
9225
- _context.n = 5;
9226
- return generateMessageId(origin.api, sender, getParaId(origin.chain), JSON.stringify(assetInfo.location), JSON.stringify(recipient), assetInfo.amount);
9415
+ buyExecutionAtReserve = {
9416
+ BuyExecution: {
9417
+ fees: buyExecutionAsset,
9418
+ weight_limit: 'Unlimited'
9419
+ }
9420
+ };
9421
+ _refund2 = buildRefundInstruction();
9422
+ return _context.a(2, [].concat(_toConsumableArray(_refund2 ? [_refund2] : []), [{
9423
+ InitiateReserveWithdraw: {
9424
+ assets: {
9425
+ Wild: {
9426
+ AllOf: {
9427
+ id: assetInfo.location,
9428
+ fun: 'Fungible'
9429
+ }
9430
+ }
9431
+ },
9432
+ reserve: destLoc,
9433
+ xcm: [buyExecutionAtReserve, depositInstruction].concat(setTopic)
9434
+ }
9435
+ }], setTopic));
9227
9436
  case 5:
9228
- messageId = _context.v;
9229
- return _context.a(2, [depositInstruction, {
9230
- SetTopic: messageId
9231
- }]);
9437
+ refund = buildRefundInstruction();
9438
+ return _context.a(2, [].concat(_toConsumableArray(refund ? [refund] : []), [{
9439
+ DepositReserveAsset: {
9440
+ assets: filter,
9441
+ dest: destLoc,
9442
+ xcm: [buyExecution, depositInstruction].concat(setTopic)
9443
+ }
9444
+ }], setTopic));
9232
9445
  case 6:
9233
- return _context.a(2, [depositInstruction]);
9446
+ return _context.a(2, [depositInstruction].concat(setTopic));
9234
9447
  }
9235
9448
  }, _callee);
9236
9449
  }));
9237
- return function createCustomXcm(_x, _x2, _x3, _x4, _x5) {
9238
- return _ref3.apply(this, arguments);
9450
+ return function createCustomXcm(_x, _x2, _x3, _x4) {
9451
+ return _ref4.apply(this, arguments);
9239
9452
  };
9240
9453
  }();
9241
9454
 
9242
- var createRefundInstruction = function createRefundInstruction(api, address, version, assetCount) {
9243
- return {
9244
- SetAppendix: [{
9245
- DepositAsset: {
9246
- assets: {
9247
- Wild: {
9248
- AllCounted: assetCount
9249
- }
9250
- },
9251
- beneficiary: createBeneficiaryLocation({
9252
- api: api,
9253
- address: address,
9254
- version: version
9255
- })
9256
- }
9257
- }]
9258
- };
9259
- };
9260
-
9261
9455
  var buildAssets = function buildAssets(chain, asset, feeAmount, isRelayAsset, _ref) {
9262
9456
  var version = _ref.version,
9263
9457
  overriddenAsset = _ref.overriddenAsset;
@@ -9279,26 +9473,25 @@ var resolveAssetCount = function resolveAssetCount(overriddenAsset, isRelayAsset
9279
9473
  return isRelayAsset ? 1 : 2;
9280
9474
  };
9281
9475
  var DEFAULT_SYSTEM_ASSET_AMOUNT = '1';
9476
+ var DEFAULT_SYSTEM_ASSET_AMOUNT_EXTERNAL = '10';
9282
9477
  var resolveSystemAssetAmount = function resolveSystemAssetAmount(_ref2, isForFeeCalc, fees) {
9283
- var systemAsset = _ref2.systemAsset;
9478
+ var systemAsset = _ref2.systemAsset,
9479
+ dest = _ref2.dest;
9284
9480
  if (isForFeeCalc) {
9285
- return parseUnits(DEFAULT_SYSTEM_ASSET_AMOUNT, systemAsset.decimals);
9481
+ var defaultAmount = isExternalChain(dest.chain) ? DEFAULT_SYSTEM_ASSET_AMOUNT_EXTERNAL : DEFAULT_SYSTEM_ASSET_AMOUNT;
9482
+ return parseUnits(defaultAmount, systemAsset.decimals);
9286
9483
  }
9287
- return fees.destFee + fees.hopFees;
9484
+ return normalizeAmount(fees.destFee + fees.hopFees);
9288
9485
  };
9289
9486
  var constructTypeAndThenCall = /*#__PURE__*/function () {
9290
9487
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(context) {
9291
9488
  var fees,
9292
9489
  origin,
9293
9490
  assetInfo,
9294
- isSubBridge,
9295
9491
  isRelayAsset,
9296
9492
  options,
9297
- sender,
9298
- version,
9299
9493
  overriddenAsset,
9300
9494
  assetCount,
9301
- refundInstruction,
9302
9495
  resolvedFees,
9303
9496
  isForFeeCalc,
9304
9497
  systemAssetAmount,
@@ -9309,10 +9502,9 @@ var constructTypeAndThenCall = /*#__PURE__*/function () {
9309
9502
  while (1) switch (_context.n) {
9310
9503
  case 0:
9311
9504
  fees = _args.length > 1 && _args[1] !== undefined ? _args[1] : null;
9312
- origin = context.origin, assetInfo = context.assetInfo, isSubBridge = context.isSubBridge, isRelayAsset = context.isRelayAsset, options = context.options;
9313
- sender = options.sender, version = options.version, overriddenAsset = options.overriddenAsset;
9505
+ origin = context.origin, assetInfo = context.assetInfo, isRelayAsset = context.isRelayAsset, options = context.options;
9506
+ overriddenAsset = options.overriddenAsset;
9314
9507
  assetCount = resolveAssetCount(overriddenAsset, isRelayAsset);
9315
- refundInstruction = sender && !isSubBridge ? createRefundInstruction(origin.api, sender, version, assetCount) : null;
9316
9508
  resolvedFees = fees !== null && fees !== void 0 ? fees : {
9317
9509
  hopFees: 0n,
9318
9510
  destFee: 0n
@@ -9320,7 +9512,7 @@ var constructTypeAndThenCall = /*#__PURE__*/function () {
9320
9512
  isForFeeCalc = fees === null;
9321
9513
  systemAssetAmount = resolveSystemAssetAmount(context, isForFeeCalc, resolvedFees);
9322
9514
  _context.n = 1;
9323
- return createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, refundInstruction, resolvedFees);
9515
+ return createCustomXcm(context, assetCount, isForFeeCalc, systemAssetAmount, resolvedFees);
9324
9516
  case 1:
9325
9517
  customXcm = _context.v;
9326
9518
  assets = buildAssets(origin.chain, assetInfo, systemAssetAmount, isRelayAsset, options);
@@ -10040,6 +10232,8 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
10040
10232
  paraIdTo = options.paraIdTo,
10041
10233
  transactOptions = options.transactOptions,
10042
10234
  useFeeAssetOnHops = options.useFeeAssetOnHops,
10235
+ _options$forceBuyExec = options.forceBuyExecution,
10236
+ forceBuyExecution = _options$forceBuyExec === void 0 ? false : _options$forceBuyExec,
10043
10237
  _options$suffixXcm = options.suffixXcm,
10044
10238
  suffixXcm = _options$suffixXcm === void 0 ? [] : _options$suffixXcm;
10045
10239
  var _prepareExecuteContex = prepareExecuteContext(options),
@@ -10071,7 +10265,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
10071
10265
  DepositReserveAsset: {
10072
10266
  assets: createAssetsFilter(assetLocalizedToReserve, version),
10073
10267
  dest: createDestination(version, reserveChain !== null && reserveChain !== void 0 ? reserveChain : chain, destChain, paraIdTo),
10074
- xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToDest !== null && hopFeeAssetToDest !== void 0 ? hopFeeAssetToDest : updateAsset(assetLocalizedToDest, reserveFee === 1000n ? amount / 2n : amount - originFeeDeduction - reserveFee))), _toConsumableArray(suffixXcm))
10268
+ xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToDest !== null && hopFeeAssetToDest !== void 0 ? hopFeeAssetToDest : updateAsset(assetLocalizedToDest, reserveFee === 1000n ? amount / 2n : amount - originFeeDeduction - reserveFee), undefined, true, forceBuyExecution)), _toConsumableArray(suffixXcm))
10075
10269
  }
10076
10270
  }];
10077
10271
  var mainInstructions;
@@ -10098,7 +10292,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
10098
10292
  InitiateTeleport: {
10099
10293
  assets: routingAssetsFilter,
10100
10294
  dest: destLocation,
10101
- xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToDest !== null && hopFeeAssetToDest !== void 0 ? hopFeeAssetToDest : updateAsset(assetLocalizedToDest, amount - originFeeDeduction))), _toConsumableArray(suffixXcm))
10295
+ xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToDest !== null && hopFeeAssetToDest !== void 0 ? hopFeeAssetToDest : updateAsset(assetLocalizedToDest, amount - originFeeDeduction), undefined, true, forceBuyExecution)), _toConsumableArray(suffixXcm))
10102
10296
  }
10103
10297
  }];
10104
10298
  break;
@@ -10108,7 +10302,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
10108
10302
  InitiateTeleport: {
10109
10303
  assets: routingAssetsFilter,
10110
10304
  dest: getChainLocation(chain, reserveChain),
10111
- xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - originFeeDeduction))), _toConsumableArray(resolvedDepositInstruction))
10305
+ xcm: [].concat(_toConsumableArray(createPayFees(version, hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - originFeeDeduction), undefined, true, forceBuyExecution)), _toConsumableArray(resolvedDepositInstruction))
10112
10306
  }
10113
10307
  }];
10114
10308
  break;
@@ -10120,7 +10314,7 @@ var createBaseExecuteXcm = function createBaseExecuteXcm(options) {
10120
10314
  reserve: getChainLocation(chain, reserveChain),
10121
10315
  xcm: [].concat(_toConsumableArray(createPayFees(version, // Decrease amount by 2 units because for some reason polkadot withdraws 2 units less
10122
10316
  // than requested, so we need to account for that
10123
- hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - 2n))), _toConsumableArray(resolvedDepositInstruction))
10317
+ hopFeeAssetToReserve !== null && hopFeeAssetToReserve !== void 0 ? hopFeeAssetToReserve : updateAsset(assetLocalizedToReserve, amount - 2n), undefined, true, forceBuyExecution)), _toConsumableArray(resolvedDepositInstruction))
10124
10318
  }
10125
10319
  }];
10126
10320
  break;
@@ -10240,7 +10434,9 @@ var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToD
10240
10434
  feeAsset = options.feeAssetInfo,
10241
10435
  useJitWithdraw = options.useJitWithdraw,
10242
10436
  recipient = options.recipient,
10243
- version = options.version;
10437
+ version = options.version,
10438
+ _options$forceBuyExec = options.forceBuyExecution,
10439
+ forceBuyExecution = _options$forceBuyExec === void 0 ? false : _options$forceBuyExec;
10244
10440
  var context = prepareExecuteContext(options);
10245
10441
  var assetLocalized = context.assetLocalized,
10246
10442
  assetLocalizedToDest = context.assetLocalizedToDest,
@@ -10254,7 +10450,7 @@ var prepareCommonExecuteXcm = function prepareCommonExecuteXcm(options, assetToD
10254
10450
  prefix.push.apply(prefix, _toConsumableArray(createPayFees(version, feeAssetLocalized !== null && feeAssetLocalized !== void 0 ? feeAssetLocalized : assetLocalized, {
10255
10451
  refTime: 450n,
10256
10452
  proofSize: 0n
10257
- })));
10453
+ }, false, forceBuyExecution)));
10258
10454
  } else {
10259
10455
  prefix.push({
10260
10456
  SetFeesMode: {
@@ -10522,7 +10718,8 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
10522
10718
  originFee: hasSeparateFeeAsset ? ethBridgeFee || originFee : originFee,
10523
10719
  reserveFee: originReserveFee
10524
10720
  },
10525
- version: version
10721
+ version: version,
10722
+ forceBuyExecution: true
10526
10723
  }, assetToLocalizedToDest), prefix = _prepareCommonExecute.prefix, depositInstruction = _prepareCommonExecute.depositInstruction;
10527
10724
  _context2.n = 4;
10528
10725
  return createExchangeInstructions(options, assetFrom, assetTo, isEthereumDest && hasSeparateFeeAsset);
@@ -10559,6 +10756,7 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
10559
10756
  originFee: hasSeparateFeeAsset ? ethBridgeFee : 0n,
10560
10757
  reserveFee: destReserveFee
10561
10758
  },
10759
+ forceBuyExecution: true,
10562
10760
  suffixXcm: snowbridgeInstructions
10563
10761
  });
10564
10762
  _context2.n = 7;
@@ -10576,6 +10774,7 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
10576
10774
  originFee: 0n,
10577
10775
  reserveFee: destReserveFee
10578
10776
  },
10777
+ forceBuyExecution: true,
10579
10778
  suffixXcm: [depositInstruction]
10580
10779
  });
10581
10780
  } else {
@@ -10594,6 +10793,7 @@ var createSwapExecuteXcm = /*#__PURE__*/function () {
10594
10793
  originFee: hasSeparateFeeAsset ? ethBridgeFee : 0n,
10595
10794
  reserveFee: originReserveFee
10596
10795
  },
10796
+ forceBuyExecution: true,
10597
10797
  suffixXcm: [].concat(_toConsumableArray(exchangeInstructions), _toConsumableArray(exchangeToDestXcm))
10598
10798
  }) : [].concat(_toConsumableArray(exchangeInstructions), _toConsumableArray(exchangeToDestXcm));
10599
10799
  fullXcm = [].concat(_toConsumableArray(prefix), _toConsumableArray(finalXcm));
@@ -10771,6 +10971,7 @@ var handleSwapExecuteTransfer = /*#__PURE__*/function () {
10771
10971
  while (1) switch (_context3.n) {
10772
10972
  case 0:
10773
10973
  api = options.api, chain = options.chain, exchangeChain = options.exchangeChain, destChain = options.destChain, assetFrom = options.assetInfoFrom, assetTo = options.assetInfoTo, currencyTo = options.currencyTo, feeAssetInfo = options.feeAssetInfo, sender = options.sender, recipient = options.recipient, calculateMinAmountOut = options.calculateMinAmountOut;
10974
+ assertCurrencyCore(currencyTo);
10774
10975
  _context3.n = 1;
10775
10976
  return api.init(chain !== null && chain !== void 0 ? chain : exchangeChain);
10776
10977
  case 1:
@@ -11053,6 +11254,7 @@ var transferPolkadotXcm = /*#__PURE__*/function () {
11053
11254
  version,
11054
11255
  methodOverride,
11055
11256
  paraIdTo,
11257
+ noFeeAsset,
11056
11258
  resolvedMultiAssets,
11057
11259
  destLocation,
11058
11260
  feeAssetIndex,
@@ -11069,10 +11271,11 @@ var transferPolkadotXcm = /*#__PURE__*/function () {
11069
11271
  _context.n = 2;
11070
11272
  break;
11071
11273
  }
11274
+ noFeeAsset = !(_typeof(destination) !== 'object' && isExternalChain(destination));
11072
11275
  _t = api;
11073
11276
  _context.n = 1;
11074
11277
  return createTypeAndThenCall(options, {
11075
- noFeeAsset: true
11278
+ noFeeAsset: noFeeAsset
11076
11279
  });
11077
11280
  case 1:
11078
11281
  return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
@@ -11642,122 +11845,6 @@ var Chain = /*#__PURE__*/function () {
11642
11845
  }
11643
11846
  });
11644
11847
  }
11645
- }, {
11646
- key: "transferToEthereum",
11647
- value: function () {
11648
- var _transferToEthereum = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(input) {
11649
- var _feeAsset$location;
11650
- var useOnlyDepositInstruction,
11651
- api,
11652
- asset,
11653
- version,
11654
- sender,
11655
- recipient,
11656
- feeAsset,
11657
- bridgeStatus,
11658
- ethAsset,
11659
- ahApi,
11660
- _yield$getParaEthTran,
11661
- _yield$getParaEthTran2,
11662
- bridgeFee,
11663
- executionFee,
11664
- PARA_TO_PARA_FEE_DOT,
11665
- fee,
11666
- ethAssetInfo,
11667
- systemAssetInfo,
11668
- shouldIncludeFeeAsset,
11669
- customXcmOnDest,
11670
- messageId,
11671
- hopDestination,
11672
- call,
11673
- _args3 = arguments;
11674
- return _regenerator().w(function (_context3) {
11675
- while (1) switch (_context3.n) {
11676
- case 0:
11677
- useOnlyDepositInstruction = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : false;
11678
- api = input.api, asset = input.assetInfo, version = input.version, sender = input.sender, recipient = input.recipient, feeAsset = input.feeAssetInfo;
11679
- _context3.n = 1;
11680
- return getBridgeStatus(api.clone());
11681
- case 1:
11682
- bridgeStatus = _context3.v;
11683
- if (!(bridgeStatus !== 'Normal')) {
11684
- _context3.n = 2;
11685
- break;
11686
- }
11687
- throw new BridgeHaltedError();
11688
- case 2:
11689
- assertAddressIsString(recipient);
11690
- assertSender(sender);
11691
- ethAsset = createAsset(version, asset.amount, asset.location);
11692
- _context3.n = 3;
11693
- return api.createApiForChain('AssetHubPolkadot');
11694
- case 3:
11695
- ahApi = _context3.v;
11696
- _context3.n = 4;
11697
- return getParaEthTransferFees(ahApi);
11698
- case 4:
11699
- _yield$getParaEthTran = _context3.v;
11700
- _yield$getParaEthTran2 = _slicedToArray(_yield$getParaEthTran, 2);
11701
- bridgeFee = _yield$getParaEthTran2[0];
11702
- executionFee = _yield$getParaEthTran2[1];
11703
- PARA_TO_PARA_FEE_DOT = 5000000000n; // 0.5 DOT
11704
- fee = useOnlyDepositInstruction ? PARA_TO_PARA_FEE_DOT : bridgeFee + executionFee;
11705
- ethAssetInfo = findAssetInfoOrThrow('Ethereum', {
11706
- symbol: asset.symbol
11707
- });
11708
- systemAssetInfo = findNativeAssetInfoOrThrow(getRelayChainOf(this.chain));
11709
- shouldIncludeFeeAsset = feeAsset && !isAssetEqual(feeAsset, asset) || !isAssetEqual(asset, systemAssetInfo);
11710
- if (!useOnlyDepositInstruction) {
11711
- _context3.n = 5;
11712
- break;
11713
- }
11714
- customXcmOnDest = addXcmVersionHeader([{
11715
- DepositAsset: {
11716
- assets: {
11717
- Wild: {
11718
- AllCounted: 2
11719
- }
11720
- },
11721
- beneficiary: createBeneficiaryLocation({
11722
- api: api,
11723
- address: recipient,
11724
- version: version
11725
- })
11726
- }
11727
- }], version);
11728
- _context3.n = 7;
11729
- break;
11730
- case 5:
11731
- assertHasId(ethAssetInfo);
11732
- _context3.n = 6;
11733
- return generateMessageId(api, sender, getParaId(this.chain), ethAssetInfo.assetId, recipient, asset.amount);
11734
- case 6:
11735
- messageId = _context3.v;
11736
- customXcmOnDest = createCustomXcmOnDest(input, this.chain, messageId, ethAssetInfo);
11737
- case 7:
11738
- hopDestination = 'AssetHubPolkadot';
11739
- call = {
11740
- module: 'PolkadotXcm',
11741
- method: 'transfer_assets_using_type_and_then',
11742
- params: {
11743
- dest: createVersionedDestination(version, this.chain, hopDestination, getParaId(hopDestination)),
11744
- assets: addXcmVersionHeader([].concat(_toConsumableArray(shouldIncludeFeeAsset ? [createAsset(version, fee, DOT_LOCATION)] : []), [ethAsset]), version),
11745
- assets_transfer_type: 'DestinationReserve',
11746
- remote_fees_id: addXcmVersionHeader((_feeAsset$location = feeAsset === null || feeAsset === void 0 ? void 0 : feeAsset.location) !== null && _feeAsset$location !== void 0 ? _feeAsset$location : shouldIncludeFeeAsset ? DOT_LOCATION : asset.location, version),
11747
- fees_transfer_type: 'DestinationReserve',
11748
- custom_xcm_on_dest: customXcmOnDest,
11749
- weight_limit: 'Unlimited'
11750
- }
11751
- };
11752
- return _context3.a(2, api.deserializeExtrinsics(call));
11753
- }
11754
- }, _callee3, this);
11755
- }));
11756
- function transferToEthereum(_x3) {
11757
- return _transferToEthereum.apply(this, arguments);
11758
- }
11759
- return transferToEthereum;
11760
- }()
11761
11848
  }, {
11762
11849
  key: "getBalanceNative",
11763
11850
  value: function getBalanceNative(api, address, asset) {
@@ -11772,60 +11859,60 @@ var Chain = /*#__PURE__*/function () {
11772
11859
  }, {
11773
11860
  key: "getBalanceForeign",
11774
11861
  value: function () {
11775
- var _getBalanceForeign = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(api, address, asset) {
11862
+ var _getBalanceForeign = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(api, address, asset) {
11776
11863
  var pallets, lastError, customCurrencyId, _iterator, _step, pallet, instance, _t2, _t3;
11777
- return _regenerator().w(function (_context4) {
11778
- while (1) switch (_context4.p = _context4.n) {
11864
+ return _regenerator().w(function (_context3) {
11865
+ while (1) switch (_context3.p = _context3.n) {
11779
11866
  case 0:
11780
11867
  pallets = getOtherAssetsPallets(this.chain);
11781
11868
  if (!(pallets.length === 0)) {
11782
- _context4.n = 1;
11869
+ _context3.n = 1;
11783
11870
  break;
11784
11871
  }
11785
11872
  throw new RoutingResolutionError("No foreign asset pallets found for ".concat(this.chain));
11786
11873
  case 1:
11787
11874
  customCurrencyId = this.getCustomCurrencyId(asset);
11788
11875
  _iterator = _createForOfIteratorHelper(pallets);
11789
- _context4.p = 2;
11876
+ _context3.p = 2;
11790
11877
  _iterator.s();
11791
11878
  case 3:
11792
11879
  if ((_step = _iterator.n()).done) {
11793
- _context4.n = 8;
11880
+ _context3.n = 8;
11794
11881
  break;
11795
11882
  }
11796
11883
  pallet = _step.value;
11797
11884
  instance = getPalletInstance(pallet);
11798
- _context4.p = 4;
11799
- _context4.n = 5;
11885
+ _context3.p = 4;
11886
+ _context3.n = 5;
11800
11887
  return instance.getBalance(api, address, asset, customCurrencyId);
11801
11888
  case 5:
11802
- return _context4.a(2, _context4.v);
11889
+ return _context3.a(2, _context3.v);
11803
11890
  case 6:
11804
- _context4.p = 6;
11805
- _t2 = _context4.v;
11891
+ _context3.p = 6;
11892
+ _t2 = _context3.v;
11806
11893
  lastError = _t2;
11807
11894
  case 7:
11808
- _context4.n = 3;
11895
+ _context3.n = 3;
11809
11896
  break;
11810
11897
  case 8:
11811
- _context4.n = 10;
11898
+ _context3.n = 10;
11812
11899
  break;
11813
11900
  case 9:
11814
- _context4.p = 9;
11815
- _t3 = _context4.v;
11901
+ _context3.p = 9;
11902
+ _t3 = _context3.v;
11816
11903
  _iterator.e(_t3);
11817
11904
  case 10:
11818
- _context4.p = 10;
11905
+ _context3.p = 10;
11819
11906
  _iterator.f();
11820
- return _context4.f(10);
11907
+ return _context3.f(10);
11821
11908
  case 11:
11822
11909
  throw lastError;
11823
11910
  case 12:
11824
- return _context4.a(2);
11911
+ return _context3.a(2);
11825
11912
  }
11826
- }, _callee4, this, [[4, 6], [2, 9, 10, 11]]);
11913
+ }, _callee3, this, [[4, 6], [2, 9, 10, 11]]);
11827
11914
  }));
11828
- function getBalanceForeign(_x4, _x5, _x6) {
11915
+ function getBalanceForeign(_x3, _x4, _x5) {
11829
11916
  return _getBalanceForeign.apply(this, arguments);
11830
11917
  }
11831
11918
  return getBalanceForeign;
@@ -12053,99 +12140,47 @@ var AssetHubPolkadot = /*#__PURE__*/function (_Chain) {
12053
12140
  }
12054
12141
  _inherits(AssetHubPolkadot, _Chain);
12055
12142
  return _createClass(AssetHubPolkadot, [{
12056
- key: "handleEthBridgeNativeTransfer",
12057
- value: function () {
12058
- var _handleEthBridgeNativeTransfer = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(input) {
12059
- var api, version, destination, sender, recipient, paraIdTo, asset, messageId, location, call;
12060
- return _regenerator().w(function (_context) {
12061
- while (1) switch (_context.n) {
12062
- case 0:
12063
- api = input.api, version = input.version, destination = input.destination, sender = input.sender, recipient = input.recipient, paraIdTo = input.paraIdTo, asset = input.assetInfo;
12064
- assertSender(sender);
12065
- _context.n = 1;
12066
- return generateMessageId(api, sender, getParaId(this.chain), JSON.stringify(asset.location), JSON.stringify(recipient), asset.amount);
12067
- case 1:
12068
- messageId = _context.v;
12069
- location = asset.symbol === this.getNativeAssetSymbol() ? DOT_LOCATION : asset.location;
12070
- call = {
12071
- module: 'PolkadotXcm',
12072
- method: 'transfer_assets_using_type_and_then',
12073
- params: {
12074
- dest: createVersionedDestination(this.version, this.chain, destination, paraIdTo, getEthereumJunction(this.chain), Parents.TWO),
12075
- assets: addXcmVersionHeader([createAsset(version, asset.amount, location)], version),
12076
- assets_transfer_type: 'LocalReserve',
12077
- remote_fees_id: addXcmVersionHeader(location, version),
12078
- fees_transfer_type: 'LocalReserve',
12079
- custom_xcm_on_dest: addXcmVersionHeader([{
12080
- DepositAsset: {
12081
- assets: {
12082
- Wild: {
12083
- AllCounted: 1
12084
- }
12085
- },
12086
- beneficiary: createBeneficiaryLocation({
12087
- api: api,
12088
- address: recipient,
12089
- version: version
12090
- })
12091
- }
12092
- }, {
12093
- SetTopic: messageId
12094
- }], version),
12095
- weight_limit: 'Unlimited'
12096
- }
12097
- };
12098
- return _context.a(2, api.deserializeExtrinsics(call));
12099
- }
12100
- }, _callee, this);
12101
- }));
12102
- function handleEthBridgeNativeTransfer(_x) {
12103
- return _handleEthBridgeNativeTransfer.apply(this, arguments);
12104
- }
12105
- return handleEthBridgeNativeTransfer;
12106
- }()
12107
- }, {
12108
12143
  key: "transferPolkadotXCM",
12109
12144
  value: function () {
12110
- var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(options) {
12145
+ var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
12111
12146
  var api, assetInfo, feeAssetInfo, overriddenAsset, isNativeAsset, isNativeFeeAsset, _t;
12112
- return _regenerator().w(function (_context2) {
12113
- while (1) switch (_context2.n) {
12147
+ return _regenerator().w(function (_context) {
12148
+ while (1) switch (_context.n) {
12114
12149
  case 0:
12115
12150
  api = options.api, assetInfo = options.assetInfo, feeAssetInfo = options.feeAssetInfo, overriddenAsset = options.overriddenAsset;
12116
12151
  if (!feeAssetInfo) {
12117
- _context2.n = 4;
12152
+ _context.n = 4;
12118
12153
  break;
12119
12154
  }
12120
12155
  if (!overriddenAsset) {
12121
- _context2.n = 1;
12156
+ _context.n = 1;
12122
12157
  break;
12123
12158
  }
12124
12159
  throw new InvalidCurrencyError('Cannot use overridden multi-assets with XCM execute');
12125
12160
  case 1:
12126
12161
  if (!isSymbolMatch(assetInfo.symbol, 'KSM')) {
12127
- _context2.n = 2;
12162
+ _context.n = 2;
12128
12163
  break;
12129
12164
  }
12130
- return _context2.a(2, transferPolkadotXcm(options));
12165
+ return _context.a(2, transferPolkadotXcm(options));
12131
12166
  case 2:
12132
12167
  isNativeAsset = isSymbolMatch(assetInfo.symbol, this.getNativeAssetSymbol());
12133
12168
  isNativeFeeAsset = isSymbolMatch(feeAssetInfo.symbol, this.getNativeAssetSymbol());
12134
12169
  if (!(!isNativeAsset || !isNativeFeeAsset)) {
12135
- _context2.n = 4;
12170
+ _context.n = 4;
12136
12171
  break;
12137
12172
  }
12138
12173
  _t = api;
12139
- _context2.n = 3;
12174
+ _context.n = 3;
12140
12175
  return handleExecuteTransfer(options);
12141
12176
  case 3:
12142
- return _context2.a(2, _t.deserializeExtrinsics.call(_t, _context2.v));
12177
+ return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
12143
12178
  case 4:
12144
- return _context2.a(2, transferPolkadotXcm(options));
12179
+ return _context.a(2, transferPolkadotXcm(options));
12145
12180
  }
12146
- }, _callee2, this);
12181
+ }, _callee, this);
12147
12182
  }));
12148
- function transferPolkadotXCM(_x2) {
12183
+ function transferPolkadotXCM(_x) {
12149
12184
  return _transferPolkadotXCM.apply(this, arguments);
12150
12185
  }
12151
12186
  return transferPolkadotXCM;
@@ -12316,40 +12351,34 @@ var Hydration = /*#__PURE__*/function (_Chain) {
12316
12351
  while (1) switch (_context.n) {
12317
12352
  case 0:
12318
12353
  destination = input.destination, asset = input.assetInfo, feeAsset = input.feeAssetInfo, overriddenAsset = input.overriddenAsset, api = input.api;
12319
- if (!(destination === 'Ethereum')) {
12320
- _context.n = 1;
12321
- break;
12322
- }
12323
- return _context.a(2, this.transferToEthereum(input));
12324
- case 1:
12325
12354
  if (!feeAsset) {
12326
- _context.n = 4;
12355
+ _context.n = 3;
12327
12356
  break;
12328
12357
  }
12329
12358
  if (!overriddenAsset) {
12330
- _context.n = 2;
12359
+ _context.n = 1;
12331
12360
  break;
12332
12361
  }
12333
12362
  throw new InvalidCurrencyError('Cannot use overridden assets with XCM execute');
12334
- case 2:
12363
+ case 1:
12335
12364
  isNativeAsset = isSymbolMatch(asset.symbol, this.getNativeAssetSymbol());
12336
12365
  isNativeFeeAsset = isSymbolMatch(feeAsset.symbol, this.getNativeAssetSymbol());
12337
12366
  if (!(!isNativeAsset || !isNativeFeeAsset)) {
12338
- _context.n = 4;
12367
+ _context.n = 3;
12339
12368
  break;
12340
12369
  }
12341
12370
  _t = api;
12342
- _context.n = 3;
12371
+ _context.n = 2;
12343
12372
  return handleExecuteTransfer(input);
12344
- case 3:
12373
+ case 2:
12345
12374
  return _context.a(2, _t.deserializeExtrinsics.call(_t, _context.v));
12346
- case 4:
12375
+ case 3:
12347
12376
  if (!(isMoonbeamWhAsset(asset.location) && destination === 'Moonbeam')) {
12348
- _context.n = 5;
12377
+ _context.n = 4;
12349
12378
  break;
12350
12379
  }
12351
12380
  return _context.a(2, this.transferMoonbeamWhAsset(input));
12352
- case 5:
12381
+ case 4:
12353
12382
  return _context.a(2, transferPolkadotXcm(input));
12354
12383
  }
12355
12384
  }, _callee, this);
@@ -12492,10 +12521,6 @@ var BifrostPolkadot = /*#__PURE__*/function (_Chain) {
12492
12521
  }, {
12493
12522
  key: "transferPolkadotXCM",
12494
12523
  value: function transferPolkadotXCM(options) {
12495
- var destination = options.destination;
12496
- if (destination === 'Ethereum') {
12497
- return this.transferToEthereum(options);
12498
- }
12499
12524
  return transferPolkadotXcm(options);
12500
12525
  }
12501
12526
  }, {
@@ -13343,28 +13368,9 @@ var Moonbeam = /*#__PURE__*/function (_Chain) {
13343
13368
  _inherits(Moonbeam, _Chain);
13344
13369
  return _createClass(Moonbeam, [{
13345
13370
  key: "transferPolkadotXCM",
13346
- value: function () {
13347
- var _transferPolkadotXCM = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
13348
- var destination;
13349
- return _regenerator().w(function (_context) {
13350
- while (1) switch (_context.n) {
13351
- case 0:
13352
- destination = options.destination;
13353
- if (!(destination === 'Ethereum')) {
13354
- _context.n = 1;
13355
- break;
13356
- }
13357
- return _context.a(2, this.transferToEthereum(options));
13358
- case 1:
13359
- return _context.a(2, transferPolkadotXcm(options));
13360
- }
13361
- }, _callee, this);
13362
- }));
13363
- function transferPolkadotXCM(_x) {
13364
- return _transferPolkadotXCM.apply(this, arguments);
13365
- }
13366
- return transferPolkadotXCM;
13367
- }()
13371
+ value: function transferPolkadotXCM(options) {
13372
+ return transferPolkadotXcm(options);
13373
+ }
13368
13374
  }, {
13369
13375
  key: "transferLocalNonNativeAsset",
13370
13376
  value: function transferLocalNonNativeAsset(_options) {
@@ -14107,6 +14113,8 @@ var MAX_WEIGHT = {
14107
14113
  refTime: MAX_U64
14108
14114
  };
14109
14115
  var BYPASS_MINT_AMOUNT = '1000';
14116
+ var HIGH_BYPASS_MINT_AMOUNT = '10000';
14117
+ var HIGH_BYPASS_MINT_CHAINS = ['Mythos'];
14110
14118
  var MIN_AMOUNT = 2n;
14111
14119
  var AMOUNT_ALL = 'ALL';
14112
14120
  var TRANSACT_ORIGINS = ['Native', 'SovereignAccount', 'Superuser', 'Xcm'];
@@ -14375,4 +14383,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
14375
14383
  };
14376
14384
  };
14377
14385
 
14378
- export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, applyDecimalAbstraction, assertAddressIsString, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
14386
+ export { API_TYPES, AmountTooLowError, ApiNotInitializedError, AssetClaimBuilder, BaseAssetsPallet, BatchMode, BatchValidationError, BridgeHaltedError, Builder, DEFAULT_TTL_MS, DRY_RUN_CLIENT_TIMEOUT_MS, DryRunFailedError, ETH_MAINNET_CHAIN_ID, ETH_TESTNET_CHAIN_ID, EXCHANGE_CHAINS, EXTENSION_MS, ExtensionNotInstalledError, FeatureTemporarilyDisabledError, GeneralBuilder, InvalidAddressError, MAX_CLIENTS, MissingChainApiError, MissingParameterError, NoXCMSupportImplementedError, NumberFormatError, OverrideConflictError, PolkadotApi, PolkadotXcmError, PolkadotXcmExecutionError, ProviderUnavailableError, RELAY_LOCATION, RoutingResolutionError, RuntimeApiError, RuntimeApiUnavailableError, ScenarioNotSupportedError, SubmitTransactionError, TRANSACT_ORIGINS, TX_CLIENT_TIMEOUT_MS, TransferToAhNotSupported, TypeAndThenUnavailableError, UnableToComputeError, UnsupportedOperationError, ValidationError, XTokensError, abstractDecimals, addEthereumBridgeFees, addXcmVersionHeader, aggregateHopFees, applyDecimalAbstraction, assertAddressIsString, assertCurrencyCore, assertEvmAddress, assertExtensionInstalled, assertHasId, assertNotEvmTransfer, assertSender, assertSenderSource, assertSubstrateOrigin, assertSwapSupport, assertToIsString, blake2b256, blake2b512, buildDestInfo, buildHopInfo, buildOriginInfo, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createCustomXcmOnDest, createDestination, createDirectExecuteXcm, createEthereumBridgeInstructions, createExecuteCall, createExecuteExchangeXcm, createSwapBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithSwap, formatAssetIdToERC20, formatUnits, generateMessageId, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmExtensionOrThrow, getEvmPrivateKeyHex, getEvmSnowbridgeExtensionOrThrow, getFailureInfo$1 as getFailureInfo, getLocalTransferAmount, getMinTransferableAmount, getMinTransferableAmountInternal, getMoonbeamErc20Balance, getOriginXcmFee, getOriginXcmFeeInternal, getParaEthTransferFees, getParaId, getRelayChainOf, getSwapExtensionOrThrow, getTChain, getTransferInfo, getTransferableAmount, getTransferableAmountInternal, getXcmFee, getXcmFeeInternal, getXcmFeeOnce, handleExecuteTransfer, handleSwapExecuteTransfer, handleToAhTeleport, isConfig, isSenderSigner, isViemSigner, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerEvmExtension, registerEvmSnowbridgeExtension, registerSwapExtension, resolveAssetCount, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };