@paraspell/sdk-pjs 13.2.1 → 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.
package/dist/index.mjs CHANGED
@@ -1,11 +1,12 @@
1
- import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, PolkadotApi, resolveChainApi, DEFAULT_TTL_MS, isExternalChain, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, assertHasId, getParaId, RoutingResolutionError, abstractDecimals, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
1
+ import { getNativeAssetSymbol, getOtherAssets, hasJunction, getJunctionValue, getEvmPrivateKeyHex, UnsupportedOperationError, createClientCache, MAX_CLIENTS, EXTENSION_MS, createClientPoolHelpers, BatchMode, isConfig, findNativeAssetInfoOrThrow, getChainProviders, isSenderSigner, PolkadotApi, findAssetInfoOrThrow, hasXcmPaymentApiSupport, resolveModuleError, getAssetsObject, RuntimeApiUnavailableError, wrapTxBypass, normalizeLocation, localizeLocation, createAssetId, addXcmVersionHeader, isAssetXcEqual, RELAY_LOCATION, getRelayChainOf, SubmitTransactionError, createChainClient as createChainClient$1, getBalance as getBalance$1, Foreign, ForeignAbstract, Native, Override, findAssetInfo, getAllAssetsSymbols, getAssetDecimals, getAssetId, getAssets, getExistentialDeposit, getNativeAssets, getRelayChainSymbol, getSupportedAssets, getTChain, hasSupportForAsset, isChainEvm, convertSs58 as convertSs58$1, assertHasId, getParaId, RoutingResolutionError, abstractDecimals, MissingParameterError, isOverrideLocationSpecifier, transferMoonbeamEvm, transferMoonbeamToEth, validateAddress as validateAddress$1, Builder as Builder$1, getBridgeStatus as getBridgeStatus$1, getParaEthTransferFees as getParaEthTransferFees$1, DRY_RUN_CLIENT_TIMEOUT_MS, dryRun as dryRun$1, dryRunOrigin as dryRunOrigin$1 } from '@paraspell/sdk-core';
2
2
  export * from '@paraspell/sdk-core';
3
3
  import { Keyring, WsProvider, ApiPromise } from '@polkadot/api';
4
4
  import { u8aConcat, compactToU8a, u8aEq, isHex, u8aToHex, hexToU8a, stringToU8a } from '@polkadot/util';
5
5
  import { decodeAddress, blake2AsHex, validateAddress } from '@polkadot/util-crypto';
6
6
  import { WETH9__factory } from '@snowbridge/contract-types';
7
7
  import { bridgeInfoFor } from '@snowbridge/registry';
8
- import { Context, toPolkadotV2 } from '@snowbridge/api';
8
+ import { toPolkadotV2, SnowbridgeApi } from '@snowbridge/api';
9
+ import { EthersEthereumProvider } from '@snowbridge/provider-ethers';
9
10
 
10
11
  function _arrayLikeToArray(r, a) {
11
12
  (null == a || a > r.length) && (a = r.length);
@@ -485,7 +486,7 @@ var createPolkadotJsClient = /*#__PURE__*/function () {
485
486
  };
486
487
  }();
487
488
  var _createClientPoolHelp = createClientPoolHelpers(clientPool, createPolkadotJsClient),
488
- leaseClient = _createClientPoolHelp.leaseClient,
489
+ _leaseClient = _createClientPoolHelp.leaseClient,
489
490
  releaseClient = _createClientPoolHelp.releaseClient;
490
491
  var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
491
492
  function PolkadotJsApi() {
@@ -497,44 +498,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
497
498
  }
498
499
  _inherits(PolkadotJsApi, _PolkadotApi);
499
500
  return _createClass(PolkadotJsApi, [{
500
- key: "init",
501
- value: function () {
502
- var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(chain) {
503
- var _this2 = this;
504
- var clientTtlMs,
505
- _args = arguments;
506
- return _regenerator().w(function (_context3) {
507
- while (1) switch (_context3.n) {
508
- case 0:
509
- clientTtlMs = _args.length > 1 && _args[1] !== undefined ? _args[1] : DEFAULT_TTL_MS;
510
- if (!(this._chain !== undefined || isExternalChain(chain))) {
511
- _context3.n = 1;
512
- break;
513
- }
514
- return _context3.a(2);
515
- case 1:
516
- this._ttlMs = clientTtlMs;
517
- this._chain = chain;
518
- _context3.n = 2;
519
- return resolveChainApi(this._config, chain, function (wsUrl) {
520
- return leaseClient(wsUrl, _this2._ttlMs);
521
- });
522
- case 2:
523
- this._api = _context3.v;
524
- case 3:
525
- return _context3.a(2);
526
- }
527
- }, _callee3, this);
528
- }));
529
- function init(_x3) {
530
- return _init.apply(this, arguments);
531
- }
532
- return init;
533
- }()
534
- }, {
535
- key: "createApiInstance",
536
- value: function createApiInstance(wsUrl, _chain) {
537
- return leaseClient(wsUrl, this._ttlMs);
501
+ key: "leaseClient",
502
+ value: function leaseClient(wsUrl, ttlMs) {
503
+ return _leaseClient(wsUrl, ttlMs);
538
504
  }
539
505
  }, {
540
506
  key: "accountToHex",
@@ -585,26 +551,38 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
585
551
  value: function txFromHex$1(hex) {
586
552
  return Promise.resolve(txFromHex(this.api, hex));
587
553
  }
554
+ }, {
555
+ key: "txToHex",
556
+ value: function txToHex(tx) {
557
+ return Promise.resolve(tx.toHex());
558
+ }
559
+ }, {
560
+ key: "encodeTx",
561
+ value: function encodeTx(hex) {
562
+ return {
563
+ encoded: hex
564
+ };
565
+ }
588
566
  }, {
589
567
  key: "queryState",
590
568
  value: function () {
591
- var _queryState = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(serialized) {
569
+ var _queryState = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(serialized) {
592
570
  var _this$api$query$modul;
593
571
  var params, _this$convertToPjsSta, module, method, res;
594
- return _regenerator().w(function (_context4) {
595
- while (1) switch (_context4.n) {
572
+ return _regenerator().w(function (_context3) {
573
+ while (1) switch (_context3.n) {
596
574
  case 0:
597
575
  params = serialized.params;
598
576
  _this$convertToPjsSta = this.convertToPjsStateQuery(serialized), module = _this$convertToPjsSta.module, method = _this$convertToPjsSta.method;
599
- _context4.n = 1;
577
+ _context3.n = 1;
600
578
  return (_this$api$query$modul = this.api.query[module])[method].apply(_this$api$query$modul, _toConsumableArray(params));
601
579
  case 1:
602
- res = _context4.v;
603
- return _context4.a(2, res.toJSON());
580
+ res = _context3.v;
581
+ return _context3.a(2, res.toJSON());
604
582
  }
605
- }, _callee4, this);
583
+ }, _callee3, this);
606
584
  }));
607
- function queryState(_x4) {
585
+ function queryState(_x3) {
608
586
  return _queryState.apply(this, arguments);
609
587
  }
610
588
  return queryState;
@@ -612,23 +590,23 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
612
590
  }, {
613
591
  key: "queryRuntimeApi",
614
592
  value: function () {
615
- var _queryRuntimeApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(serialized) {
593
+ var _queryRuntimeApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(serialized) {
616
594
  var _this$api$call$module;
617
595
  var params, _this$convertToPjsTxC2, module, method, res;
618
- return _regenerator().w(function (_context5) {
619
- while (1) switch (_context5.n) {
596
+ return _regenerator().w(function (_context4) {
597
+ while (1) switch (_context4.n) {
620
598
  case 0:
621
599
  params = serialized.params;
622
600
  _this$convertToPjsTxC2 = this.convertToPjsTxCall(serialized), module = _this$convertToPjsTxC2.module, method = _this$convertToPjsTxC2.method;
623
- _context5.n = 1;
601
+ _context4.n = 1;
624
602
  return (_this$api$call$module = this.api.call[module])[method].apply(_this$api$call$module, _toConsumableArray(params));
625
603
  case 1:
626
- res = _context5.v;
627
- return _context5.a(2, res.toJSON());
604
+ res = _context4.v;
605
+ return _context4.a(2, res.toJSON());
628
606
  }
629
- }, _callee5, this);
607
+ }, _callee4, this);
630
608
  }));
631
- function queryRuntimeApi(_x5) {
609
+ function queryRuntimeApi(_x4) {
632
610
  return _queryRuntimeApi.apply(this, arguments);
633
611
  }
634
612
  return queryRuntimeApi;
@@ -667,20 +645,20 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
667
645
  }, {
668
646
  key: "getPaymentInfo",
669
647
  value: function () {
670
- var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(tx, address) {
648
+ var _getPaymentInfo = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(tx, address) {
671
649
  var _yield$tx$paymentInfo, _yield$tx$paymentInfo2, proofSize, refTime, partialFee;
672
- return _regenerator().w(function (_context6) {
673
- while (1) switch (_context6.n) {
650
+ return _regenerator().w(function (_context5) {
651
+ while (1) switch (_context5.n) {
674
652
  case 0:
675
- _context6.n = 1;
653
+ _context5.n = 1;
676
654
  return tx.paymentInfo(address);
677
655
  case 1:
678
- _yield$tx$paymentInfo = _context6.v;
656
+ _yield$tx$paymentInfo = _context5.v;
679
657
  _yield$tx$paymentInfo2 = _yield$tx$paymentInfo.weight;
680
658
  proofSize = _yield$tx$paymentInfo2.proofSize;
681
659
  refTime = _yield$tx$paymentInfo2.refTime;
682
660
  partialFee = _yield$tx$paymentInfo.partialFee;
683
- return _context6.a(2, {
661
+ return _context5.a(2, {
684
662
  weight: {
685
663
  proofSize: proofSize.toBigInt(),
686
664
  refTime: refTime.toBigInt()
@@ -688,37 +666,13 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
688
666
  partialFee: partialFee.toBigInt()
689
667
  });
690
668
  }
691
- }, _callee6);
669
+ }, _callee5);
692
670
  }));
693
- function getPaymentInfo(_x6, _x7) {
671
+ function getPaymentInfo(_x5, _x6) {
694
672
  return _getPaymentInfo.apply(this, arguments);
695
673
  }
696
674
  return getPaymentInfo;
697
675
  }()
698
- }, {
699
- key: "quoteAhPrice",
700
- value: function () {
701
- var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(fromMl, toMl, amountIn) {
702
- var includeFee,
703
- quoted,
704
- _args5 = arguments;
705
- return _regenerator().w(function (_context7) {
706
- while (1) switch (_context7.n) {
707
- case 0:
708
- includeFee = _args5.length > 3 && _args5[3] !== undefined ? _args5[3] : true;
709
- _context7.n = 1;
710
- return this.api.call.assetConversionApi.quotePriceExactTokensForTokens(fromMl, toMl, amountIn.toString(), includeFee);
711
- case 1:
712
- quoted = _context7.v;
713
- return _context7.a(2, quoted.toJSON() !== null ? BigInt(quoted.toString()) : undefined);
714
- }
715
- }, _callee7, this);
716
- }));
717
- function quoteAhPrice(_x8, _x9, _x0) {
718
- return _quoteAhPrice.apply(this, arguments);
719
- }
720
- return quoteAhPrice;
721
- }()
722
676
  }, {
723
677
  key: "getEvmStorage",
724
678
  value: function getEvmStorage(contract, slot) {
@@ -747,27 +701,27 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
747
701
  }, {
748
702
  key: "getFromRpc",
749
703
  value: function () {
750
- var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(module, method, key) {
704
+ var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(module, method, key) {
751
705
  var rpcModule, response;
752
- return _regenerator().w(function (_context8) {
753
- while (1) switch (_context8.n) {
706
+ return _regenerator().w(function (_context6) {
707
+ while (1) switch (_context6.n) {
754
708
  case 0:
755
709
  rpcModule = this.api.rpc[module];
756
710
  if (!(!rpcModule || !rpcModule[method])) {
757
- _context8.n = 1;
711
+ _context6.n = 1;
758
712
  break;
759
713
  }
760
714
  throw new UnsupportedOperationError("RPC method ".concat(module, ".").concat(method, " not available"));
761
715
  case 1:
762
- _context8.n = 2;
716
+ _context6.n = 2;
763
717
  return rpcModule[method](key);
764
718
  case 2:
765
- response = _context8.v;
766
- return _context8.a(2, response.toHex());
719
+ response = _context6.v;
720
+ return _context6.a(2, response.toHex());
767
721
  }
768
- }, _callee8, this);
722
+ }, _callee6, this);
769
723
  }));
770
- function getFromRpc(_x1, _x10, _x11) {
724
+ function getFromRpc(_x7, _x8, _x9) {
771
725
  return _getFromRpc.apply(this, arguments);
772
726
  }
773
727
  return getFromRpc;
@@ -785,20 +739,20 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
785
739
  }, {
786
740
  key: "createApiForChain",
787
741
  value: function () {
788
- var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(chain) {
742
+ var _createApiForChain = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(chain) {
789
743
  var api;
790
- return _regenerator().w(function (_context9) {
791
- while (1) switch (_context9.n) {
744
+ return _regenerator().w(function (_context7) {
745
+ while (1) switch (_context7.n) {
792
746
  case 0:
793
747
  api = new PolkadotJsApi(isConfig(this._config) ? this._config : undefined);
794
- _context9.n = 1;
748
+ _context7.n = 1;
795
749
  return api.init(chain);
796
750
  case 1:
797
- return _context9.a(2, api);
751
+ return _context7.a(2, api);
798
752
  }
799
- }, _callee9, this);
753
+ }, _callee7, this);
800
754
  }));
801
- function createApiForChain(_x12) {
755
+ function createApiForChain(_x0) {
802
756
  return _createApiForChain.apply(this, arguments);
803
757
  }
804
758
  return createApiForChain;
@@ -813,45 +767,45 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
813
767
  }, {
814
768
  key: "resolveFeeAsset",
815
769
  value: function () {
816
- var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
770
+ var _resolveFeeAsset = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(options) {
817
771
  var chain, address, response, assetId;
818
- return _regenerator().w(function (_context0) {
819
- while (1) switch (_context0.n) {
772
+ return _regenerator().w(function (_context8) {
773
+ while (1) switch (_context8.n) {
820
774
  case 0:
821
775
  chain = options.chain, address = options.address;
822
776
  if (chain.startsWith('Hydration')) {
823
- _context0.n = 1;
777
+ _context8.n = 1;
824
778
  break;
825
779
  }
826
- return _context0.a(2, {
780
+ return _context8.a(2, {
827
781
  isCustomAsset: false,
828
782
  asset: this.resolveDefaultFeeAsset(options)
829
783
  });
830
784
  case 1:
831
- _context0.n = 2;
785
+ _context8.n = 2;
832
786
  return this.api.query.multiTransactionPayment.accountCurrencyMap(address);
833
787
  case 2:
834
- response = _context0.v;
788
+ response = _context8.v;
835
789
  assetId = response.toJSON();
836
790
  if (!(assetId === null)) {
837
- _context0.n = 3;
791
+ _context8.n = 3;
838
792
  break;
839
793
  }
840
- return _context0.a(2, {
794
+ return _context8.a(2, {
841
795
  isCustomAsset: false,
842
796
  asset: this.resolveDefaultFeeAsset(options)
843
797
  });
844
798
  case 3:
845
- return _context0.a(2, {
799
+ return _context8.a(2, {
846
800
  isCustomAsset: true,
847
801
  asset: findAssetInfoOrThrow(chain, {
848
802
  id: assetId
849
803
  })
850
804
  });
851
805
  }
852
- }, _callee0, this);
806
+ }, _callee8, this);
853
807
  }));
854
- function resolveFeeAsset(_x13) {
808
+ function resolveFeeAsset(_x1) {
855
809
  return _resolveFeeAsset.apply(this, arguments);
856
810
  }
857
811
  return resolveFeeAsset;
@@ -859,16 +813,16 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
859
813
  }, {
860
814
  key: "getDryRunCall",
861
815
  value: function () {
862
- var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(options) {
863
- var _this3 = this;
816
+ var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(options) {
817
+ var _this2 = this;
864
818
  var tx, address, feeAsset, chain, destination, version, _options$useRootOrigi, useRootOrigin, bypassOptions, supportsDryRunApi, basePayload, resolvedTx, resolvedFeeAsset, performDryRunCall, findFailingEventInResult, getExecutionSuccessFromResult, extractFailureReasonFromResult, response, resultHuman, resultJson, isSuccess, failureErr, shouldRetryWithVersion, msg, _msg, forwardedXcms, actualWeight, weight, destParaId, overriddenWeight, xcmFee, _yield$this$getPaymen, executionFee, fee, _t, _t2, _t3, _t4;
865
- return _regenerator().w(function (_context10) {
866
- while (1) switch (_context10.p = _context10.n) {
819
+ return _regenerator().w(function (_context0) {
820
+ while (1) switch (_context0.p = _context0.n) {
867
821
  case 0:
868
822
  tx = options.tx, address = options.address, feeAsset = options.feeAsset, chain = options.chain, destination = options.destination, version = options.version, _options$useRootOrigi = options.useRootOrigin, useRootOrigin = _options$useRootOrigi === void 0 ? false : _options$useRootOrigi, bypassOptions = options.bypassOptions;
869
823
  supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
870
824
  if (supportsDryRunApi) {
871
- _context10.n = 1;
825
+ _context0.n = 1;
872
826
  break;
873
827
  }
874
828
  throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
@@ -883,38 +837,38 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
883
837
  }
884
838
  };
885
839
  if (!useRootOrigin) {
886
- _context10.n = 3;
840
+ _context0.n = 3;
887
841
  break;
888
842
  }
889
- _context10.n = 2;
843
+ _context0.n = 2;
890
844
  return wrapTxBypass(_objectSpread2(_objectSpread2({}, options), {}, {
891
845
  api: this
892
846
  }), bypassOptions);
893
847
  case 2:
894
- _t = _context10.v;
895
- _context10.n = 4;
848
+ _t = _context0.v;
849
+ _context0.n = 4;
896
850
  break;
897
851
  case 3:
898
852
  _t = tx;
899
853
  case 4:
900
854
  resolvedTx = _t;
901
- _context10.n = 5;
855
+ _context0.n = 5;
902
856
  return this.resolveFeeAsset(options);
903
857
  case 5:
904
- resolvedFeeAsset = _context10.v;
858
+ resolvedFeeAsset = _context0.v;
905
859
  performDryRunCall = /*#__PURE__*/function () {
906
- var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(includeVersion) {
907
- var _this3$api$call$dryRu;
860
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(includeVersion) {
861
+ var _this2$api$call$dryRu;
908
862
  var versionNum;
909
- return _regenerator().w(function (_context1) {
910
- while (1) switch (_context1.n) {
863
+ return _regenerator().w(function (_context9) {
864
+ while (1) switch (_context9.n) {
911
865
  case 0:
912
866
  versionNum = Number(version.charAt(1));
913
- return _context1.a(2, (_this3$api$call$dryRu = _this3.api.call.dryRunApi).dryRunCall.apply(_this3$api$call$dryRu, [basePayload, resolvedTx].concat(_toConsumableArray(includeVersion ? [versionNum] : []))));
867
+ return _context9.a(2, (_this2$api$call$dryRu = _this2.api.call.dryRunApi).dryRunCall.apply(_this2$api$call$dryRu, [basePayload, resolvedTx].concat(_toConsumableArray(includeVersion ? [versionNum] : []))));
914
868
  }
915
- }, _callee1);
869
+ }, _callee9);
916
870
  }));
917
- return function performDryRunCall(_x15) {
871
+ return function performDryRunCall(_x11) {
918
872
  return _ref6.apply(this, arguments);
919
873
  };
920
874
  }();
@@ -979,11 +933,11 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
979
933
  failureReason: ''
980
934
  };
981
935
  shouldRetryWithVersion = false;
982
- _context10.p = 6;
983
- _context10.n = 7;
936
+ _context0.p = 6;
937
+ _context0.n = 7;
984
938
  return performDryRunCall(false);
985
939
  case 7:
986
- response = _context10.v;
940
+ response = _context0.v;
987
941
  resultHuman = response.toHuman();
988
942
  resultJson = response.toJSON();
989
943
  isSuccess = getExecutionSuccessFromResult(resultHuman);
@@ -993,49 +947,49 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
993
947
  shouldRetryWithVersion = true;
994
948
  }
995
949
  }
996
- _context10.n = 10;
950
+ _context0.n = 10;
997
951
  break;
998
952
  case 8:
999
- _context10.p = 8;
1000
- _t2 = _context10.v;
953
+ _context0.p = 8;
954
+ _t2 = _context0.v;
1001
955
  msg = _t2 instanceof Error ? _t2.message : String(_t2);
1002
956
  if (!msg.includes('Expected 3 arguments')) {
1003
- _context10.n = 9;
957
+ _context0.n = 9;
1004
958
  break;
1005
959
  }
1006
960
  shouldRetryWithVersion = true;
1007
- _context10.n = 10;
961
+ _context0.n = 10;
1008
962
  break;
1009
963
  case 9:
1010
- return _context10.a(2, {
964
+ return _context0.a(2, {
1011
965
  success: false,
1012
966
  failureReason: msg,
1013
967
  asset: resolvedFeeAsset.asset
1014
968
  });
1015
969
  case 10:
1016
970
  if (!shouldRetryWithVersion) {
1017
- _context10.n = 14;
971
+ _context0.n = 14;
1018
972
  break;
1019
973
  }
1020
- _context10.p = 11;
1021
- _context10.n = 12;
974
+ _context0.p = 11;
975
+ _context0.n = 12;
1022
976
  return performDryRunCall(true);
1023
977
  case 12:
1024
- response = _context10.v;
978
+ response = _context0.v;
1025
979
  resultHuman = response.toHuman();
1026
980
  resultJson = response.toJSON();
1027
981
  isSuccess = getExecutionSuccessFromResult(resultHuman);
1028
982
  if (!isSuccess) {
1029
983
  failureErr = extractFailureReasonFromResult(resultHuman, resultJson);
1030
984
  }
1031
- _context10.n = 14;
985
+ _context0.n = 14;
1032
986
  break;
1033
987
  case 13:
1034
- _context10.p = 13;
1035
- _t3 = _context10.v;
988
+ _context0.p = 13;
989
+ _t3 = _context0.v;
1036
990
  _msg = _t3 instanceof Error ? _t3.message : String(_t3);
1037
991
  failureErr = failureErr || _msg;
1038
- return _context10.a(2, {
992
+ return _context0.a(2, {
1039
993
  success: false,
1040
994
  failureReason: failureErr.failureReason,
1041
995
  failureSubReason: failureErr.failureSubReason,
@@ -1043,10 +997,10 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1043
997
  });
1044
998
  case 14:
1045
999
  if (isSuccess) {
1046
- _context10.n = 15;
1000
+ _context0.n = 15;
1047
1001
  break;
1048
1002
  }
1049
- return _context10.a(2, {
1003
+ return _context0.a(2, {
1050
1004
  success: false,
1051
1005
  failureReason: failureErr.failureReason || 'Unknown error',
1052
1006
  failureSubReason: failureErr.failureSubReason,
@@ -1063,32 +1017,32 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1063
1017
  return i.here === null ? 0 : (_ref8 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref8 === void 0 ? void 0 : _ref8.parachain;
1064
1018
  }(Object.values(forwardedXcms[0])[0].interior);
1065
1019
  if (!(hasXcmPaymentApiSupport(chain) && resultJson.ok.local_xcm && (feeAsset || chain.startsWith('AssetHub') && destination === 'Ethereum') || resolvedFeeAsset.isCustomAsset)) {
1066
- _context10.n = 21;
1020
+ _context0.n = 21;
1067
1021
  break;
1068
1022
  }
1069
1023
  if (resultJson.ok.local_xcm) {
1070
- _context10.n = 17;
1024
+ _context0.n = 17;
1071
1025
  break;
1072
1026
  }
1073
- _context10.n = 16;
1027
+ _context0.n = 16;
1074
1028
  return this.getPaymentInfo(tx, address);
1075
1029
  case 16:
1076
- _t4 = _context10.v.weight;
1077
- _context10.n = 18;
1030
+ _t4 = _context0.v.weight;
1031
+ _context0.n = 18;
1078
1032
  break;
1079
1033
  case 17:
1080
1034
  _t4 = undefined;
1081
1035
  case 18:
1082
1036
  overriddenWeight = _t4;
1083
- _context10.n = 19;
1037
+ _context0.n = 19;
1084
1038
  return this.getXcmPaymentApiFee(chain, resultJson.ok.local_xcm, forwardedXcms, resolvedFeeAsset.asset, version, false, overriddenWeight);
1085
1039
  case 19:
1086
- xcmFee = _context10.v;
1040
+ xcmFee = _context0.v;
1087
1041
  if (!(typeof xcmFee === 'bigint')) {
1088
- _context10.n = 20;
1042
+ _context0.n = 20;
1089
1043
  break;
1090
1044
  }
1091
- return _context10.a(2, Promise.resolve({
1045
+ return _context0.a(2, Promise.resolve({
1092
1046
  success: true,
1093
1047
  fee: xcmFee,
1094
1048
  asset: resolvedFeeAsset.asset,
@@ -1102,13 +1056,13 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1102
1056
  asset: this.resolveDefaultFeeAsset(options)
1103
1057
  };
1104
1058
  case 21:
1105
- _context10.n = 22;
1059
+ _context0.n = 22;
1106
1060
  return this.getPaymentInfo(tx, address);
1107
1061
  case 22:
1108
- _yield$this$getPaymen = _context10.v;
1062
+ _yield$this$getPaymen = _context0.v;
1109
1063
  executionFee = _yield$this$getPaymen.partialFee;
1110
1064
  fee = computeOriginFee(resultHuman, chain, executionFee);
1111
- return _context10.a(2, {
1065
+ return _context0.a(2, {
1112
1066
  success: true,
1113
1067
  fee: fee,
1114
1068
  asset: resolvedFeeAsset.asset,
@@ -1117,9 +1071,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1117
1071
  destParaId: destParaId
1118
1072
  });
1119
1073
  }
1120
- }, _callee10, this, [[11, 13], [6, 8]]);
1074
+ }, _callee0, this, [[11, 13], [6, 8]]);
1121
1075
  }));
1122
- function getDryRunCall(_x14) {
1076
+ function getDryRunCall(_x10) {
1123
1077
  return _getDryRunCall.apply(this, arguments);
1124
1078
  }
1125
1079
  return getDryRunCall;
@@ -1127,7 +1081,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1127
1081
  }, {
1128
1082
  key: "getXcmPaymentApiFee",
1129
1083
  value: function () {
1130
- var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, localXcm, forwardedXcm, asset, version) {
1084
+ var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(chain, localXcm, forwardedXcm, asset, version) {
1131
1085
  var overridenWeight,
1132
1086
  weight,
1133
1087
  assetLocalizedLoc,
@@ -1139,57 +1093,57 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1139
1093
  isAssetNotFound,
1140
1094
  bridgeHubExecFee,
1141
1095
  deliveryFee,
1142
- _args1 = arguments,
1096
+ _args9 = arguments,
1143
1097
  _t5;
1144
- return _regenerator().w(function (_context11) {
1145
- while (1) switch (_context11.n) {
1098
+ return _regenerator().w(function (_context1) {
1099
+ while (1) switch (_context1.n) {
1146
1100
  case 0:
1147
- overridenWeight = _args1.length > 6 ? _args1[6] : undefined;
1101
+ overridenWeight = _args9.length > 6 ? _args9[6] : undefined;
1148
1102
  if (!(overridenWeight !== null && overridenWeight !== void 0)) {
1149
- _context11.n = 1;
1103
+ _context1.n = 1;
1150
1104
  break;
1151
1105
  }
1152
1106
  _t5 = overridenWeight;
1153
- _context11.n = 3;
1107
+ _context1.n = 3;
1154
1108
  break;
1155
1109
  case 1:
1156
- _context11.n = 2;
1110
+ _context1.n = 2;
1157
1111
  return this.getXcmWeight(localXcm);
1158
1112
  case 2:
1159
- _t5 = _context11.v;
1113
+ _t5 = _context1.v;
1160
1114
  case 3:
1161
1115
  weight = _t5;
1162
1116
  assetLocalizedLoc = normalizeLocation(localizeLocation(chain, asset.location), version);
1163
1117
  assetId = createAssetId(version, assetLocalizedLoc);
1164
- _context11.n = 4;
1118
+ _context1.n = 4;
1165
1119
  return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weight, addXcmVersionHeader(assetId, version));
1166
1120
  case 4:
1167
- feeResult = _context11.v;
1121
+ feeResult = _context1.v;
1168
1122
  execFeeRes = feeResult.toJSON();
1169
1123
  execFeeOk = execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.ok;
1170
1124
  execFee = typeof execFeeOk === 'string' || typeof execFeeOk === 'number' ? BigInt(execFeeOk) : 0n;
1171
1125
  isAssetNotFound = (execFeeRes === null || execFeeRes === void 0 ? void 0 : execFeeRes.err) === 'AssetNotFound';
1172
1126
  if (!(chain.startsWith('BridgeHub') && isAssetNotFound)) {
1173
- _context11.n = 6;
1127
+ _context1.n = 6;
1174
1128
  break;
1175
1129
  }
1176
- _context11.n = 5;
1130
+ _context1.n = 5;
1177
1131
  return this.getBridgeHubFallbackExecFee(chain, weight, asset, version);
1178
1132
  case 5:
1179
- bridgeHubExecFee = _context11.v;
1133
+ bridgeHubExecFee = _context1.v;
1180
1134
  if (typeof bridgeHubExecFee === 'bigint') {
1181
1135
  execFee = bridgeHubExecFee;
1182
1136
  }
1183
1137
  case 6:
1184
- _context11.n = 7;
1138
+ _context1.n = 7;
1185
1139
  return this.getDeliveryFee(chain, forwardedXcm, asset, assetLocalizedLoc, version);
1186
1140
  case 7:
1187
- deliveryFee = _context11.v;
1188
- return _context11.a(2, execFee + deliveryFee);
1141
+ deliveryFee = _context1.v;
1142
+ return _context1.a(2, execFee + deliveryFee);
1189
1143
  }
1190
- }, _callee11, this);
1144
+ }, _callee1, this);
1191
1145
  }));
1192
- function getXcmPaymentApiFee(_x16, _x17, _x18, _x19, _x20) {
1146
+ function getXcmPaymentApiFee(_x12, _x13, _x14, _x15, _x16) {
1193
1147
  return _getXcmPaymentApiFee.apply(this, arguments);
1194
1148
  }
1195
1149
  return getXcmPaymentApiFee;
@@ -1197,41 +1151,41 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1197
1151
  }, {
1198
1152
  key: "getDeliveryFee",
1199
1153
  value: function () {
1200
- var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
1154
+ var _getDeliveryFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(chain, forwardedXcm, asset, assetLocalizedLoc, version) {
1201
1155
  var _deliveryFeeRes, _ref9, _deliveryFeeResJson$o, _deliveryFeeResJson$o2, _deliveryFeeResJson$o3, _ref0, _deliveryFeeResJson$o4, _deliveryFeeResJson$o5, _deliveryFeeResJson$o6;
1202
1156
  var usedThirdParam, deliveryFeeRes, baseArgs, _this$api$call$xcmPay, message, _this$api$call$xcmPay2, assetId, versionedAssetLoc, deliveryFeeResJson, deliveryFeeResolved, nativeAsset, res, _t6;
1203
- return _regenerator().w(function (_context12) {
1204
- while (1) switch (_context12.p = _context12.n) {
1157
+ return _regenerator().w(function (_context10) {
1158
+ while (1) switch (_context10.p = _context10.n) {
1205
1159
  case 0:
1206
1160
  usedThirdParam = false;
1207
1161
  if (!(forwardedXcm.length > 0)) {
1208
- _context12.n = 6;
1162
+ _context10.n = 6;
1209
1163
  break;
1210
1164
  }
1211
1165
  baseArgs = [forwardedXcm[0], forwardedXcm[1][0]];
1212
- _context12.p = 1;
1213
- _context12.n = 2;
1166
+ _context10.p = 1;
1167
+ _context10.n = 2;
1214
1168
  return (_this$api$call$xcmPay = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay, baseArgs);
1215
1169
  case 2:
1216
- deliveryFeeRes = _context12.v;
1217
- _context12.n = 6;
1170
+ deliveryFeeRes = _context10.v;
1171
+ _context10.n = 6;
1218
1172
  break;
1219
1173
  case 3:
1220
- _context12.p = 3;
1221
- _t6 = _context12.v;
1174
+ _context10.p = 3;
1175
+ _t6 = _context10.v;
1222
1176
  message = _t6 instanceof Error ? _t6.message : String(_t6);
1223
1177
  if (!message.includes('Expected 3 arguments')) {
1224
- _context12.n = 5;
1178
+ _context10.n = 5;
1225
1179
  break;
1226
1180
  }
1227
1181
  usedThirdParam = true;
1228
1182
  assetId = createAssetId(version, assetLocalizedLoc);
1229
1183
  versionedAssetLoc = addXcmVersionHeader(assetId, version);
1230
- _context12.n = 4;
1184
+ _context10.n = 4;
1231
1185
  return (_this$api$call$xcmPay2 = this.api.call.xcmPaymentApi).queryDeliveryFees.apply(_this$api$call$xcmPay2, baseArgs.concat([versionedAssetLoc]));
1232
1186
  case 4:
1233
- deliveryFeeRes = _context12.v;
1234
- _context12.n = 6;
1187
+ deliveryFeeRes = _context10.v;
1188
+ _context10.n = 6;
1235
1189
  break;
1236
1190
  case 5:
1237
1191
  throw _t6;
@@ -1240,25 +1194,29 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1240
1194
  deliveryFeeResolved = deliveryFeeRes && ((_ref9 = (_deliveryFeeResJson$o = (_deliveryFeeResJson$o2 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o2 === void 0 ? void 0 : _deliveryFeeResJson$o2.v4) !== null && _deliveryFeeResJson$o !== void 0 ? _deliveryFeeResJson$o : (_deliveryFeeResJson$o3 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o3 === void 0 ? void 0 : _deliveryFeeResJson$o3.v3) === null || _ref9 === void 0 ? void 0 : _ref9.length) > 0 ? BigInt((_ref0 = (_deliveryFeeResJson$o4 = deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o5 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o5 === void 0 ? void 0 : _deliveryFeeResJson$o5.v4) !== null && _deliveryFeeResJson$o4 !== void 0 ? _deliveryFeeResJson$o4 : deliveryFeeResJson === null || deliveryFeeResJson === void 0 || (_deliveryFeeResJson$o6 = deliveryFeeResJson.ok) === null || _deliveryFeeResJson$o6 === void 0 ? void 0 : _deliveryFeeResJson$o6.v3) === null || _ref0 === void 0 || (_ref0 = _ref0[0]) === null || _ref0 === void 0 || (_ref0 = _ref0.fun) === null || _ref0 === void 0 ? void 0 : _ref0.fungible) : 0n;
1241
1195
  nativeAsset = findNativeAssetInfoOrThrow(chain);
1242
1196
  if (!(isAssetXcEqual(asset, nativeAsset) || usedThirdParam)) {
1243
- _context12.n = 7;
1197
+ _context10.n = 7;
1244
1198
  break;
1245
1199
  }
1246
- return _context12.a(2, deliveryFeeResolved);
1200
+ return _context10.a(2, deliveryFeeResolved);
1247
1201
  case 7:
1248
- _context12.p = 7;
1249
- _context12.n = 8;
1250
- return this.quoteAhPrice(localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false);
1202
+ _context10.p = 7;
1203
+ _context10.n = 8;
1204
+ return this.queryRuntimeApi({
1205
+ module: 'AssetConversionApi',
1206
+ method: 'quote_price_exact_tokens_for_tokens',
1207
+ params: [localizeLocation(chain, nativeAsset.location), assetLocalizedLoc, deliveryFeeResolved, false]
1208
+ });
1251
1209
  case 8:
1252
- res = _context12.v;
1253
- return _context12.a(2, res !== null && res !== void 0 ? res : 0n);
1210
+ res = _context10.v;
1211
+ return _context10.a(2, res != null ? BigInt(res) : 0n);
1254
1212
  case 9:
1255
- _context12.p = 9;
1256
- _context12.v;
1257
- return _context12.a(2, 0n);
1213
+ _context10.p = 9;
1214
+ _context10.v;
1215
+ return _context10.a(2, 0n);
1258
1216
  }
1259
- }, _callee12, this, [[7, 9], [1, 3]]);
1217
+ }, _callee10, this, [[7, 9], [1, 3]]);
1260
1218
  }));
1261
- function getDeliveryFee(_x21, _x22, _x23, _x24, _x25) {
1219
+ function getDeliveryFee(_x17, _x18, _x19, _x20, _x21) {
1262
1220
  return _getDeliveryFee.apply(this, arguments);
1263
1221
  }
1264
1222
  return getDeliveryFee;
@@ -1266,45 +1224,49 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1266
1224
  }, {
1267
1225
  key: "getBridgeHubFallbackExecFee",
1268
1226
  value: function () {
1269
- var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(chain, weightValue, asset, version) {
1227
+ var _getBridgeHubFallbackExecFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(chain, weightValue, asset, version) {
1270
1228
  var fallbackExecFeeRes, fallbackJson, fallbackOk, fallbackExecFee, ahApi, assetHubChain, ahLocalizedLoc, convertedExecFee;
1271
- return _regenerator().w(function (_context13) {
1272
- while (1) switch (_context13.n) {
1229
+ return _regenerator().w(function (_context11) {
1230
+ while (1) switch (_context11.n) {
1273
1231
  case 0:
1274
- _context13.n = 1;
1232
+ _context11.n = 1;
1275
1233
  return this.api.call.xcmPaymentApi.queryWeightToAssetFee(weightValue, addXcmVersionHeader(RELAY_LOCATION, version));
1276
1234
  case 1:
1277
- fallbackExecFeeRes = _context13.v;
1235
+ fallbackExecFeeRes = _context11.v;
1278
1236
  fallbackJson = fallbackExecFeeRes.toJSON();
1279
1237
  fallbackOk = fallbackJson === null || fallbackJson === void 0 ? void 0 : fallbackJson.ok;
1280
1238
  fallbackExecFee = typeof fallbackOk === 'string' || typeof fallbackOk === 'number' ? BigInt(fallbackOk) : undefined;
1281
1239
  if (!(fallbackExecFee === undefined)) {
1282
- _context13.n = 2;
1240
+ _context11.n = 2;
1283
1241
  break;
1284
1242
  }
1285
- return _context13.a(2, undefined);
1243
+ return _context11.a(2, undefined);
1286
1244
  case 2:
1287
1245
  ahApi = this.clone();
1288
1246
  assetHubChain = "AssetHub".concat(getRelayChainOf(chain));
1289
- _context13.n = 3;
1247
+ _context11.n = 3;
1290
1248
  return ahApi.init(assetHubChain);
1291
1249
  case 3:
1292
1250
  ahLocalizedLoc = localizeLocation(assetHubChain, asset.location);
1293
- _context13.n = 4;
1294
- return ahApi.quoteAhPrice(RELAY_LOCATION, ahLocalizedLoc, fallbackExecFee, false);
1251
+ _context11.n = 4;
1252
+ return ahApi.queryRuntimeApi({
1253
+ module: 'AssetConversionApi',
1254
+ method: 'quote_price_exact_tokens_for_tokens',
1255
+ params: [RELAY_LOCATION, ahLocalizedLoc, fallbackExecFee, false]
1256
+ });
1295
1257
  case 4:
1296
- convertedExecFee = _context13.v;
1297
- if (!(typeof convertedExecFee === 'bigint')) {
1298
- _context13.n = 5;
1258
+ convertedExecFee = _context11.v;
1259
+ if (!(convertedExecFee != null)) {
1260
+ _context11.n = 5;
1299
1261
  break;
1300
1262
  }
1301
- return _context13.a(2, convertedExecFee);
1263
+ return _context11.a(2, BigInt(convertedExecFee));
1302
1264
  case 5:
1303
- return _context13.a(2, undefined);
1265
+ return _context11.a(2, undefined);
1304
1266
  }
1305
- }, _callee13, this);
1267
+ }, _callee11, this);
1306
1268
  }));
1307
- function getBridgeHubFallbackExecFee(_x26, _x27, _x28, _x29) {
1269
+ function getBridgeHubFallbackExecFee(_x22, _x23, _x24, _x25) {
1308
1270
  return _getBridgeHubFallbackExecFee.apply(this, arguments);
1309
1271
  }
1310
1272
  return getBridgeHubFallbackExecFee;
@@ -1312,21 +1274,21 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1312
1274
  }, {
1313
1275
  key: "getXcmWeight",
1314
1276
  value: function () {
1315
- var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(xcm) {
1277
+ var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(xcm) {
1316
1278
  var result, resultJson;
1317
- return _regenerator().w(function (_context14) {
1318
- while (1) switch (_context14.n) {
1279
+ return _regenerator().w(function (_context12) {
1280
+ while (1) switch (_context12.n) {
1319
1281
  case 0:
1320
- _context14.n = 1;
1282
+ _context12.n = 1;
1321
1283
  return this.api.call.xcmPaymentApi.queryXcmWeight(xcm);
1322
1284
  case 1:
1323
- result = _context14.v;
1285
+ result = _context12.v;
1324
1286
  resultJson = result.toJSON();
1325
- return _context14.a(2, resultJson.ok);
1287
+ return _context12.a(2, resultJson.ok);
1326
1288
  }
1327
- }, _callee14, this);
1289
+ }, _callee12, this);
1328
1290
  }));
1329
- function getXcmWeight(_x30) {
1291
+ function getXcmWeight(_x26) {
1330
1292
  return _getXcmWeight.apply(this, arguments);
1331
1293
  }
1332
1294
  return getXcmWeight;
@@ -1334,34 +1296,35 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1334
1296
  }, {
1335
1297
  key: "getDryRunXcm",
1336
1298
  value: function () {
1337
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(_ref1) {
1299
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(_ref1) {
1338
1300
  var _ref11, _ref12, _ref13;
1339
- var originLocation, xcm, asset, chain, version, origin, supportsDryRunApi, response, result, resultJson, isSuccess, error, failureReason, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
1340
- return _regenerator().w(function (_context15) {
1341
- while (1) switch (_context15.n) {
1301
+ var originLocation, xcm, asset, chain, version, origin, supportsDryRunApi, response, result, resultJson, isSuccess, _result$Ok, _execRes$Incomplete$e, _execRes$Incomplete, _execRes$Error, execRes, error, failureReason, forwardedXcms, actualWeight, weight, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, feeEvent, feeAmount, fee;
1302
+ return _regenerator().w(function (_context13) {
1303
+ while (1) switch (_context13.n) {
1342
1304
  case 0:
1343
1305
  originLocation = _ref1.originLocation, xcm = _ref1.xcm, asset = _ref1.asset, chain = _ref1.chain, version = _ref1.version, origin = _ref1.origin;
1344
1306
  supportsDryRunApi = getAssetsObject(chain).supportsDryRunApi;
1345
1307
  if (supportsDryRunApi) {
1346
- _context15.n = 1;
1308
+ _context13.n = 1;
1347
1309
  break;
1348
1310
  }
1349
1311
  throw new RuntimeApiUnavailableError(chain, 'DryRunApi');
1350
1312
  case 1:
1351
- _context15.n = 2;
1313
+ _context13.n = 2;
1352
1314
  return this.api.call.dryRunApi.dryRunXcm(originLocation, xcm);
1353
1315
  case 2:
1354
- response = _context15.v;
1316
+ response = _context13.v;
1355
1317
  result = response.toHuman();
1356
1318
  resultJson = response.toJSON();
1357
1319
  isSuccess = result.Ok && result.Ok.executionResult.Complete;
1358
1320
  if (isSuccess) {
1359
- _context15.n = 3;
1321
+ _context13.n = 3;
1360
1322
  break;
1361
1323
  }
1362
- error = result.Ok.executionResult.Incomplete.error;
1324
+ execRes = (_result$Ok = result.Ok) === null || _result$Ok === void 0 ? void 0 : _result$Ok.executionResult;
1325
+ error = (_execRes$Incomplete$e = execRes === null || execRes === void 0 || (_execRes$Incomplete = execRes.Incomplete) === null || _execRes$Incomplete === void 0 ? void 0 : _execRes$Incomplete.error) !== null && _execRes$Incomplete$e !== void 0 ? _execRes$Incomplete$e : execRes === null || execRes === void 0 || (_execRes$Error = execRes.Error) === null || _execRes$Error === void 0 ? void 0 : _execRes$Error.error;
1363
1326
  failureReason = typeof error === 'string' ? error : error.error;
1364
- return _context15.a(2, {
1327
+ return _context13.a(2, {
1365
1328
  success: false,
1366
1329
  failureReason: failureReason,
1367
1330
  asset: asset
@@ -1377,18 +1340,18 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1377
1340
  return i.Here ? 0 : (_ref10 = Array.isArray(i.x1) ? i.x1[0] : i.x1) === null || _ref10 === void 0 ? void 0 : _ref10.parachain;
1378
1341
  }(Object.values(forwardedXcms[0])[0].interior);
1379
1342
  if (!(hasXcmPaymentApiSupport(chain) && asset)) {
1380
- _context15.n = 5;
1343
+ _context13.n = 5;
1381
1344
  break;
1382
1345
  }
1383
- _context15.n = 4;
1346
+ _context13.n = 4;
1384
1347
  return this.getXcmPaymentApiFee(chain, xcm, forwardedXcms, asset, version);
1385
1348
  case 4:
1386
- _fee = _context15.v;
1349
+ _fee = _context13.v;
1387
1350
  if (!(typeof _fee === 'bigint')) {
1388
- _context15.n = 5;
1351
+ _context13.n = 5;
1389
1352
  break;
1390
1353
  }
1391
- return _context15.a(2, {
1354
+ return _context13.a(2, {
1392
1355
  success: true,
1393
1356
  fee: _fee,
1394
1357
  asset: asset,
@@ -1414,10 +1377,10 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1414
1377
  return ['currencies', 'tokens'].includes(event.section) && event.method === 'Deposited';
1415
1378
  });
1416
1379
  if (feeEvent) {
1417
- _context15.n = 6;
1380
+ _context13.n = 6;
1418
1381
  break;
1419
1382
  }
1420
- return _context15.a(2, Promise.resolve({
1383
+ return _context13.a(2, Promise.resolve({
1421
1384
  success: false,
1422
1385
  failureReason: 'Cannot determine destination fee. No Issued event found',
1423
1386
  asset: asset
@@ -1425,7 +1388,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1425
1388
  case 6:
1426
1389
  feeAmount = feeEvent.section === 'assetConversion' ? feeEvent.data.amountIn : feeEvent.data.amount;
1427
1390
  fee = BigInt(feeAmount.replace(/,/g, ''));
1428
- return _context15.a(2, {
1391
+ return _context13.a(2, {
1429
1392
  success: true,
1430
1393
  fee: fee,
1431
1394
  asset: asset,
@@ -1434,9 +1397,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1434
1397
  destParaId: destParaId
1435
1398
  });
1436
1399
  }
1437
- }, _callee15, this);
1400
+ }, _callee13, this);
1438
1401
  }));
1439
- function getDryRunXcm(_x31) {
1402
+ function getDryRunXcm(_x27) {
1440
1403
  return _getDryRunXcm.apply(this, arguments);
1441
1404
  }
1442
1405
  return getDryRunXcm;
@@ -1444,18 +1407,18 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1444
1407
  }, {
1445
1408
  key: "getBridgeStatus",
1446
1409
  value: function () {
1447
- var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16() {
1410
+ var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14() {
1448
1411
  var outboundOperatingMode;
1449
- return _regenerator().w(function (_context16) {
1450
- while (1) switch (_context16.n) {
1412
+ return _regenerator().w(function (_context14) {
1413
+ while (1) switch (_context14.n) {
1451
1414
  case 0:
1452
- _context16.n = 1;
1415
+ _context14.n = 1;
1453
1416
  return this.api.query.ethereumOutboundQueue.operatingMode();
1454
1417
  case 1:
1455
- outboundOperatingMode = _context16.v;
1456
- return _context16.a(2, outboundOperatingMode.toPrimitive());
1418
+ outboundOperatingMode = _context14.v;
1419
+ return _context14.a(2, outboundOperatingMode.toPrimitive());
1457
1420
  }
1458
- }, _callee16, this);
1421
+ }, _callee14, this);
1459
1422
  }));
1460
1423
  function getBridgeStatus() {
1461
1424
  return _getBridgeStatus.apply(this, arguments);
@@ -1506,35 +1469,35 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1506
1469
  }, {
1507
1470
  key: "signAndSubmit",
1508
1471
  value: function () {
1509
- var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(tx, sender) {
1472
+ var _signAndSubmit = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(tx, sender) {
1510
1473
  var hash, _t8;
1511
- return _regenerator().w(function (_context17) {
1512
- while (1) switch (_context17.n) {
1474
+ return _regenerator().w(function (_context15) {
1475
+ while (1) switch (_context15.n) {
1513
1476
  case 0:
1514
1477
  if (!isSenderSigner(sender)) {
1515
- _context17.n = 2;
1478
+ _context15.n = 2;
1516
1479
  break;
1517
1480
  }
1518
- _context17.n = 1;
1481
+ _context15.n = 1;
1519
1482
  return tx.signAndSend(sender.address, {
1520
1483
  signer: sender.signer
1521
1484
  });
1522
1485
  case 1:
1523
- _t8 = _context17.v;
1524
- _context17.n = 4;
1486
+ _t8 = _context15.v;
1487
+ _context15.n = 4;
1525
1488
  break;
1526
1489
  case 2:
1527
- _context17.n = 3;
1490
+ _context15.n = 3;
1528
1491
  return tx.signAndSend(createKeyringPair(sender));
1529
1492
  case 3:
1530
- _t8 = _context17.v;
1493
+ _t8 = _context15.v;
1531
1494
  case 4:
1532
1495
  hash = _t8;
1533
- return _context17.a(2, hash.toHex());
1496
+ return _context15.a(2, hash.toHex());
1534
1497
  }
1535
- }, _callee17);
1498
+ }, _callee15);
1536
1499
  }));
1537
- function signAndSubmit(_x32, _x33) {
1500
+ function signAndSubmit(_x28, _x29) {
1538
1501
  return _signAndSubmit.apply(this, arguments);
1539
1502
  }
1540
1503
  return signAndSubmit;
@@ -1542,27 +1505,27 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1542
1505
  }, {
1543
1506
  key: "signAndSubmitFinalized",
1544
1507
  value: function () {
1545
- var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(tx, sender) {
1546
- var _this4 = this;
1547
- return _regenerator().w(function (_context18) {
1548
- while (1) switch (_context18.n) {
1508
+ var _signAndSubmitFinalized = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(tx, sender) {
1509
+ var _this3 = this;
1510
+ return _regenerator().w(function (_context16) {
1511
+ while (1) switch (_context16.n) {
1549
1512
  case 0:
1550
1513
  if (!isSenderSigner(sender)) {
1551
- _context18.n = 2;
1514
+ _context16.n = 2;
1552
1515
  break;
1553
1516
  }
1554
- _context18.n = 1;
1517
+ _context16.n = 1;
1555
1518
  return tx.signAsync(sender.address, {
1556
1519
  signer: sender.signer
1557
1520
  });
1558
1521
  case 1:
1559
- _context18.n = 3;
1522
+ _context16.n = 3;
1560
1523
  break;
1561
1524
  case 2:
1562
- _context18.n = 3;
1525
+ _context16.n = 3;
1563
1526
  return tx.signAsync(createKeyringPair(sender));
1564
1527
  case 3:
1565
- return _context18.a(2, new Promise(function (resolve, reject) {
1528
+ return _context16.a(2, new Promise(function (resolve, reject) {
1566
1529
  tx.send(function (_ref14) {
1567
1530
  var status = _ref14.status,
1568
1531
  dispatchError = _ref14.dispatchError,
@@ -1570,7 +1533,7 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1570
1533
  if (status.isFinalized) {
1571
1534
  if (dispatchError !== undefined) {
1572
1535
  if (dispatchError.isModule) {
1573
- var decoded = _this4.api.registry.findMetaError(dispatchError.asModule);
1536
+ var decoded = _this3.api.registry.findMetaError(dispatchError.asModule);
1574
1537
  var docs = decoded.docs,
1575
1538
  name = decoded.name,
1576
1539
  section = decoded.section;
@@ -1587,9 +1550,9 @@ var PolkadotJsApi = /*#__PURE__*/function (_PolkadotApi) {
1587
1550
  });
1588
1551
  }));
1589
1552
  }
1590
- }, _callee18);
1553
+ }, _callee16);
1591
1554
  }));
1592
- function signAndSubmitFinalized(_x34, _x35) {
1555
+ function signAndSubmitFinalized(_x30, _x31) {
1593
1556
  return _signAndSubmitFinalized.apply(this, arguments);
1594
1557
  }
1595
1558
  return signAndSubmitFinalized;
@@ -1726,9 +1689,8 @@ var depositToken = /*#__PURE__*/function () {
1726
1689
  };
1727
1690
  }();
1728
1691
 
1729
- var createContext = function createContext(executionUrl, env) {
1730
- var isStringProvider = typeof executionUrl === 'string';
1731
- var context = new Context(_objectSpread2(_objectSpread2({}, env), {}, {
1692
+ var createEnvironment = function createEnvironment(env, executionUrl) {
1693
+ return _objectSpread2(_objectSpread2({}, env), {}, {
1732
1694
  assetOverrides: {
1733
1695
  '3369': [{
1734
1696
  token: '0xba41ddf06b7ffd89d1267b5a93bfef2424eb2003',
@@ -1742,10 +1704,8 @@ var createContext = function createContext(executionUrl, env) {
1742
1704
  precompiles: {
1743
1705
  '2004': '0x000000000000000000000000000000000000081A'
1744
1706
  },
1745
- ethereumChains: _objectSpread2(_objectSpread2({}, isStringProvider ? _defineProperty({}, env.ethChainId.toString(), executionUrl) : {}), {}, _defineProperty({}, getParaId('Moonbeam'), 'https://rpc.api.moonbeam.network'))
1746
- }));
1747
- if (!isStringProvider) context.setEthProvider(env.ethChainId, executionUrl);
1748
- return context;
1707
+ ethereumChains: _objectSpread2(_objectSpread2(_objectSpread2({}, env.ethereumChains), executionUrl !== undefined ? _defineProperty({}, env.ethChainId.toString(), executionUrl) : {}), {}, _defineProperty({}, getParaId('Moonbeam'), 'https://rpc.api.moonbeam.network'))
1708
+ });
1749
1709
  };
1750
1710
 
1751
1711
  /**
@@ -1760,7 +1720,7 @@ var createContext = function createContext(executionUrl, env) {
1760
1720
  */
1761
1721
  var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1762
1722
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
1763
- var api, provider, signer, recipient, to, currency, ethAsset, amount, _bridgeInfoFor, environment, registry, context, destParaId, fee, sourceAddress, transfer, validation, tx, response, receipt, messageReceipt, _t, _t2, _t3, _t4, _t5, _t6, _t7, _t8, _t9, _t0, _t1;
1723
+ var api, provider, signer, recipient, to, currency, ethAsset, amount, info, environment, snowbridgeApi, destParaId, sender, sourceAddress, fee, transfer, validated, response, receipt, messageReceipt;
1764
1724
  return _regenerator().w(function (_context) {
1765
1725
  while (1) switch (_context.n) {
1766
1726
  case 0:
@@ -1791,108 +1751,78 @@ var transferEthToPolkadot$1 = /*#__PURE__*/function () {
1791
1751
  case 4:
1792
1752
  ethAsset = findAssetInfoOrThrow('Ethereum', currency, to);
1793
1753
  amount = abstractDecimals(currency.amount, ethAsset.decimals, api);
1794
- _bridgeInfoFor = bridgeInfoFor('polkadot_mainnet'), environment = _bridgeInfoFor.environment, registry = _bridgeInfoFor.registry;
1795
- context = createContext(provider, environment);
1754
+ info = bridgeInfoFor('polkadot_mainnet');
1755
+ environment = createEnvironment(info.environment, typeof provider === 'string' ? provider : undefined);
1756
+ snowbridgeApi = new SnowbridgeApi({
1757
+ info: _objectSpread2(_objectSpread2({}, info), {}, {
1758
+ environment: environment
1759
+ }),
1760
+ ethereumProvider: new EthersEthereumProvider()
1761
+ });
1762
+ if (typeof provider !== 'string') {
1763
+ snowbridgeApi.context.setEthProvider(environment.ethChainId, provider);
1764
+ }
1796
1765
  destParaId = getParaId(to);
1797
1766
  assertHasId(ethAsset);
1798
- _t = toPolkadotV2;
1799
- _t2 = context.gateway();
1767
+ sender = snowbridgeApi.sender({
1768
+ kind: 'ethereum',
1769
+ id: environment.ethChainId
1770
+ }, {
1771
+ kind: 'polkadot',
1772
+ id: destParaId
1773
+ });
1800
1774
  _context.n = 5;
1801
- return context.assetHub();
1775
+ return signer.getAddress();
1802
1776
  case 5:
1803
- _t3 = _context.v;
1777
+ sourceAddress = _context.v;
1804
1778
  _context.n = 6;
1805
- return context.parachain(destParaId);
1779
+ return sender.fee(ethAsset.assetId);
1806
1780
  case 6:
1807
- _t4 = _context.v;
1781
+ fee = _context.v;
1808
1782
  _context.n = 7;
1809
- return _t.getDeliveryFee.call(_t, {
1810
- gateway: _t2,
1811
- assetHub: _t3,
1812
- destination: _t4
1813
- }, registry, ethAsset.assetId, destParaId);
1783
+ return sender.tx(sourceAddress, recipient, ethAsset.assetId, amount, fee);
1814
1784
  case 7:
1815
- fee = _context.v;
1785
+ transfer = _context.v;
1816
1786
  _context.n = 8;
1817
- return signer.getAddress();
1787
+ return sender.validate(transfer);
1818
1788
  case 8:
1819
- sourceAddress = _context.v;
1820
- _context.n = 9;
1821
- return toPolkadotV2.createTransfer(registry, sourceAddress, recipient, ethAsset.assetId, destParaId, amount, fee);
1822
- case 9:
1823
- transfer = _context.v;
1824
- _t5 = toPolkadotV2;
1825
- _t6 = context.ethereum();
1826
- _t7 = context.gateway();
1827
- _context.n = 10;
1828
- return context.bridgeHub();
1829
- case 10:
1830
- _t8 = _context.v;
1831
- _context.n = 11;
1832
- return context.assetHub();
1833
- case 11:
1834
- _t9 = _context.v;
1835
- if (!(destParaId !== getParaId('AssetHubPolkadot'))) {
1836
- _context.n = 13;
1837
- break;
1838
- }
1839
- _context.n = 12;
1840
- return context.parachain(destParaId);
1841
- case 12:
1842
- _t0 = _context.v;
1843
- _context.n = 14;
1844
- break;
1845
- case 13:
1846
- _t0 = undefined;
1847
- case 14:
1848
- _t1 = _t0;
1849
- _context.n = 15;
1850
- return _t5.validateTransfer.call(_t5, {
1851
- ethereum: _t6,
1852
- gateway: _t7,
1853
- bridgeHub: _t8,
1854
- assetHub: _t9,
1855
- destParachain: _t1
1856
- }, transfer);
1857
- case 15:
1858
- validation = _context.v;
1859
- if (!validation.logs.find(function (l) {
1860
- return l.kind == toPolkadotV2.ValidationKind.Error;
1789
+ validated = _context.v;
1790
+ if (!validated.logs.find(function (l) {
1791
+ return l.kind === toPolkadotV2.ValidationKind.Error;
1861
1792
  })) {
1862
- _context.n = 16;
1793
+ _context.n = 9;
1863
1794
  break;
1864
1795
  }
1865
- throw new RoutingResolutionError("Validation failed with following errors: \n\n ".concat(validation.logs.filter(function (l) {
1866
- return l.kind == toPolkadotV2.ValidationKind.Error;
1796
+ throw new RoutingResolutionError("Validation failed with following errors: \n\n ".concat(validated.logs.filter(function (l) {
1797
+ return l.kind === toPolkadotV2.ValidationKind.Error;
1867
1798
  }).map(function (l) {
1868
1799
  return l.message;
1869
1800
  }).join('\n\n')));
1870
- case 16:
1871
- tx = transfer.tx;
1872
- _context.n = 17;
1873
- return signer.sendTransaction(tx);
1874
- case 17:
1801
+ case 9:
1802
+ _context.n = 10;
1803
+ return signer.sendTransaction(transfer.tx);
1804
+ case 10:
1875
1805
  response = _context.v;
1876
- _context.n = 18;
1806
+ _context.n = 11;
1877
1807
  return response.wait(1);
1878
- case 18:
1808
+ case 11:
1879
1809
  receipt = _context.v;
1880
1810
  if (receipt) {
1881
- _context.n = 19;
1811
+ _context.n = 12;
1882
1812
  break;
1883
1813
  }
1884
1814
  throw new RoutingResolutionError("Transaction ".concat(response.hash, " not included."));
1885
- case 19:
1886
- _context.n = 20;
1887
- return toPolkadotV2.getMessageReceipt(receipt);
1888
- case 20:
1815
+ case 12:
1816
+ _context.n = 13;
1817
+ return sender.messageId(receipt);
1818
+ case 13:
1889
1819
  messageReceipt = _context.v;
1890
1820
  if (messageReceipt) {
1891
- _context.n = 21;
1821
+ _context.n = 14;
1892
1822
  break;
1893
1823
  }
1894
1824
  throw new RoutingResolutionError("Transaction ".concat(receipt.hash, " did not emit a message."));
1895
- case 21:
1825
+ case 14:
1896
1826
  return _context.a(2, {
1897
1827
  response: response,
1898
1828
  messageReceipt: messageReceipt
@@ -1931,6 +1861,8 @@ var getTokenBalance = /*#__PURE__*/function () {
1931
1861
 
1932
1862
  /**
1933
1863
  * Builder class for constructing transfers from Ethereum to Polkadot.
1864
+ *
1865
+ * @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
1934
1866
  */
1935
1867
  var EvmBuilderCore = /*#__PURE__*/function () {
1936
1868
  function EvmBuilderCore(options) {
@@ -2075,6 +2007,7 @@ var EvmBuilderCore = /*#__PURE__*/function () {
2075
2007
  *
2076
2008
  * @param provider - The Ethereum provider to use for the transfer.
2077
2009
  * @returns An instance of EvmBuilder class
2010
+ * @deprecated EvmBuilder is deprecated. Please use the Builder class instead.
2078
2011
  */
2079
2012
  var EvmBuilder$1 = function EvmBuilder(api, provider) {
2080
2013
  return new EvmBuilderCore({
@@ -2093,6 +2026,7 @@ var Builder = function Builder(api) {
2093
2026
  var pjsApi = new PolkadotJsApi(api);
2094
2027
  return Builder$1(pjsApi);
2095
2028
  };
2029
+ /** @deprecated EvmBuilder is deprecated. Please use the Builder class instead. */
2096
2030
  var EvmBuilder = function EvmBuilder(provider, api) {
2097
2031
  var pjsApi = new PolkadotJsApi(api);
2098
2032
  return EvmBuilder$1(pjsApi, provider);