@paraspell/sdk-core 13.2.2 → 13.3.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 (4) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +1041 -1032
  3. package/dist/index.mjs +322 -109
  4. package/package.json +6 -15
package/dist/index.mjs CHANGED
@@ -3,7 +3,7 @@ import { isChainEvm, getAssetsObject, InvalidCurrencyError, extractAssetLocation
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, parseUnits as parseUnits$1, formatUnits as formatUnits$1 } from 'viem';
6
- import { Version, isTLocation, replaceBigInt, hasJunction, getJunctionValue, isRelayChain, deepEqual, Parents, isExternalChain, isSnowbridge, isBridge, isSubstrateBridge, PARACHAINS, RELAYCHAINS, isTrustedChain } from '@paraspell/sdk-common';
6
+ import { Version, isTLocation, replaceBigInt, isExternalChain, hasJunction, getJunctionValue, isRelayChain, deepEqual, Parents, 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';
@@ -1060,7 +1060,7 @@ var createTransactInstructions = /*#__PURE__*/function () {
1060
1060
  return _context3.a(2, [{
1061
1061
  Transact: _defineProperty(_defineProperty({
1062
1062
  origin_kind: originKind !== null && originKind !== void 0 ? originKind : 'SovereignAccount'
1063
- }, weightKey, convertWeight(weight)), "call", call)
1063
+ }, weightKey, convertWeight(weight)), "call", typeof call === 'string' ? api.encodeTx(call) : call)
1064
1064
  }, {
1065
1065
  ExpectTransactStatus: {
1066
1066
  Success: undefined
@@ -1112,6 +1112,17 @@ var validateDestinationAddress = function validateDestinationAddress(address, de
1112
1112
  }
1113
1113
  };
1114
1114
 
1115
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1116
+ var isConfig = function isConfig(value) {
1117
+ return _typeof(value) === 'object' && value !== null && !Array.isArray(value) && (
1118
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
1119
+ Object.keys(value).length < 3 || 'apiOverrides' in value || 'development' in value || 'abstractDecimals' in value || 'xcmFormatCheck' in value);
1120
+ };
1121
+
1122
+ var isViemSigner = function isViemSigner(value) {
1123
+ return _typeof(value) === 'object' && value !== null && 'sendTransaction' in value && 'account' in value;
1124
+ };
1125
+
1115
1126
  var assertToIsString = function assertToIsString(to, overrideMsg) {
1116
1127
  if (isTLocation(to)) {
1117
1128
  throw new InvalidAddressError(overrideMsg !== null && overrideMsg !== void 0 ? overrideMsg : 'Location destination is not supported for XCM fee calculation.');
@@ -1145,6 +1156,25 @@ var assertSwapSupport = function assertSwapSupport(options) {
1145
1156
  throw new UnsupportedOperationError('Swap options are not supported by this operation. Please open an issue if you would like to see this supported.');
1146
1157
  }
1147
1158
  };
1159
+ var evmTransferUnsupportedMessage = function evmTransferUnsupportedMessage(origin) {
1160
+ return "This operation is not supported for EVM transfers (origin '".concat(origin, "'). Call .signAndSubmit() with your viem WalletClient instead.");
1161
+ };
1162
+ var assertSubstrateOrigin = function assertSubstrateOrigin(chain) {
1163
+ if (isExternalChain(chain)) {
1164
+ throw new UnsupportedOperationError(evmTransferUnsupportedMessage(chain));
1165
+ }
1166
+ };
1167
+ var assertNotEvmTransfer = function assertNotEvmTransfer(from, senderSource) {
1168
+ assertSubstrateOrigin(from);
1169
+ if (isViemSigner(senderSource)) {
1170
+ throw new UnsupportedOperationError(evmTransferUnsupportedMessage(from));
1171
+ }
1172
+ };
1173
+ var assertExtensionInstalled = function assertExtensionInstalled(extension, extensionName, packageName, usage) {
1174
+ if (!extension) {
1175
+ throw new ExtensionNotInstalledError("The ".concat(extensionName, " extension is not registered. Please install ").concat(packageName, " and import it before ").concat(usage, "."));
1176
+ }
1177
+ };
1148
1178
 
1149
1179
  var getAssetReserveChain = function getAssetReserveChain(chain, assetLocation) {
1150
1180
  var hasGlobalConsensusJunction = hasJunction(assetLocation, 'GlobalConsensus');
@@ -2806,9 +2836,8 @@ var configs = {
2806
2836
  Paseo: Paseo$1
2807
2837
  };
2808
2838
 
2809
- var configsMap = configs;
2810
2839
  var getChainConfig = function getChainConfig(chain) {
2811
- return configsMap[chain];
2840
+ return configs[chain];
2812
2841
  };
2813
2842
 
2814
2843
  var getChainProviders = function getChainProviders(chain) {
@@ -3246,7 +3275,7 @@ var padValueBy = function padValueBy(amount, percent) {
3246
3275
 
3247
3276
  var getMythosOriginFee = /*#__PURE__*/function () {
3248
3277
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api) {
3249
- var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, nativeAsset, feeConverted;
3278
+ var ahApi, _yield$getParaEthTran, _yield$getParaEthTran2, bridgeFee, ahExecutionFee, nativeAsset, feeConvertedRes, feeConverted;
3250
3279
  return _regenerator().w(function (_context) {
3251
3280
  while (1) switch (_context.n) {
3252
3281
  case 0:
@@ -3263,9 +3292,14 @@ var getMythosOriginFee = /*#__PURE__*/function () {
3263
3292
  ahExecutionFee = _yield$getParaEthTran2[1];
3264
3293
  nativeAsset = findNativeAssetInfoOrThrow('Mythos');
3265
3294
  _context.n = 3;
3266
- return ahApi.quoteAhPrice(DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee);
3295
+ return ahApi.queryRuntimeApi({
3296
+ module: 'AssetConversionApi',
3297
+ method: 'quote_price_exact_tokens_for_tokens',
3298
+ params: [DOT_LOCATION, nativeAsset.location, bridgeFee + ahExecutionFee, true]
3299
+ });
3267
3300
  case 3:
3268
- feeConverted = _context.v;
3301
+ feeConvertedRes = _context.v;
3302
+ feeConverted = feeConvertedRes != null ? BigInt(feeConvertedRes) : undefined;
3269
3303
  _context.n = 4;
3270
3304
  return ahApi.disconnect();
3271
3305
  case 4:
@@ -3375,11 +3409,17 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
3375
3409
  case 0:
3376
3410
  sender = this._options.senderSource;
3377
3411
  assertSenderSource(sender);
3378
- _context.n = 1;
3412
+ if (!isViemSigner(sender)) {
3413
+ _context.n = 1;
3414
+ break;
3415
+ }
3416
+ throw new UnsupportedOperationError('Asset claim with a viem WalletClient signer is not supported.');
3417
+ case 1:
3418
+ _context.n = 2;
3379
3419
  return claimAssets(_objectSpread2({
3380
3420
  api: this.api
3381
3421
  }, this._options));
3382
- case 1:
3422
+ case 2:
3383
3423
  tx = _context.v;
3384
3424
  return _context.a(2, this.api.signAndSubmit(tx, sender));
3385
3425
  }
@@ -3413,6 +3453,33 @@ var AssetClaimBuilder = /*#__PURE__*/function () {
3413
3453
  }]);
3414
3454
  }();
3415
3455
 
3456
+ var evmExtension;
3457
+ var registerEvmExtension = function registerEvmExtension(extension) {
3458
+ evmExtension = extension;
3459
+ };
3460
+ var getEvmExtensionOrThrow = function getEvmExtensionOrThrow() {
3461
+ assertExtensionInstalled(evmExtension, 'EVM', '@paraspell/evm', 'using an EVM origin');
3462
+ return evmExtension;
3463
+ };
3464
+
3465
+ var evmSnowbridgeExtension;
3466
+ var registerEvmSnowbridgeExtension = function registerEvmSnowbridgeExtension(extension) {
3467
+ evmSnowbridgeExtension = extension;
3468
+ };
3469
+ var getEvmSnowbridgeExtensionOrThrow = function getEvmSnowbridgeExtensionOrThrow() {
3470
+ assertExtensionInstalled(evmSnowbridgeExtension, 'EVM Snowbridge', '@paraspell/evm-snowbridge', 'using Ethereum as an origin');
3471
+ return evmSnowbridgeExtension;
3472
+ };
3473
+
3474
+ var swapExtension;
3475
+ var registerSwapExtension = function registerSwapExtension(extension) {
3476
+ swapExtension = extension;
3477
+ };
3478
+ var getSwapExtensionOrThrow = function getSwapExtensionOrThrow() {
3479
+ assertExtensionInstalled(swapExtension, 'swap', '@paraspell/swap', 'using swap features');
3480
+ return swapExtension;
3481
+ };
3482
+
3416
3483
  var API_TYPES = ['PAPI', 'PJS', 'DEDOT'];
3417
3484
 
3418
3485
  var BaseAssetsPallet = /*#__PURE__*/_createClass(function BaseAssetsPallet(palletName) {
@@ -3538,11 +3605,11 @@ var PolkadotXcmExecutionError;
3538
3605
 
3539
3606
  var normalizeAmountAll = /*#__PURE__*/function () {
3540
3607
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(api, builder, options) {
3541
- var currency, swapOptions, isAmountAll, builderWithMinAmount, buildTx, transferable, finalBuildTx, _t;
3608
+ var currency, swapOptions, from, isAmountAll, builderWithMinAmount, buildTx, transferable, finalBuildTx, _t;
3542
3609
  return _regenerator().w(function (_context) {
3543
3610
  while (1) switch (_context.n) {
3544
3611
  case 0:
3545
- currency = options.currency, swapOptions = options.swapOptions;
3612
+ currency = options.currency, swapOptions = options.swapOptions, from = options.from;
3546
3613
  isAmountAll = !Array.isArray(currency) && currency.amount === AMOUNT_ALL;
3547
3614
  if (isAmountAll) {
3548
3615
  _context.n = 1;
@@ -3556,6 +3623,7 @@ var normalizeAmountAll = /*#__PURE__*/function () {
3556
3623
  buildTx: builder['createTxFactory']()
3557
3624
  });
3558
3625
  case 1:
3626
+ assertSubstrateOrigin(from);
3559
3627
  builderWithMinAmount = builder.currency(_objectSpread2(_objectSpread2({}, options.currency), {}, {
3560
3628
  amount: MIN_AMOUNT
3561
3629
  }));
@@ -3567,8 +3635,9 @@ var normalizeAmountAll = /*#__PURE__*/function () {
3567
3635
  break;
3568
3636
  }
3569
3637
  _context.n = 2;
3570
- return executeWithRouter(_objectSpread2(_objectSpread2({}, options), {}, {
3638
+ return executeWithSwap(_objectSpread2(_objectSpread2({}, options), {}, {
3571
3639
  api: api,
3640
+ from: from,
3572
3641
  swapOptions: swapOptions
3573
3642
  }), function (builder) {
3574
3643
  return builder.getTransferableAmount();
@@ -3582,7 +3651,7 @@ var normalizeAmountAll = /*#__PURE__*/function () {
3582
3651
  return getTransferableAmountInternal({
3583
3652
  api: api,
3584
3653
  buildTx: buildTx,
3585
- origin: options.from,
3654
+ origin: from,
3586
3655
  destination: options.to,
3587
3656
  sender: options.sender,
3588
3657
  feeAsset: options.feeAsset,
@@ -3687,7 +3756,11 @@ var BatchTransactionManager = /*#__PURE__*/function () {
3687
3756
  _context2.n = 5;
3688
3757
  return Promise.all(normalized.map(function (_ref2) {
3689
3758
  var options = _ref2.options;
3690
- return createTransferOrSwap(options);
3759
+ var origin = options.from;
3760
+ assertSubstrateOrigin(origin);
3761
+ return createTransferOrSwap(_objectSpread2(_objectSpread2({}, options), {}, {
3762
+ from: origin
3763
+ }));
3691
3764
  }));
3692
3765
  case 5:
3693
3766
  txs = _context2.v;
@@ -3810,14 +3883,25 @@ var GeneralBuilder = /*#__PURE__*/function () {
3810
3883
  }));
3811
3884
  }
3812
3885
  /**
3813
- * Sets the sender address.
3886
+ * Sets the sender address or signer.
3814
3887
  *
3815
- * @param sender - The sender address or signer.
3888
+ * @param sender - The sender address, substrate signer, or viem `WalletClient`.
3816
3889
  * @returns An instance of Builder
3817
3890
  */
3818
3891
  }, {
3819
3892
  key: "sender",
3820
3893
  value: function sender(_sender) {
3894
+ if (isViemSigner(_sender)) {
3895
+ var _sender$account;
3896
+ var _address = (_sender$account = _sender.account) === null || _sender$account === void 0 ? void 0 : _sender$account.address;
3897
+ if (!_address) {
3898
+ throw new InvalidAddressError('viem WalletClient has no account attached. Create it with a specific account.');
3899
+ }
3900
+ return new GeneralBuilder(this.api, this.batchManager, _objectSpread2(_objectSpread2({}, this._options), {}, {
3901
+ sender: _address,
3902
+ senderSource: _sender
3903
+ }));
3904
+ }
3821
3905
  var isPath = typeof _sender === 'string' && _sender.startsWith('//');
3822
3906
  var isPathOrSigner = isPath || isSenderSigner(_sender);
3823
3907
  var address = isPathOrSigner ? this.api.deriveAddress(_sender) : _sender;
@@ -3935,14 +4019,19 @@ var GeneralBuilder = /*#__PURE__*/function () {
3935
4019
  }, {
3936
4020
  key: "addToBatch",
3937
4021
  value: function addToBatch() {
4022
+ var _this$_options = this._options,
4023
+ from = _this$_options.from,
4024
+ senderSource = _this$_options.senderSource;
4025
+ assertNotEvmTransfer(from, senderSource);
3938
4026
  this.batchManager.addTransaction(_objectSpread2(_objectSpread2({
3939
4027
  api: this.api
3940
4028
  }, this._options), {}, {
4029
+ from: from,
3941
4030
  builder: this
3942
4031
  }));
3943
- return new GeneralBuilder(this.api, this.batchManager, {
3944
- from: this._options.from
3945
- });
4032
+ return new GeneralBuilder(this.api, this.batchManager, _objectSpread2(_objectSpread2({}, this._options), {}, {
4033
+ from: from
4034
+ }));
3946
4035
  }
3947
4036
  /**
3948
4037
  * Builds and returns the batched transaction based on the configured parameters.
@@ -3954,10 +4043,13 @@ var GeneralBuilder = /*#__PURE__*/function () {
3954
4043
  key: "buildBatch",
3955
4044
  value: (function () {
3956
4045
  var _buildBatch = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options) {
4046
+ var _this$_options2, from, senderSource;
3957
4047
  return _regenerator().w(function (_context) {
3958
4048
  while (1) switch (_context.n) {
3959
4049
  case 0:
3960
- return _context.a(2, this.batchManager.buildBatch(this.api, this._options.from, options));
4050
+ _this$_options2 = this._options, from = _this$_options2.from, senderSource = _this$_options2.senderSource;
4051
+ assertNotEvmTransfer(from, senderSource);
4052
+ return _context.a(2, this.batchManager.buildBatch(this.api, from, options));
3961
4053
  }
3962
4054
  }, _callee, this);
3963
4055
  }));
@@ -4006,10 +4098,12 @@ var GeneralBuilder = /*#__PURE__*/function () {
4006
4098
  key: "build",
4007
4099
  value: (function () {
4008
4100
  var _build = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
4009
- var _yield$this$buildComm, tx;
4101
+ var _this$_options3, from, senderSource, _yield$this$buildComm, tx;
4010
4102
  return _regenerator().w(function (_context3) {
4011
4103
  while (1) switch (_context3.n) {
4012
4104
  case 0:
4105
+ _this$_options3 = this._options, from = _this$_options3.from, senderSource = _this$_options3.senderSource;
4106
+ assertNotEvmTransfer(from, senderSource);
4013
4107
  _context3.n = 1;
4014
4108
  return this.buildCommon();
4015
4109
  case 1:
@@ -4034,10 +4128,12 @@ var GeneralBuilder = /*#__PURE__*/function () {
4034
4128
  key: "buildAll",
4035
4129
  value: (function () {
4036
4130
  var _buildAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
4037
- var _yield$this$buildComm2, txContexts;
4131
+ var _this$_options4, from, senderSource, _yield$this$buildComm2, txContexts;
4038
4132
  return _regenerator().w(function (_context4) {
4039
4133
  while (1) switch (_context4.n) {
4040
4134
  case 0:
4135
+ _this$_options4 = this._options, from = _this$_options4.from, senderSource = _this$_options4.senderSource;
4136
+ assertNotEvmTransfer(from, senderSource);
4041
4137
  _context4.n = 1;
4042
4138
  return this.buildCommonAll();
4043
4139
  case 1:
@@ -4066,6 +4162,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
4066
4162
  var isCalledInternally,
4067
4163
  _yield$this$prepareNo,
4068
4164
  normalizedOptions,
4165
+ from,
4166
+ substrateOptions,
4069
4167
  tx,
4070
4168
  _args5 = arguments;
4071
4169
  return _regenerator().w(function (_context5) {
@@ -4078,12 +4176,17 @@ var GeneralBuilder = /*#__PURE__*/function () {
4078
4176
  case 1:
4079
4177
  _yield$this$prepareNo = _context5.v;
4080
4178
  normalizedOptions = _yield$this$prepareNo.normalizedOptions;
4179
+ from = normalizedOptions.from;
4180
+ assertSubstrateOrigin(from);
4181
+ substrateOptions = _objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4182
+ from: from
4183
+ });
4081
4184
  _context5.n = 2;
4082
- return createTransferOrSwap(normalizedOptions);
4185
+ return createTransferOrSwap(substrateOptions);
4083
4186
  case 2:
4084
4187
  tx = _context5.v;
4085
4188
  _context5.n = 3;
4086
- return this.maybePerformXcmFormatCheck(tx, normalizedOptions, isCalledInternally);
4189
+ return this.maybePerformXcmFormatCheck(tx, substrateOptions, isCalledInternally);
4087
4190
  case 3:
4088
4191
  return _context5.a(2, {
4089
4192
  tx: tx,
@@ -4104,6 +4207,8 @@ var GeneralBuilder = /*#__PURE__*/function () {
4104
4207
  var isCalledInternally,
4105
4208
  _yield$this$prepareNo2,
4106
4209
  normalizedOptions,
4210
+ from,
4211
+ substrateOptions,
4107
4212
  txContexts,
4108
4213
  _args6 = arguments;
4109
4214
  return _regenerator().w(function (_context6) {
@@ -4116,8 +4221,13 @@ var GeneralBuilder = /*#__PURE__*/function () {
4116
4221
  case 1:
4117
4222
  _yield$this$prepareNo2 = _context6.v;
4118
4223
  normalizedOptions = _yield$this$prepareNo2.normalizedOptions;
4224
+ from = normalizedOptions.from;
4225
+ assertSubstrateOrigin(from);
4226
+ substrateOptions = _objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4227
+ from: from
4228
+ });
4119
4229
  _context6.n = 2;
4120
- return createTransferOrSwapAll(normalizedOptions);
4230
+ return createTransferOrSwapAll(substrateOptions);
4121
4231
  case 2:
4122
4232
  txContexts = _context6.v;
4123
4233
  return _context6.a(2, {
@@ -4174,16 +4284,18 @@ var GeneralBuilder = /*#__PURE__*/function () {
4174
4284
  key: "dryRun",
4175
4285
  value: function () {
4176
4286
  var _dryRun = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
4177
- var swapOptions, _yield$this$buildInte, tx, options;
4287
+ var _this$_options5, from, senderSource, swapOptions, _yield$this$buildInte, tx, options;
4178
4288
  return _regenerator().w(function (_context8) {
4179
4289
  while (1) switch (_context8.n) {
4180
4290
  case 0:
4181
- swapOptions = this._options.swapOptions;
4291
+ _this$_options5 = this._options, from = _this$_options5.from, senderSource = _this$_options5.senderSource, swapOptions = _this$_options5.swapOptions;
4292
+ assertNotEvmTransfer(from, senderSource);
4182
4293
  if (!swapOptions) {
4183
4294
  _context8.n = 1;
4184
4295
  break;
4185
4296
  }
4186
- return _context8.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
4297
+ return _context8.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4298
+ from: from,
4187
4299
  api: this.api,
4188
4300
  swapOptions: swapOptions
4189
4301
  }), function (builder) {
@@ -4196,7 +4308,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
4196
4308
  _yield$this$buildInte = _context8.v;
4197
4309
  tx = _yield$this$buildInte.tx;
4198
4310
  options = _yield$this$buildInte.options;
4199
- return _context8.a(2, buildDryRun(this.api, tx, options));
4311
+ return _context8.a(2, buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
4312
+ from: from
4313
+ })));
4200
4314
  }
4201
4315
  }, _callee8, this);
4202
4316
  }));
@@ -4209,11 +4323,12 @@ var GeneralBuilder = /*#__PURE__*/function () {
4209
4323
  key: "dryRunPreview",
4210
4324
  value: function () {
4211
4325
  var _dryRunPreview = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(dryRunOptions) {
4212
- var swapOptions, _yield$this$buildInte2, tx, options;
4326
+ var _this$_options6, from, senderSource, swapOptions, _yield$this$buildInte2, tx, options;
4213
4327
  return _regenerator().w(function (_context9) {
4214
4328
  while (1) switch (_context9.n) {
4215
4329
  case 0:
4216
- swapOptions = this._options.swapOptions;
4330
+ _this$_options6 = this._options, from = _this$_options6.from, senderSource = _this$_options6.senderSource, swapOptions = _this$_options6.swapOptions;
4331
+ assertNotEvmTransfer(from, senderSource);
4217
4332
  assertSwapSupport(swapOptions);
4218
4333
  _context9.n = 1;
4219
4334
  return this.buildInternal();
@@ -4221,7 +4336,9 @@ var GeneralBuilder = /*#__PURE__*/function () {
4221
4336
  _yield$this$buildInte2 = _context9.v;
4222
4337
  tx = _yield$this$buildInte2.tx;
4223
4338
  options = _yield$this$buildInte2.options;
4224
- return _context9.a(2, buildDryRun(this.api, tx, options, {
4339
+ return _context9.a(2, buildDryRun(this.api, tx, _objectSpread2(_objectSpread2({}, options), {}, {
4340
+ from: from
4341
+ }), {
4225
4342
  sentAssetMintMode: 'preview',
4226
4343
  mintFeeAssets: dryRunOptions === null || dryRunOptions === void 0 ? void 0 : dryRunOptions.mintFeeAssets
4227
4344
  }));
@@ -4253,11 +4370,12 @@ var GeneralBuilder = /*#__PURE__*/function () {
4253
4370
  value: (function () {
4254
4371
  var _getXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
4255
4372
  var _options$disableFallb;
4256
- var disableFallback, _yield$this$prepareNo3, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4373
+ var disableFallback, senderSource, _yield$this$prepareNo3, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4257
4374
  return _regenerator().w(function (_context0) {
4258
4375
  while (1) switch (_context0.n) {
4259
4376
  case 0:
4260
4377
  disableFallback = (_options$disableFallb = options === null || options === void 0 ? void 0 : options.disableFallback) !== null && _options$disableFallb !== void 0 ? _options$disableFallb : false;
4378
+ senderSource = this._options.senderSource;
4261
4379
  _context0.n = 1;
4262
4380
  return this.prepareNormalizedOptions(this._options);
4263
4381
  case 1:
@@ -4267,11 +4385,13 @@ var GeneralBuilder = /*#__PURE__*/function () {
4267
4385
  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;
4268
4386
  assertToIsString(to);
4269
4387
  assertAddressIsString(recipient);
4388
+ assertNotEvmTransfer(from, senderSource);
4270
4389
  if (!swapOptions) {
4271
4390
  _context0.n = 2;
4272
4391
  break;
4273
4392
  }
4274
- return _context0.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4393
+ return _context0.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4394
+ from: from,
4275
4395
  swapOptions: swapOptions
4276
4396
  }), function (builder) {
4277
4397
  return builder.getXcmFees(options);
@@ -4309,6 +4429,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4309
4429
  var _getOriginXcmFee2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
4310
4430
  var _ref,
4311
4431
  disableFallback,
4432
+ senderSource,
4312
4433
  _yield$this$prepareNo4,
4313
4434
  normalizedOptions,
4314
4435
  buildTx,
@@ -4327,6 +4448,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4327
4448
  _ref = _args1.length > 0 && _args1[0] !== undefined ? _args1[0] : {
4328
4449
  disableFallback: false
4329
4450
  }, disableFallback = _ref.disableFallback;
4451
+ senderSource = this._options.senderSource;
4330
4452
  _context1.n = 1;
4331
4453
  return this.prepareNormalizedOptions(this._options);
4332
4454
  case 1:
@@ -4336,6 +4458,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4336
4458
  api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, sender = normalizedOptions.sender, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
4337
4459
  assertToIsString(to);
4338
4460
  assertSwapSupport(swapOptions);
4461
+ assertNotEvmTransfer(from, senderSource);
4339
4462
  _context1.p = 2;
4340
4463
  _context1.n = 3;
4341
4464
  return getOriginXcmFee({
@@ -4377,10 +4500,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
4377
4500
  key: "getTransferableAmount",
4378
4501
  value: (function () {
4379
4502
  var _getTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
4380
- var _yield$this$prepareNo5, normalizedOptions, buildTx, api, from, to, sender, currency, feeAsset, version, swapOptions;
4503
+ var senderSource, _yield$this$prepareNo5, normalizedOptions, buildTx, api, from, to, sender, currency, feeAsset, version, swapOptions;
4381
4504
  return _regenerator().w(function (_context10) {
4382
4505
  while (1) switch (_context10.n) {
4383
4506
  case 0:
4507
+ senderSource = this._options.senderSource;
4384
4508
  _context10.n = 1;
4385
4509
  return this.prepareNormalizedOptions(this._options);
4386
4510
  case 1:
@@ -4389,11 +4513,13 @@ var GeneralBuilder = /*#__PURE__*/function () {
4389
4513
  buildTx = _yield$this$prepareNo5.buildTx;
4390
4514
  api = normalizedOptions.api, from = normalizedOptions.from, to = normalizedOptions.to, sender = normalizedOptions.sender, currency = normalizedOptions.currency, feeAsset = normalizedOptions.feeAsset, version = normalizedOptions.version, swapOptions = normalizedOptions.swapOptions;
4391
4515
  assertToIsString(to);
4516
+ assertNotEvmTransfer(from, senderSource);
4392
4517
  if (!swapOptions) {
4393
4518
  _context10.n = 2;
4394
4519
  break;
4395
4520
  }
4396
- return _context10.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4521
+ return _context10.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4522
+ from: from,
4397
4523
  swapOptions: swapOptions
4398
4524
  }), function (builder) {
4399
4525
  return builder.getTransferableAmount();
@@ -4427,10 +4553,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
4427
4553
  key: "getMinTransferableAmount",
4428
4554
  value: (function () {
4429
4555
  var _getMinTransferableAmount2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
4430
- var _yield$this$prepareNo6, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4556
+ var senderSource, _yield$this$prepareNo6, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4431
4557
  return _regenerator().w(function (_context11) {
4432
4558
  while (1) switch (_context11.n) {
4433
4559
  case 0:
4560
+ senderSource = this._options.senderSource;
4434
4561
  _context11.n = 1;
4435
4562
  return this.prepareNormalizedOptions(this._options);
4436
4563
  case 1:
@@ -4440,11 +4567,13 @@ var GeneralBuilder = /*#__PURE__*/function () {
4440
4567
  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;
4441
4568
  assertToIsString(to);
4442
4569
  assertAddressIsString(recipient);
4570
+ assertNotEvmTransfer(from, senderSource);
4443
4571
  if (!swapOptions) {
4444
4572
  _context11.n = 2;
4445
4573
  break;
4446
4574
  }
4447
- return _context11.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4575
+ return _context11.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, normalizedOptions), {}, {
4576
+ from: from,
4448
4577
  swapOptions: swapOptions
4449
4578
  }), function (builder) {
4450
4579
  return builder.getMinTransferableAmount();
@@ -4480,10 +4609,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
4480
4609
  key: "verifyEdOnDestination",
4481
4610
  value: (function () {
4482
4611
  var _verifyEdOnDestination2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
4483
- var _yield$this$prepareNo7, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4612
+ var senderSource, _yield$this$prepareNo7, normalizedOptions, buildTx, api, from, to, sender, recipient, currency, feeAsset, version, swapOptions;
4484
4613
  return _regenerator().w(function (_context12) {
4485
4614
  while (1) switch (_context12.n) {
4486
4615
  case 0:
4616
+ senderSource = this._options.senderSource;
4487
4617
  _context12.n = 1;
4488
4618
  return this.prepareNormalizedOptions(this._options);
4489
4619
  case 1:
@@ -4494,6 +4624,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4494
4624
  assertToIsString(to);
4495
4625
  assertAddressIsString(recipient);
4496
4626
  assertSwapSupport(swapOptions);
4627
+ assertNotEvmTransfer(from, senderSource);
4497
4628
  return _context12.a(2, verifyEdOnDestination({
4498
4629
  api: api,
4499
4630
  buildTx: buildTx,
@@ -4523,10 +4654,11 @@ var GeneralBuilder = /*#__PURE__*/function () {
4523
4654
  key: "getTransferInfo",
4524
4655
  value: (function () {
4525
4656
  var _getTransferInfo2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13() {
4526
- var _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, recipient, currency, ahAddress, sender, feeAsset, version, swapOptions;
4657
+ var senderSource, _yield$this$prepareNo8, normalizedOptions, buildTx, api, from, to, recipient, currency, ahAddress, sender, feeAsset, version, swapOptions;
4527
4658
  return _regenerator().w(function (_context13) {
4528
4659
  while (1) switch (_context13.n) {
4529
4660
  case 0:
4661
+ senderSource = this._options.senderSource;
4530
4662
  _context13.n = 1;
4531
4663
  return this.prepareNormalizedOptions(this._options);
4532
4664
  case 1:
@@ -4537,6 +4669,7 @@ var GeneralBuilder = /*#__PURE__*/function () {
4537
4669
  assertToIsString(to);
4538
4670
  assertAddressIsString(recipient);
4539
4671
  assertSwapSupport(swapOptions);
4672
+ assertNotEvmTransfer(from, senderSource);
4540
4673
  return _context13.a(2, getTransferInfo({
4541
4674
  api: api,
4542
4675
  buildTx: buildTx,
@@ -4596,12 +4729,14 @@ var GeneralBuilder = /*#__PURE__*/function () {
4596
4729
  key: "getBestAmountOut",
4597
4730
  value: function () {
4598
4731
  var _getBestAmountOut = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15() {
4599
- var swapOptions;
4732
+ var _this$_options7, from, senderSource, swapOptions;
4600
4733
  return _regenerator().w(function (_context15) {
4601
4734
  while (1) switch (_context15.n) {
4602
4735
  case 0:
4603
- swapOptions = this._options.swapOptions;
4604
- return _context15.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
4736
+ _this$_options7 = this._options, from = _this$_options7.from, senderSource = _this$_options7.senderSource, swapOptions = _this$_options7.swapOptions;
4737
+ assertNotEvmTransfer(from, senderSource);
4738
+ return _context15.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4739
+ from: from,
4605
4740
  api: this.api,
4606
4741
  swapOptions: swapOptions
4607
4742
  }), function (builder) {
@@ -4619,36 +4754,44 @@ var GeneralBuilder = /*#__PURE__*/function () {
4619
4754
  key: "signAndSubmit",
4620
4755
  value: function () {
4621
4756
  var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
4622
- var _this$_options, senderSource, swapOptions, txHashes, _yield$this$buildInte3, tx;
4757
+ var _this$_options8, from, senderSource, swapOptions, txHashes, _yield$this$buildInte3, tx;
4623
4758
  return _regenerator().w(function (_context16) {
4624
4759
  while (1) switch (_context16.n) {
4625
4760
  case 0:
4626
- _this$_options = this._options, senderSource = _this$_options.senderSource, swapOptions = _this$_options.swapOptions;
4761
+ _this$_options8 = this._options, from = _this$_options8.from, senderSource = _this$_options8.senderSource, swapOptions = _this$_options8.swapOptions;
4627
4762
  assertSenderSource(senderSource);
4763
+ if (!isViemSigner(senderSource)) {
4764
+ _context16.n = 1;
4765
+ break;
4766
+ }
4767
+ return _context16.a(2, this.executeWithEvmSigner(senderSource));
4768
+ case 1:
4769
+ assertSubstrateOrigin(from);
4628
4770
  if (!swapOptions) {
4629
- _context16.n = 3;
4771
+ _context16.n = 4;
4630
4772
  break;
4631
4773
  }
4632
4774
  if (isSenderSigner(senderSource)) {
4633
- _context16.n = 1;
4775
+ _context16.n = 2;
4634
4776
  break;
4635
4777
  }
4636
4778
  throw new UnsupportedOperationError('Swap operations do not support local accounts yet. Please provider a signer');
4637
- case 1:
4638
- _context16.n = 2;
4639
- return executeWithRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
4779
+ case 2:
4780
+ _context16.n = 3;
4781
+ return executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4782
+ from: from,
4640
4783
  swapOptions: swapOptions,
4641
4784
  api: this.api
4642
4785
  }), function (builder) {
4643
4786
  return builder.signer(senderSource).signAndSubmit();
4644
4787
  });
4645
- case 2:
4788
+ case 3:
4646
4789
  txHashes = _context16.v;
4647
4790
  return _context16.a(2, txHashes[0]);
4648
- case 3:
4649
- _context16.n = 4;
4650
- return this.buildInternal();
4651
4791
  case 4:
4792
+ _context16.n = 5;
4793
+ return this.buildInternal();
4794
+ case 5:
4652
4795
  _yield$this$buildInte3 = _context16.v;
4653
4796
  tx = _yield$this$buildInte3.tx;
4654
4797
  return _context16.a(2, this.api.signAndSubmit(tx, senderSource));
@@ -4664,37 +4807,49 @@ var GeneralBuilder = /*#__PURE__*/function () {
4664
4807
  key: "signAndSubmitAll",
4665
4808
  value: function () {
4666
4809
  var _signAndSubmitAll = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17() {
4667
- var _this$_options2, senderSource, swapOptions, _yield$this$buildInte4, tx, txHash;
4810
+ var _this$_options9, from, senderSource, swapOptions, hash, _yield$this$buildInte4, tx, txHash;
4668
4811
  return _regenerator().w(function (_context17) {
4669
4812
  while (1) switch (_context17.n) {
4670
4813
  case 0:
4671
- _this$_options2 = this._options, senderSource = _this$_options2.senderSource, swapOptions = _this$_options2.swapOptions;
4814
+ _this$_options9 = this._options, from = _this$_options9.from, senderSource = _this$_options9.senderSource, swapOptions = _this$_options9.swapOptions;
4672
4815
  assertSenderSource(senderSource);
4673
- if (!swapOptions) {
4816
+ if (!isViemSigner(senderSource)) {
4674
4817
  _context17.n = 2;
4675
4818
  break;
4676
4819
  }
4820
+ _context17.n = 1;
4821
+ return this.executeWithEvmSigner(senderSource);
4822
+ case 1:
4823
+ hash = _context17.v;
4824
+ return _context17.a(2, [hash]);
4825
+ case 2:
4826
+ assertSubstrateOrigin(from);
4827
+ if (!swapOptions) {
4828
+ _context17.n = 4;
4829
+ break;
4830
+ }
4677
4831
  if (isSenderSigner(senderSource)) {
4678
- _context17.n = 1;
4832
+ _context17.n = 3;
4679
4833
  break;
4680
4834
  }
4681
4835
  throw new UnsupportedOperationError('Swap operations do not support local accounts yet. Please provider a signer');
4682
- case 1:
4683
- return _context17.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, this._options), {}, {
4836
+ case 3:
4837
+ return _context17.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, this._options), {}, {
4838
+ from: from,
4684
4839
  swapOptions: swapOptions,
4685
4840
  api: this.api
4686
4841
  }), function (builder) {
4687
4842
  return builder.signer(senderSource).signAndSubmit();
4688
4843
  }));
4689
- case 2:
4690
- _context17.n = 3;
4844
+ case 4:
4845
+ _context17.n = 5;
4691
4846
  return this.buildInternal();
4692
- case 3:
4847
+ case 5:
4693
4848
  _yield$this$buildInte4 = _context17.v;
4694
4849
  tx = _yield$this$buildInte4.tx;
4695
- _context17.n = 4;
4850
+ _context17.n = 6;
4696
4851
  return this.api.signAndSubmit(tx, senderSource);
4697
- case 4:
4852
+ case 6:
4698
4853
  txHash = _context17.v;
4699
4854
  return _context17.a(2, [txHash]);
4700
4855
  }
@@ -4705,6 +4860,48 @@ var GeneralBuilder = /*#__PURE__*/function () {
4705
4860
  }
4706
4861
  return signAndSubmitAll;
4707
4862
  }()
4863
+ }, {
4864
+ key: "executeWithEvmSigner",
4865
+ value: function () {
4866
+ var _executeWithEvmSigner = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(signer) {
4867
+ var _this$_options0, from, to, currency, recipient, ahAddress;
4868
+ return _regenerator().w(function (_context18) {
4869
+ while (1) switch (_context18.n) {
4870
+ case 0:
4871
+ _this$_options0 = this._options, from = _this$_options0.from, to = _this$_options0.to, currency = _this$_options0.currency, recipient = _this$_options0.recipient, ahAddress = _this$_options0.ahAddress;
4872
+ assertToIsString(to);
4873
+ assertAddressIsString(recipient);
4874
+ if (!isExternalChain(from)) {
4875
+ _context18.n = 1;
4876
+ break;
4877
+ }
4878
+ return _context18.a(2, getEvmSnowbridgeExtensionOrThrow().executeEvmSnowbridgeTransfer({
4879
+ api: this.api,
4880
+ from: from,
4881
+ to: to,
4882
+ currency: currency,
4883
+ recipient: recipient,
4884
+ ahAddress: ahAddress,
4885
+ signer: signer
4886
+ }));
4887
+ case 1:
4888
+ return _context18.a(2, getEvmExtensionOrThrow().executeEvmTransfer({
4889
+ api: this.api,
4890
+ from: from,
4891
+ to: to,
4892
+ currency: currency,
4893
+ recipient: recipient,
4894
+ ahAddress: ahAddress,
4895
+ signer: signer
4896
+ }));
4897
+ }
4898
+ }, _callee18, this);
4899
+ }));
4900
+ function executeWithEvmSigner(_x8) {
4901
+ return _executeWithEvmSigner.apply(this, arguments);
4902
+ }
4903
+ return executeWithEvmSigner;
4904
+ }()
4708
4905
  /**
4709
4906
  * Returns the API instance used by the builder.
4710
4907
  *
@@ -6054,7 +6251,6 @@ var transferMoonbeamEvm = /*#__PURE__*/function () {
6054
6251
  weight = U_64_MAX; // Partially inspired by Moonbeam XCM-SDK
6055
6252
  // https://github.com/moonbeam-foundation/xcm-sdk/blob/ab835c15bf41612604b1c858d956a9f07705ed65/packages/sdk/src/contract/contracts/Xtokens/Xtokens.ts#L53
6056
6253
  createTx = function createTx(func, args) {
6057
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
6058
6254
  return contract.write[func](args);
6059
6255
  };
6060
6256
  multiCurrencySymbols = ['xcPINK', 'xcDED', 'xcSTINK', 'xcWIFD', 'xcNCTR'];
@@ -9500,17 +9696,6 @@ var verifyEdOnDestination = /*#__PURE__*/function () {
9500
9696
  };
9501
9697
  }();
9502
9698
 
9503
- var swapExtension;
9504
- var registerSwapExtension = function registerSwapExtension(extension) {
9505
- swapExtension = extension;
9506
- };
9507
- var getSwapExtensionOrThrow = function getSwapExtensionOrThrow() {
9508
- if (!swapExtension) {
9509
- throw new ExtensionNotInstalledError('The swap extension is not registered. Please install @paraspell/swap and import it before using swap features.');
9510
- }
9511
- return swapExtension;
9512
- };
9513
-
9514
9699
  var _excluded = ["apiOverrides"];
9515
9700
  var isUrl = function isUrl(value) {
9516
9701
  return typeof value === 'string' || Array.isArray(value);
@@ -9542,14 +9727,14 @@ var convertBuilderConfig = function convertBuilderConfig(config) {
9542
9727
  throw new UnsupportedOperationError('Swap module does not support API client override');
9543
9728
  }
9544
9729
  };
9545
- var createRouterBuilder = function createRouterBuilder(options) {
9730
+ var createSwapBuilder = function createSwapBuilder(options) {
9546
9731
  var _options$transactOpti, _slippage$toString;
9547
9732
  var api = options.api;
9548
9733
  if ((_options$transactOpti = options.transactOptions) !== null && _options$transactOpti !== void 0 && _options$transactOpti.call) {
9549
9734
  throw new UnsupportedOperationError('Cannot use transact options together with swap options.');
9550
9735
  }
9551
9736
  var _getSwapExtensionOrTh = getSwapExtensionOrThrow(),
9552
- RouterBuilder = _getSwapExtensionOrTh.RouterBuilder;
9737
+ SwapBuilder = _getSwapExtensionOrTh.SwapBuilder;
9553
9738
  var from = options.from,
9554
9739
  to = options.to,
9555
9740
  currency = options.currency,
@@ -9567,24 +9752,24 @@ var createRouterBuilder = function createRouterBuilder(options) {
9567
9752
  if (Array.isArray(currency)) {
9568
9753
  throw new UnsupportedOperationError('Swaps with multiple currencies are not supported.');
9569
9754
  }
9570
- var builder = RouterBuilder(api).from(from).exchange(exchange).to(to).currencyFrom(currency).currencyTo(currencyTo).amount(currency.amount).sender(sender).evmSenderAddress(evmSenderAddress).recipient(address).slippagePct((_slippage$toString = slippage === null || slippage === void 0 ? void 0 : slippage.toString()) !== null && _slippage$toString !== void 0 ? _slippage$toString : DEFAULT_SWAP_SLIPPAGE.toString());
9755
+ var builder = SwapBuilder(api).from(from).exchange(exchange).to(to).currencyFrom(currency).currencyTo(currencyTo).amount(currency.amount).sender(sender).evmSenderAddress(evmSenderAddress).recipient(address).slippagePct((_slippage$toString = slippage === null || slippage === void 0 ? void 0 : slippage.toString()) !== null && _slippage$toString !== void 0 ? _slippage$toString : DEFAULT_SWAP_SLIPPAGE.toString());
9571
9756
  if (onStatusChange) {
9572
9757
  builder = builder.onStatusChange(onStatusChange);
9573
9758
  }
9574
9759
  return builder;
9575
9760
  };
9576
- var executeWithRouter = /*#__PURE__*/function () {
9761
+ var executeWithSwap = /*#__PURE__*/function () {
9577
9762
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(options, executor) {
9578
- var routerBuilder;
9763
+ var swapBuilder;
9579
9764
  return _regenerator().w(function (_context) {
9580
9765
  while (1) switch (_context.n) {
9581
9766
  case 0:
9582
- routerBuilder = createRouterBuilder(options);
9583
- return _context.a(2, executor(routerBuilder));
9767
+ swapBuilder = createSwapBuilder(options);
9768
+ return _context.a(2, executor(swapBuilder));
9584
9769
  }
9585
9770
  }, _callee);
9586
9771
  }));
9587
- return function executeWithRouter(_x, _x2) {
9772
+ return function executeWithSwap(_x, _x2) {
9588
9773
  return _ref3.apply(this, arguments);
9589
9774
  };
9590
9775
  }();
@@ -9592,13 +9777,6 @@ var normalizeExchange = function normalizeExchange(exchange) {
9592
9777
  return Array.isArray(exchange) ? exchange.length === 0 ? undefined : exchange.length === 1 ? exchange[0] : exchange : exchange;
9593
9778
  };
9594
9779
 
9595
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9596
- var isConfig = function isConfig(value) {
9597
- return _typeof(value) === 'object' && value !== null && !Array.isArray(value) && (
9598
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
9599
- Object.keys(value).length < 3 || 'apiOverrides' in value || 'development' in value || 'abstractDecimals' in value || 'xcmFormatCheck' in value);
9600
- };
9601
-
9602
9780
  var computeOverridenAmount = function computeOverridenAmount(options, increaseAmount) {
9603
9781
  var relative = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
9604
9782
  var from = options.from,
@@ -9678,7 +9856,7 @@ var createTransferOrSwapAll = /*#__PURE__*/function () {
9678
9856
  _context3.n = 1;
9679
9857
  break;
9680
9858
  }
9681
- return _context3.a(2, executeWithRouter(_objectSpread2(_objectSpread2({}, options), {}, {
9859
+ return _context3.a(2, executeWithSwap(_objectSpread2(_objectSpread2({}, options), {}, {
9682
9860
  swapOptions: swapOptions
9683
9861
  }), function (builder) {
9684
9862
  return builder.build();
@@ -14051,6 +14229,21 @@ var EVM_DEV_PRIVATE_KEYS = {
14051
14229
  faith: '0xb9d2ea9a615f3165812e8d44de0d24da9bbd164b65c4f0573e1ce2c8dbd9c8df'
14052
14230
  };
14053
14231
 
14232
+ var resolveChainApi = function resolveChainApi(config, chain, createApiInstance) {
14233
+ var _config$apiOverrides;
14234
+ var apiConfig = isConfig(config) ? (_config$apiOverrides = config.apiOverrides) === null || _config$apiOverrides === void 0 ? void 0 : _config$apiOverrides[chain] : config;
14235
+ if (isConfig(config) && config.development && !apiConfig) {
14236
+ throw new MissingChainApiError(chain);
14237
+ }
14238
+ if (!apiConfig) {
14239
+ return createApiInstance(getChainProviders(chain));
14240
+ }
14241
+ if (typeof apiConfig === 'string' || apiConfig instanceof Array) {
14242
+ return createApiInstance(apiConfig);
14243
+ }
14244
+ return Promise.resolve(apiConfig);
14245
+ };
14246
+
14054
14247
  var PolkadotApi = /*#__PURE__*/function () {
14055
14248
  function PolkadotApi(config) {
14056
14249
  _classCallCheck(this, PolkadotApi);
@@ -14079,24 +14272,44 @@ var PolkadotApi = /*#__PURE__*/function () {
14079
14272
  get: function get() {
14080
14273
  return this._config;
14081
14274
  }
14275
+ }, {
14276
+ key: "init",
14277
+ value: function () {
14278
+ var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(chain) {
14279
+ var _this = this;
14280
+ var clientTtlMs,
14281
+ _args = arguments;
14282
+ return _regenerator().w(function (_context) {
14283
+ while (1) switch (_context.n) {
14284
+ case 0:
14285
+ clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
14286
+ if (!(this._chain !== undefined || isExternalChain(chain))) {
14287
+ _context.n = 1;
14288
+ break;
14289
+ }
14290
+ return _context.a(2);
14291
+ case 1:
14292
+ this._ttlMs = clientTtlMs;
14293
+ this._chain = chain;
14294
+ _context.n = 2;
14295
+ return resolveChainApi(this._config, chain, function (wsUrl) {
14296
+ return _this.leaseClient(wsUrl, _this._ttlMs);
14297
+ });
14298
+ case 2:
14299
+ this._api = _context.v;
14300
+ case 3:
14301
+ return _context.a(2);
14302
+ }
14303
+ }, _callee, this);
14304
+ }));
14305
+ function init(_x) {
14306
+ return _init.apply(this, arguments);
14307
+ }
14308
+ return init;
14309
+ }()
14082
14310
  }]);
14083
14311
  }();
14084
14312
 
14085
- var resolveChainApi = function resolveChainApi(config, chain, createApiInstance) {
14086
- var _config$apiOverrides;
14087
- var apiConfig = isConfig(config) ? (_config$apiOverrides = config.apiOverrides) === null || _config$apiOverrides === void 0 ? void 0 : _config$apiOverrides[chain] : config;
14088
- if (isConfig(config) && config.development && !apiConfig) {
14089
- throw new MissingChainApiError(chain);
14090
- }
14091
- if (!apiConfig) {
14092
- return createApiInstance(getChainProviders(chain));
14093
- }
14094
- if (typeof apiConfig === 'string' || apiConfig instanceof Array) {
14095
- return createApiInstance(apiConfig);
14096
- }
14097
- return Promise.resolve(apiConfig);
14098
- };
14099
-
14100
14313
  var createClientCache = function createClientCache(maxSize, pingClient, onEviction) {
14101
14314
  var extensionMs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 5 * 60000;
14102
14315
  var data = new Map();
@@ -14265,4 +14478,4 @@ var createClientCache = function createClientCache(maxSize, pingClient, onEvicti
14265
14478
  };
14266
14479
  };
14267
14480
 
14268
- 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, assertHasId, assertSender, assertSenderSource, assertSwapSupport, assertToIsString, blake2b256, blake2b512, calcPreviewMintAmount, claimAssets, compareAddresses, computeOverridenAmount, constructTypeAndThenCall, convertBuilderConfig, convertSs58, createAsset, createAssetId, createAssetsFilter, createBaseExecuteXcm, createBeneficiaryLocXTokens, createBeneficiaryLocation, createChainClient, createClientCache, createClientPoolHelpers, createDestination, createDirectExecuteXcm, createExecuteCall, createExecuteExchangeXcm, createRouterBuilder, createTransfer, createTransferOrSwap, createTransferOrSwapAll, createTxOverrideAmount, createTypeAndThenCall, createTypeThenAutoReserve, createVersionedAssets, createVersionedDestination, createX1Payload, deriveAccountId, dryRun, dryRunInternal, dryRunOrigin, encodeSs58, executeWithRouter, formatAssetIdToERC20, formatUnits, getAssetBalanceInternal, getAssetReserveChain, getBalance, getBalanceInternal, getBridgeStatus, getChain, getChainConfig, getChainLocation, getChainProviders, getChainVersion, getEthErc20Balance, getEvmPrivateKeyHex, 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, keyFromWs, localizeLocation, maybeOverrideAsset, maybeOverrideAssets, normalizeAmount, normalizeExchange, overrideTxAmount, padFee, padValueBy, parseUnits, pickCompatibleXcmVersion, pickRouterCompatibleXcmVersion, registerSwapExtension, resolveAssetCount, resolveChainApi, resolveDestChain, resolveModuleError, resolveParaId, resolveTransferParams, reverseTransformLocation, selectXcmVersion, sortAssets, throwUnsupportedCurrency, transferMoonbeamEvm, transferMoonbeamToEth, traverseXcmHops, validateAddress, validateAssetSpecifiers, validateCurrency, validateDestination, validateDestinationAddress, validateTransact, verifyEdOnDestination, wrapTxBypass };
14481
+ 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 };