@paraspell/sdk 10.10.11 → 10.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -548,7 +548,7 @@ function createClientCache(maxSize, onEviction) {
548
548
  // Call rpc.properties to keep the connection alive
549
549
  void _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
550
550
  return _regenerator().w(function (_context) {
551
- while (1) switch (_context.n) {
551
+ while (1) switch (_context.p = _context.n) {
552
552
  case 0:
553
553
  _context.p = 0;
554
554
  _context.n = 1;
@@ -785,21 +785,17 @@ var isHex = function isHex(str) {
785
785
  return typeof str === 'string' && /^0x[0-9a-fA-F]+$/.test(str);
786
786
  };
787
787
  var PapiApi = /*#__PURE__*/function () {
788
- function PapiApi() {
788
+ function PapiApi(config) {
789
789
  _classCallCheck(this, PapiApi);
790
790
  this._ttlMs = DEFAULT_TTL_MS;
791
791
  this.initialized = false;
792
792
  this.disconnectAllowed = true;
793
+ this._config = config;
793
794
  }
794
795
  return _createClass(PapiApi, [{
795
- key: "setApi",
796
- value: function setApi(api) {
797
- this._api = api;
798
- }
799
- }, {
800
- key: "getApiOrUrl",
801
- value: function getApiOrUrl() {
802
- return this._api;
796
+ key: "getConfig",
797
+ value: function getConfig() {
798
+ return this._config;
803
799
  }
804
800
  }, {
805
801
  key: "getApi",
@@ -809,57 +805,41 @@ var PapiApi = /*#__PURE__*/function () {
809
805
  }, {
810
806
  key: "init",
811
807
  value: function () {
812
- var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(node) {
808
+ var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(chain) {
813
809
  var clientTtlMs,
814
- _this$_api,
815
- _args3 = arguments,
816
- _t3;
810
+ apiConfig,
811
+ _args3 = arguments;
817
812
  return _regenerator().w(function (_context3) {
818
813
  while (1) switch (_context3.n) {
819
814
  case 0:
820
815
  clientTtlMs = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : DEFAULT_TTL_MS;
821
- if (!(this.initialized || node === 'Ethereum')) {
816
+ if (!(this.initialized || chain === 'Ethereum')) {
822
817
  _context3.n = 1;
823
818
  break;
824
819
  }
825
820
  return _context3.a(2);
826
821
  case 1:
827
- if (!unsupportedNodes.includes(node)) {
822
+ if (!unsupportedNodes.includes(chain)) {
828
823
  _context3.n = 2;
829
824
  break;
830
825
  }
831
- throw new sdkCore.NodeNotSupportedError("The node ".concat(node, " is not yet supported by the Polkadot API."));
826
+ throw new sdkCore.NodeNotSupportedError("The node ".concat(chain, " is not yet supported by the Polkadot API."));
832
827
  case 2:
833
828
  this._ttlMs = clientTtlMs;
834
- if (!(typeof this._api === 'string' || this._api instanceof Array)) {
835
- _context3.n = 4;
829
+ this._node = chain;
830
+ apiConfig = this.getApiConfigForChain(chain); // For development mode, api for each used chain must be provided
831
+ if (!(sdkCore.isConfig(this._config) && this._config.development && !apiConfig)) {
832
+ _context3.n = 3;
836
833
  break;
837
834
  }
838
- _context3.n = 3;
839
- return this.createApiInstance(this._api);
835
+ throw new sdkCore.MissingChainApiError(chain);
840
836
  case 3:
841
- this.api = _context3.v;
842
- _context3.n = 8;
843
- break;
837
+ _context3.n = 4;
838
+ return this.resolveApi(apiConfig, chain);
844
839
  case 4:
845
- if (!((_this$_api = this._api) !== null && _this$_api !== void 0)) {
846
- _context3.n = 5;
847
- break;
848
- }
849
- _t3 = _this$_api;
850
- _context3.n = 7;
851
- break;
852
- case 5:
853
- _context3.n = 6;
854
- return sdkCore.createApiInstanceForNode(this, node);
855
- case 6:
856
- _t3 = _context3.v;
857
- case 7:
858
- this.api = _t3;
859
- case 8:
860
- this._node = node;
840
+ this.api = _context3.v;
861
841
  this.initialized = true;
862
- case 9:
842
+ case 5:
863
843
  return _context3.a(2);
864
844
  }
865
845
  }, _callee3, this);
@@ -870,17 +850,54 @@ var PapiApi = /*#__PURE__*/function () {
870
850
  return init;
871
851
  }()
872
852
  }, {
873
- key: "createApiInstance",
853
+ key: "getApiConfigForChain",
854
+ value: function getApiConfigForChain(chain) {
855
+ if (sdkCore.isConfig(this._config)) {
856
+ var _this$_config$apiOver;
857
+ return (_this$_config$apiOver = this._config.apiOverrides) === null || _this$_config$apiOver === void 0 ? void 0 : _this$_config$apiOver[chain];
858
+ }
859
+ return this._config;
860
+ }
861
+ }, {
862
+ key: "resolveApi",
874
863
  value: function () {
875
- var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(wsUrl) {
864
+ var _resolveApi = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(apiConfig, chain) {
876
865
  return _regenerator().w(function (_context4) {
877
866
  while (1) switch (_context4.n) {
878
867
  case 0:
879
- return _context4.a(2, leasePolkadotClient(wsUrl, this._ttlMs));
868
+ if (apiConfig) {
869
+ _context4.n = 1;
870
+ break;
871
+ }
872
+ return _context4.a(2, sdkCore.createApiInstanceForNode(this, chain));
873
+ case 1:
874
+ if (!(typeof apiConfig === 'string' || apiConfig instanceof Array)) {
875
+ _context4.n = 2;
876
+ break;
877
+ }
878
+ return _context4.a(2, this.createApiInstance(apiConfig));
879
+ case 2:
880
+ return _context4.a(2, apiConfig);
880
881
  }
881
882
  }, _callee4, this);
882
883
  }));
883
- function createApiInstance(_x5) {
884
+ function resolveApi(_x5, _x6) {
885
+ return _resolveApi.apply(this, arguments);
886
+ }
887
+ return resolveApi;
888
+ }()
889
+ }, {
890
+ key: "createApiInstance",
891
+ value: function () {
892
+ var _createApiInstance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(wsUrl) {
893
+ return _regenerator().w(function (_context5) {
894
+ while (1) switch (_context5.n) {
895
+ case 0:
896
+ return _context5.a(2, leasePolkadotClient(wsUrl, this._ttlMs));
897
+ }
898
+ }, _callee5, this);
899
+ }));
900
+ function createApiInstance(_x7) {
884
901
  return _createApiInstance.apply(this, arguments);
885
902
  }
886
903
  return createApiInstance;
@@ -924,10 +941,10 @@ var PapiApi = /*#__PURE__*/function () {
924
941
  }, {
925
942
  key: "objectToHex",
926
943
  value: function () {
927
- var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(obj) {
944
+ var _objectToHex = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(obj) {
928
945
  var transformedObj, tx, removeFirst5Bytes, encodedData;
929
- return _regenerator().w(function (_context5) {
930
- while (1) switch (_context5.n) {
946
+ return _regenerator().w(function (_context6) {
947
+ while (1) switch (_context6.n) {
931
948
  case 0:
932
949
  transformedObj = _transform(obj);
933
950
  tx = this.api.getUnsafeApi().tx.PolkadotXcm.send({
@@ -945,15 +962,15 @@ var PapiApi = /*#__PURE__*/function () {
945
962
  removeFirst5Bytes = function removeFirst5Bytes(hexString) {
946
963
  return '0x' + hexString.slice(12);
947
964
  };
948
- _context5.n = 1;
965
+ _context6.n = 1;
949
966
  return tx.getEncodedData();
950
967
  case 1:
951
- encodedData = _context5.v;
952
- return _context5.a(2, removeFirst5Bytes(encodedData.asHex()));
968
+ encodedData = _context6.v;
969
+ return _context6.a(2, removeFirst5Bytes(encodedData.asHex()));
953
970
  }
954
- }, _callee5, this);
971
+ }, _callee6, this);
955
972
  }));
956
- function objectToHex(_x6) {
973
+ function objectToHex(_x8) {
957
974
  return _objectToHex.apply(this, arguments);
958
975
  }
959
976
  return objectToHex;
@@ -983,15 +1000,15 @@ var PapiApi = /*#__PURE__*/function () {
983
1000
  }, {
984
1001
  key: "calculateTransactionFee",
985
1002
  value: function () {
986
- var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(tx, address) {
987
- return _regenerator().w(function (_context6) {
988
- while (1) switch (_context6.n) {
1003
+ var _calculateTransactionFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(tx, address) {
1004
+ return _regenerator().w(function (_context7) {
1005
+ while (1) switch (_context7.n) {
989
1006
  case 0:
990
- return _context6.a(2, tx.getEstimatedFees(address));
1007
+ return _context7.a(2, tx.getEstimatedFees(address));
991
1008
  }
992
- }, _callee6);
1009
+ }, _callee7);
993
1010
  }));
994
- function calculateTransactionFee(_x7, _x8) {
1011
+ function calculateTransactionFee(_x9, _x0) {
995
1012
  return _calculateTransactionFee.apply(this, arguments);
996
1013
  }
997
1014
  return calculateTransactionFee;
@@ -999,27 +1016,27 @@ var PapiApi = /*#__PURE__*/function () {
999
1016
  }, {
1000
1017
  key: "quoteAhPrice",
1001
1018
  value: function () {
1002
- var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(fromMl, toMl, amountIn) {
1019
+ var _quoteAhPrice = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(fromMl, toMl, amountIn) {
1003
1020
  var includeFee,
1004
1021
  transformedFromMl,
1005
1022
  transformedToMl,
1006
1023
  response,
1007
- _args7 = arguments;
1008
- return _regenerator().w(function (_context7) {
1009
- while (1) switch (_context7.n) {
1024
+ _args8 = arguments;
1025
+ return _regenerator().w(function (_context8) {
1026
+ while (1) switch (_context8.n) {
1010
1027
  case 0:
1011
- includeFee = _args7.length > 3 && _args7[3] !== undefined ? _args7[3] : true;
1028
+ includeFee = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : true;
1012
1029
  transformedFromMl = _transform(fromMl);
1013
1030
  transformedToMl = _transform(toMl);
1014
- _context7.n = 1;
1031
+ _context8.n = 1;
1015
1032
  return this.api.getUnsafeApi().apis.AssetConversionApi.quote_price_exact_tokens_for_tokens(transformedFromMl, transformedToMl, amountIn, includeFee);
1016
1033
  case 1:
1017
- response = _context7.v;
1018
- return _context7.a(2, response ? BigInt(response) : undefined);
1034
+ response = _context8.v;
1035
+ return _context8.a(2, response ? BigInt(response) : undefined);
1019
1036
  }
1020
- }, _callee7, this);
1037
+ }, _callee8, this);
1021
1038
  }));
1022
- function quoteAhPrice(_x9, _x0, _x1) {
1039
+ function quoteAhPrice(_x1, _x10, _x11) {
1023
1040
  return _quoteAhPrice.apply(this, arguments);
1024
1041
  }
1025
1042
  return quoteAhPrice;
@@ -1027,20 +1044,20 @@ var PapiApi = /*#__PURE__*/function () {
1027
1044
  }, {
1028
1045
  key: "getBalanceNative",
1029
1046
  value: function () {
1030
- var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(address) {
1047
+ var _getBalanceNative = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address) {
1031
1048
  var res;
1032
- return _regenerator().w(function (_context8) {
1033
- while (1) switch (_context8.n) {
1049
+ return _regenerator().w(function (_context9) {
1050
+ while (1) switch (_context9.n) {
1034
1051
  case 0:
1035
- _context8.n = 1;
1052
+ _context9.n = 1;
1036
1053
  return this.api.getUnsafeApi().query.System.Account.getValue(address);
1037
1054
  case 1:
1038
- res = _context8.v;
1039
- return _context8.a(2, res.data.free);
1055
+ res = _context9.v;
1056
+ return _context9.a(2, res.data.free);
1040
1057
  }
1041
- }, _callee8, this);
1058
+ }, _callee9, this);
1042
1059
  }));
1043
- function getBalanceNative(_x10) {
1060
+ function getBalanceNative(_x12) {
1044
1061
  return _getBalanceNative.apply(this, arguments);
1045
1062
  }
1046
1063
  return getBalanceNative;
@@ -1048,20 +1065,20 @@ var PapiApi = /*#__PURE__*/function () {
1048
1065
  }, {
1049
1066
  key: "getBalanceForeignPolkadotXcm",
1050
1067
  value: function () {
1051
- var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(address, id) {
1068
+ var _getBalanceForeignPolkadotXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address, id) {
1052
1069
  var res;
1053
- return _regenerator().w(function (_context9) {
1054
- while (1) switch (_context9.n) {
1070
+ return _regenerator().w(function (_context0) {
1071
+ while (1) switch (_context0.n) {
1055
1072
  case 0:
1056
- _context9.n = 1;
1073
+ _context0.n = 1;
1057
1074
  return this.api.getUnsafeApi().query.Assets.Account.getValue(id, address);
1058
1075
  case 1:
1059
- res = _context9.v;
1060
- return _context9.a(2, res && res.balance ? BigInt(res.balance) : 0n);
1076
+ res = _context0.v;
1077
+ return _context0.a(2, res && res.balance ? BigInt(res.balance) : 0n);
1061
1078
  }
1062
- }, _callee9, this);
1079
+ }, _callee0, this);
1063
1080
  }));
1064
- function getBalanceForeignPolkadotXcm(_x11, _x12) {
1081
+ function getBalanceForeignPolkadotXcm(_x13, _x14) {
1065
1082
  return _getBalanceForeignPolkadotXcm.apply(this, arguments);
1066
1083
  }
1067
1084
  return getBalanceForeignPolkadotXcm;
@@ -1069,20 +1086,20 @@ var PapiApi = /*#__PURE__*/function () {
1069
1086
  }, {
1070
1087
  key: "getMythosForeignBalance",
1071
1088
  value: function () {
1072
- var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(address) {
1089
+ var _getMythosForeignBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address) {
1073
1090
  var res;
1074
- return _regenerator().w(function (_context0) {
1075
- while (1) switch (_context0.n) {
1091
+ return _regenerator().w(function (_context1) {
1092
+ while (1) switch (_context1.n) {
1076
1093
  case 0:
1077
- _context0.n = 1;
1094
+ _context1.n = 1;
1078
1095
  return this.api.getUnsafeApi().query.Balances.Account.getValue(address);
1079
1096
  case 1:
1080
- res = _context0.v;
1081
- return _context0.a(2, res && res.free ? BigInt(res.free) : 0n);
1097
+ res = _context1.v;
1098
+ return _context1.a(2, res && res.free ? BigInt(res.free) : 0n);
1082
1099
  }
1083
- }, _callee0, this);
1100
+ }, _callee1, this);
1084
1101
  }));
1085
- function getMythosForeignBalance(_x13) {
1102
+ function getMythosForeignBalance(_x15) {
1086
1103
  return _getMythosForeignBalance.apply(this, arguments);
1087
1104
  }
1088
1105
  return getMythosForeignBalance;
@@ -1090,21 +1107,21 @@ var PapiApi = /*#__PURE__*/function () {
1090
1107
  }, {
1091
1108
  key: "getBalanceForeignAssetsPallet",
1092
1109
  value: function () {
1093
- var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(address, multiLocation) {
1110
+ var _getBalanceForeignAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(address, multiLocation) {
1094
1111
  var transformedMultiLocation, res;
1095
- return _regenerator().w(function (_context1) {
1096
- while (1) switch (_context1.n) {
1112
+ return _regenerator().w(function (_context10) {
1113
+ while (1) switch (_context10.n) {
1097
1114
  case 0:
1098
1115
  transformedMultiLocation = _transform(multiLocation);
1099
- _context1.n = 1;
1116
+ _context10.n = 1;
1100
1117
  return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(transformedMultiLocation, address);
1101
1118
  case 1:
1102
- res = _context1.v;
1103
- return _context1.a(2, BigInt(res === undefined ? 0 : res.balance));
1119
+ res = _context10.v;
1120
+ return _context10.a(2, BigInt(res === undefined ? 0 : res.balance));
1104
1121
  }
1105
- }, _callee1, this);
1122
+ }, _callee10, this);
1106
1123
  }));
1107
- function getBalanceForeignAssetsPallet(_x14, _x15) {
1124
+ function getBalanceForeignAssetsPallet(_x16, _x17) {
1108
1125
  return _getBalanceForeignAssetsPallet.apply(this, arguments);
1109
1126
  }
1110
1127
  return getBalanceForeignAssetsPallet;
@@ -1112,20 +1129,20 @@ var PapiApi = /*#__PURE__*/function () {
1112
1129
  }, {
1113
1130
  key: "getForeignAssetsByIdBalance",
1114
1131
  value: function () {
1115
- var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(address, assetId) {
1132
+ var _getForeignAssetsByIdBalance = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, assetId) {
1116
1133
  var res;
1117
- return _regenerator().w(function (_context10) {
1118
- while (1) switch (_context10.n) {
1134
+ return _regenerator().w(function (_context11) {
1135
+ while (1) switch (_context11.n) {
1119
1136
  case 0:
1120
- _context10.n = 1;
1137
+ _context11.n = 1;
1121
1138
  return this.api.getUnsafeApi().query.ForeignAssets.Account.getValue(assetId, address);
1122
1139
  case 1:
1123
- res = _context10.v;
1124
- return _context10.a(2, BigInt(res === undefined ? 0 : res.balance));
1140
+ res = _context11.v;
1141
+ return _context11.a(2, BigInt(res === undefined ? 0 : res.balance));
1125
1142
  }
1126
- }, _callee10, this);
1143
+ }, _callee11, this);
1127
1144
  }));
1128
- function getForeignAssetsByIdBalance(_x16, _x17) {
1145
+ function getForeignAssetsByIdBalance(_x18, _x19) {
1129
1146
  return _getForeignAssetsByIdBalance.apply(this, arguments);
1130
1147
  }
1131
1148
  return getForeignAssetsByIdBalance;
@@ -1133,23 +1150,23 @@ var PapiApi = /*#__PURE__*/function () {
1133
1150
  }, {
1134
1151
  key: "getBalanceForeignBifrost",
1135
1152
  value: function () {
1136
- var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11(address, asset) {
1153
+ var _getBalanceForeignBifrost = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(address, asset) {
1137
1154
  var currencySelection, transformedParameters, response, accountData;
1138
- return _regenerator().w(function (_context11) {
1139
- while (1) switch (_context11.n) {
1155
+ return _regenerator().w(function (_context12) {
1156
+ while (1) switch (_context12.n) {
1140
1157
  case 0:
1141
1158
  currencySelection = sdkCore.getNode('BifrostPolkadot').getCurrencySelection(asset);
1142
1159
  transformedParameters = _transform(currencySelection);
1143
- _context11.n = 1;
1160
+ _context12.n = 1;
1144
1161
  return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
1145
1162
  case 1:
1146
- response = _context11.v;
1163
+ response = _context12.v;
1147
1164
  accountData = response ? response : null;
1148
- return _context11.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
1165
+ return _context12.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
1149
1166
  }
1150
- }, _callee11, this);
1167
+ }, _callee12, this);
1151
1168
  }));
1152
- function getBalanceForeignBifrost(_x18, _x19) {
1169
+ function getBalanceForeignBifrost(_x20, _x21) {
1153
1170
  return _getBalanceForeignBifrost.apply(this, arguments);
1154
1171
  }
1155
1172
  return getBalanceForeignBifrost;
@@ -1157,24 +1174,24 @@ var PapiApi = /*#__PURE__*/function () {
1157
1174
  }, {
1158
1175
  key: "getBalanceNativeAcala",
1159
1176
  value: function () {
1160
- var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12(address, symbol) {
1177
+ var _getBalanceNativeAcala = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(address, symbol) {
1161
1178
  var transformedParameters, response, accountData;
1162
- return _regenerator().w(function (_context12) {
1163
- while (1) switch (_context12.n) {
1179
+ return _regenerator().w(function (_context13) {
1180
+ while (1) switch (_context13.n) {
1164
1181
  case 0:
1165
1182
  transformedParameters = _transform({
1166
1183
  Token: symbol
1167
1184
  });
1168
- _context12.n = 1;
1185
+ _context13.n = 1;
1169
1186
  return this.api.getUnsafeApi().query.Tokens.Accounts.getValue(address, transformedParameters);
1170
1187
  case 1:
1171
- response = _context12.v;
1188
+ response = _context13.v;
1172
1189
  accountData = response ? response : null;
1173
- return _context12.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
1190
+ return _context13.a(2, accountData ? BigInt(accountData.free.toString()) : 0n);
1174
1191
  }
1175
- }, _callee12, this);
1192
+ }, _callee13, this);
1176
1193
  }));
1177
- function getBalanceNativeAcala(_x20, _x21) {
1194
+ function getBalanceNativeAcala(_x22, _x23) {
1178
1195
  return _getBalanceNativeAcala.apply(this, arguments);
1179
1196
  }
1180
1197
  return getBalanceNativeAcala;
@@ -1182,19 +1199,30 @@ var PapiApi = /*#__PURE__*/function () {
1182
1199
  }, {
1183
1200
  key: "getBalanceForeignXTokens",
1184
1201
  value: function () {
1185
- var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(node, address, asset) {
1186
- var pallet, response, entry;
1187
- return _regenerator().w(function (_context13) {
1188
- while (1) switch (_context13.n) {
1202
+ var _getBalanceForeignXTokens = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(node, address, asset) {
1203
+ var pallet, currencyId, _response, response, entry;
1204
+ return _regenerator().w(function (_context14) {
1205
+ while (1) switch (_context14.n) {
1189
1206
  case 0:
1190
1207
  pallet = 'Tokens';
1191
1208
  if (node === 'Centrifuge' || node === 'Altair') {
1192
1209
  pallet = 'OrmlTokens';
1193
1210
  }
1194
- _context13.n = 1;
1195
- return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
1211
+ if (!(node === 'Hydration' && (asset.symbol === 'aUSDT' || asset.symbol === 'aUSDC' || asset.symbol === 'aDOT' || asset.symbol === 'atBTC' || asset.symbol === 'avDOT' || asset.symbol === 'aETH' || asset.symbol === 'aWBTC'))) {
1212
+ _context14.n = 2;
1213
+ break;
1214
+ }
1215
+ currencyId = asset.symbol === 'aUSDT' ? 1002 : asset.symbol === 'aUSDC' ? 1003 : asset.symbol === 'aDOT' ? 1001 : asset.symbol === 'atBTC' ? 1006 : asset.symbol === 'avDOT' ? 1005 : asset.symbol === 'aETH' ? 1007 : 1004;
1216
+ _context14.n = 1;
1217
+ return this.api.getUnsafeApi().apis.CurrenciesApi.account(currencyId, address);
1196
1218
  case 1:
1197
- response = _context13.v;
1219
+ _response = _context14.v;
1220
+ return _context14.a(2, _response ? BigInt(_response.free.toString()) : 0n);
1221
+ case 2:
1222
+ _context14.n = 3;
1223
+ return this.api.getUnsafeApi().query[pallet].Accounts.getEntries(address);
1224
+ case 3:
1225
+ response = _context14.v;
1198
1226
  entry = response.find(function (_ref5) {
1199
1227
  var _asset$symbol, _asset$assetId, _asset$symbol2, _asset$assetId2;
1200
1228
  var keyArgs = _ref5.keyArgs;
@@ -1203,11 +1231,11 @@ var PapiApi = /*#__PURE__*/function () {
1203
1231
  var assetItem = _keyArgs[1];
1204
1232
  return assetItem.toString().toLowerCase() === ((_asset$symbol = asset.symbol) === null || _asset$symbol === void 0 ? void 0 : _asset$symbol.toLowerCase()) || sdkCore.isForeignAsset(asset) && assetItem.toString().toLowerCase() === ((_asset$assetId = asset.assetId) === null || _asset$assetId === void 0 ? void 0 : _asset$assetId.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && assetItem.value.toString().toLowerCase() === ((_asset$symbol2 = asset.symbol) === null || _asset$symbol2 === void 0 ? void 0 : _asset$symbol2.toLowerCase()) || _typeof(assetItem) === 'object' && 'value' in assetItem && sdkCore.isForeignAsset(asset) && assetItem.value.toString().toLowerCase() === ((_asset$assetId2 = asset.assetId) === null || _asset$assetId2 === void 0 ? void 0 : _asset$assetId2.toLowerCase());
1205
1233
  });
1206
- return _context13.a(2, entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
1234
+ return _context14.a(2, entry !== null && entry !== void 0 && entry.value ? BigInt(entry.value.free.toString()) : 0n);
1207
1235
  }
1208
- }, _callee13, this);
1236
+ }, _callee14, this);
1209
1237
  }));
1210
- function getBalanceForeignXTokens(_x22, _x23, _x24) {
1238
+ function getBalanceForeignXTokens(_x24, _x25, _x26) {
1211
1239
  return _getBalanceForeignXTokens.apply(this, arguments);
1212
1240
  }
1213
1241
  return getBalanceForeignXTokens;
@@ -1215,20 +1243,20 @@ var PapiApi = /*#__PURE__*/function () {
1215
1243
  }, {
1216
1244
  key: "getBalanceAssetsPallet",
1217
1245
  value: function () {
1218
- var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(address, assetId) {
1246
+ var _getBalanceAssetsPallet = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(address, assetId) {
1219
1247
  var response;
1220
- return _regenerator().w(function (_context14) {
1221
- while (1) switch (_context14.n) {
1248
+ return _regenerator().w(function (_context15) {
1249
+ while (1) switch (_context15.n) {
1222
1250
  case 0:
1223
- _context14.n = 1;
1251
+ _context15.n = 1;
1224
1252
  return this.api.getUnsafeApi().query.Assets.Account.getValue(assetId, address);
1225
1253
  case 1:
1226
- response = _context14.v;
1227
- return _context14.a(2, BigInt(response === undefined ? 0 : response.balance));
1254
+ response = _context15.v;
1255
+ return _context15.a(2, BigInt(response === undefined ? 0 : response.balance));
1228
1256
  }
1229
- }, _callee14, this);
1257
+ }, _callee15, this);
1230
1258
  }));
1231
- function getBalanceAssetsPallet(_x25, _x26) {
1259
+ function getBalanceAssetsPallet(_x27, _x28) {
1232
1260
  return _getBalanceAssetsPallet.apply(this, arguments);
1233
1261
  }
1234
1262
  return getBalanceAssetsPallet;
@@ -1236,21 +1264,21 @@ var PapiApi = /*#__PURE__*/function () {
1236
1264
  }, {
1237
1265
  key: "getFromRpc",
1238
1266
  value: function () {
1239
- var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(module, method, key) {
1267
+ var _getFromRpc = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(module, method, key) {
1240
1268
  var toSS58, value;
1241
- return _regenerator().w(function (_context15) {
1242
- while (1) switch (_context15.n) {
1269
+ return _regenerator().w(function (_context16) {
1270
+ while (1) switch (_context16.n) {
1243
1271
  case 0:
1244
1272
  toSS58 = polkadotApi.AccountId().dec;
1245
- _context15.n = 1;
1273
+ _context16.n = 1;
1246
1274
  return this.api._request("".concat(module, "_").concat(method), [module === 'system' && isHex(key) && !viem.isAddress(key) ? toSS58(key) : key]);
1247
1275
  case 1:
1248
- value = _context15.v;
1249
- return _context15.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
1276
+ value = _context16.v;
1277
+ return _context16.a(2, isHex(value) ? value : '0x' + value.toString(16).padStart(8, '0'));
1250
1278
  }
1251
- }, _callee15, this);
1279
+ }, _callee16, this);
1252
1280
  }));
1253
- function getFromRpc(_x27, _x28, _x29) {
1281
+ function getFromRpc(_x29, _x30, _x31) {
1254
1282
  return _getFromRpc.apply(this, arguments);
1255
1283
  }
1256
1284
  return getFromRpc;
@@ -1258,25 +1286,25 @@ var PapiApi = /*#__PURE__*/function () {
1258
1286
  }, {
1259
1287
  key: "clone",
1260
1288
  value: function clone() {
1261
- return new PapiApi();
1289
+ return new PapiApi(sdkCore.isConfig(this._config) ? this._config : undefined);
1262
1290
  }
1263
1291
  }, {
1264
1292
  key: "createApiForNode",
1265
1293
  value: function () {
1266
- var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(node) {
1294
+ var _createApiForNode = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(node) {
1267
1295
  var api;
1268
- return _regenerator().w(function (_context16) {
1269
- while (1) switch (_context16.n) {
1296
+ return _regenerator().w(function (_context17) {
1297
+ while (1) switch (_context17.n) {
1270
1298
  case 0:
1271
1299
  api = new PapiApi();
1272
- _context16.n = 1;
1300
+ _context17.n = 1;
1273
1301
  return api.init(node);
1274
1302
  case 1:
1275
- return _context16.a(2, api);
1303
+ return _context17.a(2, api);
1276
1304
  }
1277
- }, _callee16);
1305
+ }, _callee17);
1278
1306
  }));
1279
- function createApiForNode(_x30) {
1307
+ function createApiForNode(_x32) {
1280
1308
  return _createApiForNode.apply(this, arguments);
1281
1309
  }
1282
1310
  return createApiForNode;
@@ -1284,16 +1312,16 @@ var PapiApi = /*#__PURE__*/function () {
1284
1312
  }, {
1285
1313
  key: "getDryRunCall",
1286
1314
  value: function () {
1287
- var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(_ref6) {
1315
+ var _getDryRunCall = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(_ref6) {
1288
1316
  var _this = this;
1289
1317
  var tx, address, node, feeAsset, supportsDryRunApi, DEFAULT_XCM_VERSION, basePayload, performDryRunCall, getExecutionSuccessFromResult, extractFailureReasonFromResult, result, isSuccess, failureOutputReason, initialFailureReason, actualWeight, weight, forwardedXcms, destParaId, executionFee, nativeAsset, hasMultiLocation, xcmFee, fee;
1290
- return _regenerator().w(function (_context18) {
1291
- while (1) switch (_context18.n) {
1318
+ return _regenerator().w(function (_context19) {
1319
+ while (1) switch (_context19.n) {
1292
1320
  case 0:
1293
1321
  tx = _ref6.tx, address = _ref6.address, node = _ref6.node, feeAsset = _ref6.feeAsset;
1294
1322
  supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
1295
1323
  if (supportsDryRunApi) {
1296
- _context18.n = 1;
1324
+ _context19.n = 1;
1297
1325
  break;
1298
1326
  }
1299
1327
  throw new sdkCore.NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
@@ -1307,21 +1335,21 @@ var PapiApi = /*#__PURE__*/function () {
1307
1335
  }
1308
1336
  };
1309
1337
  performDryRunCall = /*#__PURE__*/function () {
1310
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(includeVersion) {
1338
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18(includeVersion) {
1311
1339
  var _this$api$getUnsafeAp;
1312
1340
  var callArgs;
1313
- return _regenerator().w(function (_context17) {
1314
- while (1) switch (_context17.n) {
1341
+ return _regenerator().w(function (_context18) {
1342
+ while (1) switch (_context18.n) {
1315
1343
  case 0:
1316
1344
  callArgs = [basePayload, tx.decodedCall];
1317
1345
  if (includeVersion) {
1318
1346
  callArgs.push(DEFAULT_XCM_VERSION);
1319
1347
  }
1320
- return _context17.a(2, (_this$api$getUnsafeAp = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, callArgs));
1348
+ return _context18.a(2, (_this$api$getUnsafeAp = _this.api.getUnsafeApi().apis.DryRunApi).dry_run_call.apply(_this$api$getUnsafeAp, callArgs));
1321
1349
  }
1322
- }, _callee17);
1350
+ }, _callee18);
1323
1351
  }));
1324
- return function performDryRunCall(_x32) {
1352
+ return function performDryRunCall(_x34) {
1325
1353
  return _ref7.apply(this, arguments);
1326
1354
  };
1327
1355
  }();
@@ -1344,25 +1372,25 @@ var PapiApi = /*#__PURE__*/function () {
1344
1372
  return JSON.stringify((_ref8 = (_result$value4 = result === null || result === void 0 ? void 0 : result.value) !== null && _result$value4 !== void 0 ? _result$value4 : result) !== null && _ref8 !== void 0 ? _ref8 : 'Unknown error structure');
1345
1373
  };
1346
1374
  failureOutputReason = '';
1347
- _context18.n = 2;
1375
+ _context19.n = 2;
1348
1376
  return performDryRunCall(false);
1349
1377
  case 2:
1350
- result = _context18.v;
1378
+ result = _context19.v;
1351
1379
  isSuccess = getExecutionSuccessFromResult(result);
1352
1380
  if (isSuccess) {
1353
- _context18.n = 4;
1381
+ _context19.n = 4;
1354
1382
  break;
1355
1383
  }
1356
1384
  initialFailureReason = extractFailureReasonFromResult(result);
1357
1385
  failureOutputReason = initialFailureReason;
1358
1386
  if (!(initialFailureReason === 'VersionedConversionFailed')) {
1359
- _context18.n = 4;
1387
+ _context19.n = 4;
1360
1388
  break;
1361
1389
  }
1362
- _context18.n = 3;
1390
+ _context19.n = 3;
1363
1391
  return performDryRunCall(true);
1364
1392
  case 3:
1365
- result = _context18.v;
1393
+ result = _context19.v;
1366
1394
  isSuccess = getExecutionSuccessFromResult(result);
1367
1395
  if (!isSuccess) {
1368
1396
  failureOutputReason = extractFailureReasonFromResult(result);
@@ -1371,10 +1399,10 @@ var PapiApi = /*#__PURE__*/function () {
1371
1399
  }
1372
1400
  case 4:
1373
1401
  if (isSuccess) {
1374
- _context18.n = 5;
1402
+ _context19.n = 5;
1375
1403
  break;
1376
1404
  }
1377
- return _context18.a(2, Promise.resolve({
1405
+ return _context19.a(2, Promise.resolve({
1378
1406
  success: false,
1379
1407
  failureReason: failureOutputReason
1380
1408
  }));
@@ -1386,27 +1414,27 @@ var PapiApi = /*#__PURE__*/function () {
1386
1414
  } : undefined;
1387
1415
  forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1388
1416
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1389
- _context18.n = 6;
1417
+ _context19.n = 6;
1390
1418
  return this.calculateTransactionFee(tx, address);
1391
1419
  case 6:
1392
- executionFee = _context18.v;
1420
+ executionFee = _context19.v;
1393
1421
  nativeAsset = sdkCore.findAsset(node, {
1394
1422
  symbol: sdkCore.Native(sdkCore.getNativeAssetSymbol(node))
1395
1423
  }, null);
1396
1424
  hasMultiLocation = feeAsset ? Boolean(feeAsset.multiLocation) : Boolean(nativeAsset === null || nativeAsset === void 0 ? void 0 : nativeAsset.multiLocation);
1397
1425
  if (!(sdkCore.hasXcmPaymentApiSupport(node) && result.value.local_xcm && hasMultiLocation && nativeAsset && node !== 'AssetHubPolkadot' && node !== 'Kusama')) {
1398
- _context18.n = 8;
1426
+ _context19.n = 8;
1399
1427
  break;
1400
1428
  }
1401
- _context18.n = 7;
1429
+ _context19.n = 7;
1402
1430
  return this.getXcmPaymentApiFee(node, result.value.local_xcm, feeAsset !== null && feeAsset !== void 0 ? feeAsset : nativeAsset);
1403
1431
  case 7:
1404
- xcmFee = _context18.v;
1432
+ xcmFee = _context19.v;
1405
1433
  if (!(typeof xcmFee === 'bigint')) {
1406
- _context18.n = 8;
1434
+ _context19.n = 8;
1407
1435
  break;
1408
1436
  }
1409
- return _context18.a(2, Promise.resolve({
1437
+ return _context19.a(2, Promise.resolve({
1410
1438
  success: true,
1411
1439
  fee: xcmFee,
1412
1440
  weight: weight,
@@ -1415,7 +1443,7 @@ var PapiApi = /*#__PURE__*/function () {
1415
1443
  }));
1416
1444
  case 8:
1417
1445
  fee = sdkCore.computeFeeFromDryRun(result, node, executionFee, !!feeAsset);
1418
- return _context18.a(2, Promise.resolve({
1446
+ return _context19.a(2, Promise.resolve({
1419
1447
  success: true,
1420
1448
  fee: fee,
1421
1449
  weight: weight,
@@ -1423,9 +1451,9 @@ var PapiApi = /*#__PURE__*/function () {
1423
1451
  destParaId: destParaId
1424
1452
  }));
1425
1453
  }
1426
- }, _callee18, this);
1454
+ }, _callee19, this);
1427
1455
  }));
1428
- function getDryRunCall(_x31) {
1456
+ function getDryRunCall(_x33) {
1429
1457
  return _getDryRunCall.apply(this, arguments);
1430
1458
  }
1431
1459
  return getDryRunCall;
@@ -1433,24 +1461,24 @@ var PapiApi = /*#__PURE__*/function () {
1433
1461
  }, {
1434
1462
  key: "getXcmWeight",
1435
1463
  value: function () {
1436
- var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19(xcm) {
1464
+ var _getXcmWeight = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(xcm) {
1437
1465
  var weightResult, _weightResult$value, ref_time, proof_size;
1438
- return _regenerator().w(function (_context19) {
1439
- while (1) switch (_context19.n) {
1466
+ return _regenerator().w(function (_context20) {
1467
+ while (1) switch (_context20.n) {
1440
1468
  case 0:
1441
- _context19.n = 1;
1469
+ _context20.n = 1;
1442
1470
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(!xcm.type ? _transform(xcm) : xcm);
1443
1471
  case 1:
1444
- weightResult = _context19.v;
1472
+ weightResult = _context20.v;
1445
1473
  _weightResult$value = weightResult.value, ref_time = _weightResult$value.ref_time, proof_size = _weightResult$value.proof_size;
1446
- return _context19.a(2, {
1474
+ return _context20.a(2, {
1447
1475
  refTime: ref_time,
1448
1476
  proofSize: proof_size
1449
1477
  });
1450
1478
  }
1451
- }, _callee19, this);
1479
+ }, _callee20, this);
1452
1480
  }));
1453
- function getXcmWeight(_x33) {
1481
+ function getXcmWeight(_x35) {
1454
1482
  return _getXcmWeight.apply(this, arguments);
1455
1483
  }
1456
1484
  return getXcmWeight;
@@ -1458,35 +1486,35 @@ var PapiApi = /*#__PURE__*/function () {
1458
1486
  }, {
1459
1487
  key: "getXcmPaymentApiFee",
1460
1488
  value: function () {
1461
- var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee20(node, xcm, asset) {
1489
+ var _getXcmPaymentApiFee = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(node, xcm, asset) {
1462
1490
  var weight, transformedLocation, transformedPapiLocation, feeResult;
1463
- return _regenerator().w(function (_context20) {
1464
- while (1) switch (_context20.n) {
1491
+ return _regenerator().w(function (_context21) {
1492
+ while (1) switch (_context21.n) {
1465
1493
  case 0:
1466
- _context20.n = 1;
1494
+ _context21.n = 1;
1467
1495
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_xcm_weight(xcm);
1468
1496
  case 1:
1469
- weight = _context20.v;
1497
+ weight = _context21.v;
1470
1498
  if (asset !== null && asset !== void 0 && asset.multiLocation) {
1471
- _context20.n = 2;
1499
+ _context21.n = 2;
1472
1500
  break;
1473
1501
  }
1474
1502
  throw new sdkCore.InvalidCurrencyError('This asset does not have a multiLocation defined. Cannot determine destination fee.');
1475
1503
  case 2:
1476
1504
  transformedLocation = node === 'AssetHubPolkadot' || node === 'AssetHubKusama' || sdkCore.isRelayChain(node) ? sdkCore.localizeLocation(node, asset.multiLocation) : asset.multiLocation;
1477
1505
  transformedPapiLocation = _transform(transformedLocation);
1478
- _context20.n = 3;
1506
+ _context21.n = 3;
1479
1507
  return this.api.getUnsafeApi().apis.XcmPaymentApi.query_weight_to_asset_fee(weight.value, {
1480
1508
  type: sdkCore.Version.V4,
1481
1509
  value: transformedPapiLocation
1482
1510
  });
1483
1511
  case 3:
1484
- feeResult = _context20.v;
1485
- return _context20.a(2, feeResult.value);
1512
+ feeResult = _context21.v;
1513
+ return _context21.a(2, feeResult.value);
1486
1514
  }
1487
- }, _callee20, this);
1515
+ }, _callee21, this);
1488
1516
  }));
1489
- function getXcmPaymentApiFee(_x34, _x35, _x36) {
1517
+ function getXcmPaymentApiFee(_x36, _x37, _x38) {
1490
1518
  return _getXcmPaymentApiFee.apply(this, arguments);
1491
1519
  }
1492
1520
  return getXcmPaymentApiFee;
@@ -1494,32 +1522,32 @@ var PapiApi = /*#__PURE__*/function () {
1494
1522
  }, {
1495
1523
  key: "getDryRunXcm",
1496
1524
  value: function () {
1497
- var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee21(_ref9) {
1525
+ var _getDryRunXcm = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22(_ref9) {
1498
1526
  var _ref0, _processAssetsDeposit, _ref1, _ref10, _ref11, _ref12, _ref13;
1499
1527
  var originLocation, xcm, node, origin, asset, feeAsset, originFee, amount, supportsDryRunApi, transformedOriginLocation, result, isSuccess, failureReason, actualWeight, weight, forwardedXcms, destParaId, _fee, emitted, reversedEvents, palletsWithIssued, isFeeAsset, feeAssetFeeEvent, processedAssetsAmount, feeEvent, fee, processedFee;
1500
- return _regenerator().w(function (_context21) {
1501
- while (1) switch (_context21.n) {
1528
+ return _regenerator().w(function (_context22) {
1529
+ while (1) switch (_context22.n) {
1502
1530
  case 0:
1503
1531
  originLocation = _ref9.originLocation, xcm = _ref9.xcm, node = _ref9.node, origin = _ref9.origin, asset = _ref9.asset, feeAsset = _ref9.feeAsset, originFee = _ref9.originFee, amount = _ref9.amount;
1504
1532
  supportsDryRunApi = sdkCore.getAssetsObject(node).supportsDryRunApi;
1505
1533
  if (supportsDryRunApi) {
1506
- _context21.n = 1;
1534
+ _context22.n = 1;
1507
1535
  break;
1508
1536
  }
1509
1537
  throw new sdkCore.NodeNotSupportedError("DryRunApi is not available on node ".concat(node));
1510
1538
  case 1:
1511
1539
  transformedOriginLocation = _transform(originLocation);
1512
- _context21.n = 2;
1540
+ _context22.n = 2;
1513
1541
  return this.api.getUnsafeApi().apis.DryRunApi.dry_run_xcm(transformedOriginLocation, xcm);
1514
1542
  case 2:
1515
- result = _context21.v;
1543
+ result = _context22.v;
1516
1544
  isSuccess = result.success && result.value.execution_result.type === 'Complete';
1517
1545
  if (isSuccess) {
1518
- _context21.n = 3;
1546
+ _context22.n = 3;
1519
1547
  break;
1520
1548
  }
1521
1549
  failureReason = result.value.execution_result.value.error.type;
1522
- return _context21.a(2, Promise.resolve({
1550
+ return _context22.a(2, Promise.resolve({
1523
1551
  success: false,
1524
1552
  failureReason: failureReason
1525
1553
  }));
@@ -1532,18 +1560,18 @@ var PapiApi = /*#__PURE__*/function () {
1532
1560
  forwardedXcms = result.value.forwarded_xcms.length > 0 ? result.value.forwarded_xcms[0] : [];
1533
1561
  destParaId = forwardedXcms.length === 0 ? undefined : forwardedXcms[0].value.interior.type === 'Here' ? 0 : forwardedXcms[0].value.interior.value.value;
1534
1562
  if (!(sdkCore.hasXcmPaymentApiSupport(node) && asset && node !== 'AssetHubPolkadot' && node !== 'Polkadot')) {
1535
- _context21.n = 5;
1563
+ _context22.n = 5;
1536
1564
  break;
1537
1565
  }
1538
- _context21.n = 4;
1566
+ _context22.n = 4;
1539
1567
  return this.getXcmPaymentApiFee(node, xcm, asset);
1540
1568
  case 4:
1541
- _fee = _context21.v;
1569
+ _fee = _context22.v;
1542
1570
  if (!(typeof _fee === 'bigint')) {
1543
- _context21.n = 5;
1571
+ _context22.n = 5;
1544
1572
  break;
1545
1573
  }
1546
- return _context21.a(2, {
1574
+ return _context22.a(2, {
1547
1575
  success: true,
1548
1576
  fee: _fee,
1549
1577
  weight: weight,
@@ -1591,10 +1619,10 @@ var PapiApi = /*#__PURE__*/function () {
1591
1619
  return ['Currencies', 'Tokens'].includes(event.type) && event.value.type === 'Deposited';
1592
1620
  });
1593
1621
  if (feeEvent) {
1594
- _context21.n = 6;
1622
+ _context22.n = 6;
1595
1623
  break;
1596
1624
  }
1597
- return _context21.a(2, Promise.resolve({
1625
+ return _context22.a(2, Promise.resolve({
1598
1626
  success: false,
1599
1627
  failureReason: 'Cannot determine destination fee. No fee event found'
1600
1628
  }));
@@ -1604,7 +1632,7 @@ var PapiApi = /*#__PURE__*/function () {
1604
1632
  fee = amount - originFee - feeEvent.value.value.amount;
1605
1633
  }
1606
1634
  processedFee = (sdkCore.isRelayChain(node) || node.includes('AssetHub')) && (asset === null || asset === void 0 ? void 0 : asset.symbol) === 'DOT' ? sdkCore.padFeeBy(fee, 30) : fee;
1607
- return _context21.a(2, Promise.resolve({
1635
+ return _context22.a(2, Promise.resolve({
1608
1636
  success: true,
1609
1637
  fee: processedFee,
1610
1638
  weight: weight,
@@ -1612,9 +1640,9 @@ var PapiApi = /*#__PURE__*/function () {
1612
1640
  destParaId: destParaId
1613
1641
  }));
1614
1642
  }
1615
- }, _callee21, this);
1643
+ }, _callee22, this);
1616
1644
  }));
1617
- function getDryRunXcm(_x37) {
1645
+ function getDryRunXcm(_x39) {
1618
1646
  return _getDryRunXcm.apply(this, arguments);
1619
1647
  }
1620
1648
  return getDryRunXcm;
@@ -1622,18 +1650,18 @@ var PapiApi = /*#__PURE__*/function () {
1622
1650
  }, {
1623
1651
  key: "getBridgeStatus",
1624
1652
  value: function () {
1625
- var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee22() {
1653
+ var _getBridgeStatus = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee23() {
1626
1654
  var outboundOperatingMode;
1627
- return _regenerator().w(function (_context22) {
1628
- while (1) switch (_context22.n) {
1655
+ return _regenerator().w(function (_context23) {
1656
+ while (1) switch (_context23.n) {
1629
1657
  case 0:
1630
- _context22.n = 1;
1658
+ _context23.n = 1;
1631
1659
  return this.api.getUnsafeApi().query.EthereumOutboundQueue.OperatingMode.getValue();
1632
1660
  case 1:
1633
- outboundOperatingMode = _context22.v;
1634
- return _context22.a(2, outboundOperatingMode.type);
1661
+ outboundOperatingMode = _context23.v;
1662
+ return _context23.a(2, outboundOperatingMode.type);
1635
1663
  }
1636
- }, _callee22, this);
1664
+ }, _callee23, this);
1637
1665
  }));
1638
1666
  function getBridgeStatus() {
1639
1667
  return _getBridgeStatus.apply(this, arguments);
@@ -1653,19 +1681,21 @@ var PapiApi = /*#__PURE__*/function () {
1653
1681
  }, {
1654
1682
  key: "disconnect",
1655
1683
  value: function disconnect() {
1684
+ var _this$_config$apiOver2;
1656
1685
  var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1657
1686
  if (!this.initialized) return Promise.resolve();
1658
1687
  if (!force && !this.disconnectAllowed) return Promise.resolve();
1688
+ var api = sdkCore.isConfig(this._config) ? (_this$_config$apiOver2 = this._config.apiOverrides) === null || _this$_config$apiOver2 === void 0 ? void 0 : _this$_config$apiOver2[this._node] : this._config;
1659
1689
  // Own client provided, destroy only if force true
1660
- if (force && _typeof(this._api) === 'object') {
1690
+ if (force && _typeof(api) === 'object') {
1661
1691
  this.api.destroy();
1662
1692
  }
1663
1693
  // Client created automatically
1664
- if (typeof this._api === 'string' || Array.isArray(this._api) || this._api === undefined) {
1694
+ if (typeof api === 'string' || Array.isArray(api) || api === undefined) {
1665
1695
  if (force) {
1666
1696
  this.api.destroy();
1667
1697
  } else {
1668
- var key = this._api === undefined ? sdkCore.getNodeProviders(this._node) : this._api;
1698
+ var key = api === undefined ? sdkCore.getNodeProviders(this._node) : api;
1669
1699
  releasePolkadotClient(key);
1670
1700
  }
1671
1701
  }
@@ -1685,8 +1715,7 @@ var createPapiApiCall = function createPapiApiCall(apiCall) {
1685
1715
  return _regenerator().w(function (_context) {
1686
1716
  while (1) switch (_context.n) {
1687
1717
  case 0:
1688
- papiApi = new PapiApi();
1689
- papiApi.setApi(options.api);
1718
+ papiApi = new PapiApi(options.api);
1690
1719
  optionsWithApi = _objectSpread2(_objectSpread2({}, options), {}, {
1691
1720
  api: papiApi
1692
1721
  });
@@ -1897,8 +1926,7 @@ var EvmBuilder$1 = function EvmBuilder(api) {
1897
1926
  * @returns A new Builder instance.
1898
1927
  */
1899
1928
  var Builder = function Builder(api) {
1900
- var papiApi = new PapiApi();
1901
- papiApi.setApi(api);
1929
+ var papiApi = new PapiApi(api);
1902
1930
  return sdkCore.Builder(papiApi);
1903
1931
  };
1904
1932
  var EvmBuilder = function EvmBuilder() {
@@ -1920,8 +1948,7 @@ var getParaEthTransferFees = /*#__PURE__*/function () {
1920
1948
  return _regenerator().w(function (_context) {
1921
1949
  while (1) switch (_context.n) {
1922
1950
  case 0:
1923
- papiApi = new PapiApi();
1924
- papiApi.setApi(ahApi);
1951
+ papiApi = new PapiApi(ahApi);
1925
1952
  _context.n = 1;
1926
1953
  return papiApi.init('AssetHubPolkadot');
1927
1954
  case 1:
@@ -1942,8 +1969,7 @@ var getBridgeStatus = /*#__PURE__*/function () {
1942
1969
  return _regenerator().w(function (_context2) {
1943
1970
  while (1) switch (_context2.n) {
1944
1971
  case 0:
1945
- papiApi = new PapiApi();
1946
- papiApi.setApi(ahApi);
1972
+ papiApi = new PapiApi(ahApi);
1947
1973
  return _context2.a(2, sdkCore.getBridgeStatus(papiApi));
1948
1974
  }
1949
1975
  }, _callee2);