@rabbitio/ui-kit 1.0.0-beta.39 → 1.0.0-beta.40

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.
@@ -4632,6 +4632,83 @@ var ExternalApiProvider = /*#__PURE__*/function () {
4632
4632
  return ExternalApiProvider;
4633
4633
  }();
4634
4634
 
4635
+ /**
4636
+ * Models a group of APIs provided by the same owner and used for different services in our app.
4637
+ * It means we need to mention RPS several times for each usage and also have some holder of last call timestamp per
4638
+ * api group. So this concept allows to use it for exact ExternalApiProvider and make sure that you use the same
4639
+ * RPS value and make decisions on base of the same timestamp of last call to the API group owner.
4640
+ */
4641
+ var ApiGroup = /*#__PURE__*/function () {
4642
+ function ApiGroup(id, rps, backendProxyIdGenerator) {
4643
+ if (backendProxyIdGenerator === void 0) {
4644
+ backendProxyIdGenerator = null;
4645
+ }
4646
+ this.id = id;
4647
+ this.rps = rps;
4648
+ this.lastCalledTimestamp = null;
4649
+ this.backendProxyIdGenerator = backendProxyIdGenerator;
4650
+ }
4651
+ var _proto = ApiGroup.prototype;
4652
+ _proto.isRpsExceeded = function isRpsExceeded() {
4653
+ var _this$lastCalledTimes;
4654
+ return ((_this$lastCalledTimes = this.lastCalledTimestamp) != null ? _this$lastCalledTimes : 0) + Math.floor(1000 / this.rps) > Date.now();
4655
+ };
4656
+ _proto.actualizeLastCalledTimestamp = function actualizeLastCalledTimestamp() {
4657
+ this.lastCalledTimestamp = Date.now();
4658
+ };
4659
+ return ApiGroup;
4660
+ }();
4661
+ var ApiGroups = {
4662
+ /**
4663
+ * Currently we use free version of etherscan provider with 0.2 RPS. But we have API key with 100k requests free
4664
+ * per month. So we can add it if not enough current RPS.
4665
+ */
4666
+ ETHERSCAN: new ApiGroup("etherscan", 0.17),
4667
+ // Actually 0.2 but fails sometime, so we use smaller
4668
+ ALCHEMY: new ApiGroup("alchemy", 0.3, function (networkKey) {
4669
+ return "alchemy-" + networkKey;
4670
+ }),
4671
+ BLOCKSTREAM: new ApiGroup("blockstream", 0.2),
4672
+ BLOCKCHAIN_INFO: new ApiGroup("blockchain.info", 1),
4673
+ BLOCKNATIVE: new ApiGroup("blocknative", 0.5),
4674
+ ETHGASSTATION: new ApiGroup("ethgasstation", 0.5),
4675
+ TRONGRID: new ApiGroup("trongrid", 0.3, function (networkKey) {
4676
+ return "trongrid-" + networkKey;
4677
+ }),
4678
+ TRONSCAN: new ApiGroup("tronscan", 0.3),
4679
+ GETBLOCK: new ApiGroup("getblock", 0.3),
4680
+ COINCAP: new ApiGroup("coincap", 0.5),
4681
+ // 200 per minute without API key
4682
+ COINGECKO: new ApiGroup("coingecko", 0.9),
4683
+ // actually 0.13-0.5 according to the docs but we use smaller due to expirienced frequent abuses
4684
+ MESSARI: new ApiGroup("messari", 0.2),
4685
+ BTCCOM: new ApiGroup("btccom", 0.2),
4686
+ BITAPS: new ApiGroup("bitaps", 0.25),
4687
+ // Docs say that RPS is 3 but using it causes frequent 429 HTTP errors
4688
+ CEX: new ApiGroup("cex", 0.5),
4689
+ // Just assumption for RPS
4690
+ BIGDATACLOUD: new ApiGroup("bigdatacloud", 1),
4691
+ // Just assumption for RPS
4692
+ TRACKIP: new ApiGroup("trackip", 1),
4693
+ // Just assumption for RPS
4694
+ IPIFY: new ApiGroup("ipify", 1),
4695
+ // Just assumption for RPS
4696
+ WHATISMYIPADDRESS: new ApiGroup("whatismyipaddress", 1),
4697
+ // Just assumption for RPS
4698
+ EXCHANGERATE: new ApiGroup("exchangerate", 1),
4699
+ // Just assumption for RPS
4700
+ FRANKFURTER: new ApiGroup("frankfurter", 1),
4701
+ // Just assumption for RPS
4702
+ BITGO: new ApiGroup("bitgo", 1),
4703
+ // Just assumption for RPS
4704
+ BITCOINER: new ApiGroup("bitcoiner", 1),
4705
+ // Just assumption for RPS
4706
+ BITCORE: new ApiGroup("bitcore", 1),
4707
+ // Just assumption for RPS
4708
+ // BLOCKCHAIR: new ApiGroup("blockchair", 0.04), // this provider require API key for commercial use (10usd 10000 reqs), we will add it later
4709
+ MEMPOOL: new ApiGroup("mempool", 0.2) // Just assumption for RPS
4710
+ };
4711
+
4635
4712
  var ExistingSwap =
4636
4713
  /**
4637
4714
  * @param swapId {string}
@@ -6604,5 +6681,5 @@ PublicSwapService.PUBLIC_SWAP_DETAILS_FAIL_REASONS = {
6604
6681
  };
6605
6682
  PublicSwapService._fiatDecimalsCount = FiatCurrenciesService.getCurrencyDecimalCountByCode("USD");
6606
6683
 
6607
- export { AmountUtils, AssetIcon, AxiosAdapter, BaseSwapCreationInfo, Blockchain, Button, Cache, CacheAndConcurrentRequestsResolver, CachedRobustExternalApiCallerService, CancelProcessing, Coin, EmailsApi, ExistingSwap, ExistingSwapWithFiatData, ExternalApiProvider, FiatCurrenciesService, LoadingDots, Logger, LogsStorage, Protocol, PublicSwapService, RobustExternalAPICallerService, SupportChat, SwapProvider, SwapUtils, SwapspaceSwapProvider, getQueryParameterSingleValue, getQueryParameterValues, handleClickOutside, improveAndRethrow, logErrorOrOutputToConsole, postponeExecution, removeQueryParameterAndValues, safeStringify, saveQueryParameterAndValues, useCallHandlingErrors, useReferredState };
6684
+ export { AmountUtils, ApiGroup, ApiGroups, AssetIcon, AxiosAdapter, BaseSwapCreationInfo, Blockchain, Button, Cache, CacheAndConcurrentRequestsResolver, CachedRobustExternalApiCallerService, CancelProcessing, Coin, EmailsApi, ExistingSwap, ExistingSwapWithFiatData, ExternalApiProvider, FiatCurrenciesService, LoadingDots, Logger, LogsStorage, Protocol, PublicSwapService, RobustExternalAPICallerService, SupportChat, SwapProvider, SwapUtils, SwapspaceSwapProvider, getQueryParameterSingleValue, getQueryParameterValues, handleClickOutside, improveAndRethrow, logErrorOrOutputToConsole, postponeExecution, removeQueryParameterAndValues, safeStringify, saveQueryParameterAndValues, useCallHandlingErrors, useReferredState };
6608
6685
  //# sourceMappingURL=index.module.js.map