@rabbitio/ui-kit 1.0.0-beta.61 → 1.0.0-beta.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/coverage/clover.xml +889 -4771
  2. package/coverage/coverage-final.json +99 -159
  3. package/coverage/index.html +91 -346
  4. package/coverage/{ui-kit → rabbit-ui-kit}/index.html +3 -3
  5. package/coverage/{ui-kit → rabbit-ui-kit}/index.js.html +3 -3
  6. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/arrowIcon.jsx.html +3 -3
  7. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/arrowTosca.jsx.html +3 -3
  8. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/arrowWhite.jsx.html +3 -3
  9. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/darkRectangle.jsx.html +3 -3
  10. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/determinedError.jsx.html +3 -3
  11. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/failedValidationIcon.jsx.html +3 -3
  12. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/index.html +3 -3
  13. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/infoIcon.jsx.html +3 -3
  14. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/noticeQuestionIcon.jsx.html +3 -3
  15. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/successfulValidationIcon.jsx.html +3 -3
  16. package/coverage/{ui-kit → rabbit-ui-kit}/src/assets/wrappedImages/walletIcon.jsx.html +3 -3
  17. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/adapters/axiosAdapter.js.html +3 -3
  18. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/adapters/index.html +3 -3
  19. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/adapters/qrUtils.js.html +3 -3
  20. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/amountUtils.js.html +138 -105
  21. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/errorUtils.js.html +3 -3
  22. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/external-apis/apiGroups.js.html +3 -3
  23. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/external-apis/index.html +3 -3
  24. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/external-apis/ipAddressProviders.js.html +3 -3
  25. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/fiatCurrenciesService.js.html +3 -3
  26. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/index.html +22 -22
  27. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/models/blockchain.js.html +3 -3
  28. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/models/coin.js.html +42 -42
  29. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/models/index.html +3 -3
  30. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/models/protocol.js.html +5 -5
  31. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/utils/cache.js.html +8 -8
  32. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/utils/emailAPI.js.html +3 -3
  33. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/utils/index.html +3 -3
  34. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/utils/logging/index.html +3 -3
  35. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/utils/logging/logger.js.html +6 -6
  36. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/utils/logging/logsStorage.js.html +5 -5
  37. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/utils/postponeExecution.js.html +3 -3
  38. package/coverage/{ui-kit → rabbit-ui-kit}/src/common/utils/safeStringify.js.html +3 -3
  39. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/AssetIcon/AssetIcon.jsx.html +3 -3
  40. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/AssetIcon/index.html +3 -3
  41. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/AssetSelection/AssetSelection.jsx.html +3 -3
  42. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/AssetSelection/index.html +3 -3
  43. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/BackgroundTitle/BackgroundTitle.jsx.html +3 -3
  44. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/BackgroundTitle/index.html +3 -3
  45. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/InformationMessage/InformationMessage.jsx.html +3 -3
  46. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/InformationMessage/index.html +3 -3
  47. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/Input/Input.jsx.html +3 -3
  48. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/Input/index.html +3 -3
  49. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/LoadingDots/LoadingDots.jsx.html +3 -3
  50. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/LoadingDots/index.html +3 -3
  51. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/NoticeIcon/NoticeIcon.jsx.html +16 -7
  52. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/NoticeIcon/index.html +7 -7
  53. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/QrCode/QrCode.jsx.html +26 -8
  54. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/QrCode/index.html +7 -7
  55. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/RateSelector/RateSelector.jsx.html +3 -3
  56. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/RateSelector/index.html +3 -3
  57. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/SupportChat/SupportChat.jsx.html +3 -3
  58. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/SupportChat/index.html +3 -3
  59. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/Textarea/Textarea.jsx.html +3 -3
  60. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/Textarea/index.html +3 -3
  61. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/TitleBox/TitleBox.jsx.html +3 -3
  62. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/TitleBox/index.html +3 -3
  63. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/Tooltip/Tooltip.jsx.html +3 -3
  64. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/Tooltip/index.html +3 -3
  65. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/TwoLinesOfText/LinesOfText.jsx.html +3 -3
  66. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/TwoLinesOfText/index.html +3 -3
  67. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/Validation/Validation.jsx.html +3 -3
  68. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/Validation/index.html +3 -3
  69. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/buttons/Button/Button.jsx.html +3 -3
  70. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/buttons/Button/index.html +3 -3
  71. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/buttons/Close/Close.jsx.html +3 -3
  72. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/buttons/Close/index.html +3 -3
  73. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/buttons/LinkButton/LinkButton.jsx.html +3 -3
  74. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/buttons/LinkButton/index.html +3 -3
  75. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/buttons/RadioButtonWithText/RadioButtonWithText.jsx.html +3 -3
  76. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/atoms/buttons/RadioButtonWithText/index.html +3 -3
  77. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/hooks/index.html +3 -3
  78. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/hooks/useCallHandlingErrors.js.html +3 -3
  79. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/hooks/useReferredState.js.html +3 -3
  80. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/molecules/AmountInput/AmountInput.jsx.html +3 -3
  81. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/molecules/AmountInput/index.html +3 -3
  82. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/molecules/CoinPicker/CoinPicker.jsx.html +3 -3
  83. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/molecules/CoinPicker/index.html +3 -3
  84. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/molecules/LineWithIconLink/LineWithIconLink.jsx.html +3 -3
  85. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/molecules/LineWithIconLink/index.html +3 -3
  86. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/molecules/TitledLineWithIconLink/TitledLineWithIconLink.jsx.html +3 -3
  87. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/molecules/TitledLineWithIconLink/index.html +3 -3
  88. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/CoinPickerDialogStep/CoinPickerDialogStep.jsx.html +3 -3
  89. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/CoinPickerDialogStep/index.html +3 -3
  90. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/Dialog/Dialog.jsx.html +3 -3
  91. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/Dialog/DialogButtons/DialogButtons.jsx.html +3 -3
  92. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/Dialog/DialogButtons/index.html +3 -3
  93. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/Dialog/DialogStep/DialogStep.jsx.html +3 -3
  94. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/Dialog/DialogStep/index.html +3 -3
  95. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/Dialog/index.html +3 -3
  96. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/SwapForm/SwapForm.jsx.html +40 -16
  97. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/organisms/SwapForm/index.html +7 -7
  98. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/templates/DeterminedErrorDialogStep/DeterminedErrorDialogStep.jsx.html +3 -3
  99. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/templates/DeterminedErrorDialogStep/index.html +3 -3
  100. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/utils/index.html +3 -3
  101. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/utils/inputValueProviders.js.html +3 -3
  102. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/utils/textUtils.js.html +3 -3
  103. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/utils/uiUtils.js.html +3 -3
  104. package/coverage/{ui-kit → rabbit-ui-kit}/src/components/utils/urlQueryUtils.js.html +3 -3
  105. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/atoms/Close/close.jsx.html +3 -3
  106. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/atoms/Close/index.html +3 -3
  107. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/atoms/LinkButton/index.html +3 -3
  108. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/atoms/LinkButton/linkButton.jsx.html +3 -3
  109. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/atoms/Tooltip/index.html +3 -3
  110. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/atoms/Tooltip/tooltip.jsx.html +3 -3
  111. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/globalConstants.jsx.html +3 -3
  112. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/index.html +3 -3
  113. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/organisms/dialog/DialogStep/dialogStep.js.html +3 -3
  114. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/organisms/dialog/DialogStep/index.html +3 -3
  115. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/organisms/dialog/dialog.js.html +3 -3
  116. package/coverage/{ui-kit → rabbit-ui-kit}/src/constants/organisms/dialog/index.html +3 -3
  117. package/coverage/{ui-kit → rabbit-ui-kit}/src/index.html +3 -3
  118. package/coverage/{ui-kit → rabbit-ui-kit}/src/index.js.html +3 -3
  119. package/coverage/{ui-kit → rabbit-ui-kit}/src/robustExteranlApiCallerService/cacheAndConcurrentRequestsResolver.js.html +3 -3
  120. package/coverage/{ui-kit → rabbit-ui-kit}/src/robustExteranlApiCallerService/cachedRobustExternalApiCallerService.js.html +3 -3
  121. package/coverage/{ui-kit → rabbit-ui-kit}/src/robustExteranlApiCallerService/cancelProcessing.js.html +3 -3
  122. package/coverage/{ui-kit → rabbit-ui-kit}/src/robustExteranlApiCallerService/concurrentCalculationsMetadataHolder.js.html +3 -3
  123. package/coverage/{ui-kit → rabbit-ui-kit}/src/robustExteranlApiCallerService/externalApiProvider.js.html +3 -3
  124. package/coverage/{ui-kit → rabbit-ui-kit}/src/robustExteranlApiCallerService/externalServicesStatsCollector.js.html +3 -3
  125. package/coverage/{ui-kit → rabbit-ui-kit}/src/robustExteranlApiCallerService/index.html +3 -3
  126. package/coverage/{ui-kit → rabbit-ui-kit}/src/robustExteranlApiCallerService/robustExternalAPICallerService.js.html +3 -3
  127. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/external-apis/index.html +17 -17
  128. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/external-apis/swapProvider.js.html +3 -3
  129. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/external-apis/swapspaceSwapProvider.js.html +139 -103
  130. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/models/baseSwapCreationInfo.js.html +3 -3
  131. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/models/existingSwap.js.html +3 -3
  132. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/models/existingSwapWithFiatData.js.html +3 -3
  133. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/models/index.html +3 -3
  134. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/services/index.html +3 -3
  135. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/services/publicSwapService.js.html +3 -3
  136. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/utils/index.html +3 -3
  137. package/coverage/{ui-kit → rabbit-ui-kit}/src/swaps-lib/utils/swapUtils.js.html +3 -3
  138. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/BackgroundTitle.stories.jsx.html +3 -3
  139. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/LinesOfText.stories.jsx.html +3 -3
  140. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/LoadingDots.stories.jsx.html +3 -3
  141. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/QrCode.stories.jsx.html +3 -3
  142. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/RateSelector.stories.jsx.html +3 -3
  143. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/Validation.stories.jsx.html +3 -3
  144. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/buttons/Button.stories.jsx.html +3 -3
  145. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/buttons/Close.stories.jsx.html +3 -3
  146. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/buttons/LinkButton.stories.jsx.html +3 -3
  147. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/buttons/index.html +3 -3
  148. package/coverage/{ui-kit → rabbit-ui-kit}/stories/atoms/index.html +3 -3
  149. package/coverage/{ui-kit → rabbit-ui-kit}/stories/molecules/LineWithIconLink.stories.jsx.html +3 -3
  150. package/coverage/{ui-kit → rabbit-ui-kit}/stories/molecules/TitledLineWithIconLink.stories.jsx.html +3 -3
  151. package/coverage/{ui-kit → rabbit-ui-kit}/stories/molecules/index.html +3 -3
  152. package/coverage/{ui-kit → rabbit-ui-kit}/stories/organisms/Dialog/Dialog.stories.jsx.html +3 -3
  153. package/coverage/{ui-kit → rabbit-ui-kit}/stories/organisms/Dialog/DialogButtons/DialogButtons.stories.jsx.html +3 -3
  154. package/coverage/{ui-kit → rabbit-ui-kit}/stories/organisms/Dialog/DialogButtons/index.html +3 -3
  155. package/coverage/{ui-kit → rabbit-ui-kit}/stories/organisms/Dialog/DialogStep/DialogStep.stories.jsx.html +3 -3
  156. package/coverage/{ui-kit → rabbit-ui-kit}/stories/organisms/Dialog/DialogStep/index.html +3 -3
  157. package/coverage/{ui-kit → rabbit-ui-kit}/stories/organisms/Dialog/index.html +3 -3
  158. package/coverage/{ui-kit → rabbit-ui-kit}/stories/stubs/exampleContent.jsx.html +3 -3
  159. package/coverage/{ui-kit → rabbit-ui-kit}/stories/stubs/index.html +3 -3
  160. package/coverage/{ui-kit → rabbit-ui-kit}/stories/templates/DeterminedErrorDialogStep.stories.jsx.html +3 -3
  161. package/coverage/{ui-kit → rabbit-ui-kit}/stories/templates/index.html +3 -3
  162. package/dist/index.cjs +77 -40
  163. package/dist/index.cjs.map +1 -1
  164. package/dist/index.css +6 -0
  165. package/dist/index.css.map +1 -1
  166. package/dist/index.modern.js +53 -28
  167. package/dist/index.modern.js.map +1 -1
  168. package/dist/index.module.js +77 -40
  169. package/dist/index.module.js.map +1 -1
  170. package/dist/index.umd.js +77 -40
  171. package/dist/index.umd.js.map +1 -1
  172. package/package.json +1 -1
  173. package/src/common/amountUtils.js +32 -21
  174. package/src/common/tests/amountUtils/composeRateText.test.js +209 -0
  175. package/src/components/atoms/AssetSelection/asset-selection.module.scss +1 -0
  176. package/src/components/atoms/NoticeIcon/NoticeIcon.jsx +4 -1
  177. package/src/components/atoms/QrCode/QrCode.jsx +8 -2
  178. package/src/components/atoms/QrCode/qr-code.module.scss +6 -0
  179. package/src/components/organisms/SwapForm/SwapForm.jsx +18 -10
  180. package/src/swaps-lib/external-apis/swapspaceSwapProvider.js +13 -1
  181. package/src/swaps-lib/test/external-apis/swapspaceSwapProvider/_fetchSupportedCurrenciesIfNeeded.test.js +117 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rabbitio/ui-kit",
3
- "version": "1.0.0-beta.61",
3
+ "version": "1.0.0-beta.64",
4
4
  "description": "Rabbit.io react.js components kit",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -356,42 +356,53 @@ export class AmountUtils {
356
356
  }
357
357
 
358
358
  /**
359
- * Safely composes rate string (handles small/big rates)
359
+ * Safely composes rate string (handles small/big rates).
360
+ * Here we try to calculate a clear rate for the user. The difficulty is that the rate value can be pretty
361
+ * small as some coins have significantly higher price than the other. For such cases we calculate
362
+ * not the "1 <coin_A> is X <coin B>" but "Y <coin_A> is X <coin B>" where Y is one of the powers of 100.
360
363
  *
361
364
  * @param leftTicker {string}
362
365
  * @param rightTicker {string}
363
366
  * @param rate {number|string|BigNumber}
364
367
  * @param [rightCurrencyDigitsAfterDots=8] {number}
368
+ * @param [strictRate=false] {boolean} true if the rate is strict and false if approximate
365
369
  * @return {string}
366
370
  */
367
371
  static composeRateText(
368
372
  leftTicker,
369
373
  rightTicker,
370
374
  rate,
371
- rightCurrencyDigitsAfterDots = this.significantDecimalCount
375
+ rightCurrencyDigitsAfterDots = this.significantDecimalCount,
376
+ strictRate = false
372
377
  ) {
373
378
  try {
374
- /* Here we try to calculate a clear rate for the user. The difficulty is that the rate value can be pretty
375
- * small as some coins have significantly higher price than the other. For such cases we calculate
376
- * not the "1 <coin_A> is X <coin B>" but "Y <coin_A> is X <coin B>" where Y is one of the powers of 100.
377
- */
379
+ if (rightCurrencyDigitsAfterDots < 0) {
380
+ rightCurrencyDigitsAfterDots = this.significantDecimalCount;
381
+ }
378
382
  let leftNumber = BigNumber("1");
379
383
  const multiplier = BigNumber("100");
380
384
  const maxAttemptsToGetRate = 10;
381
385
  let right = null;
382
386
  const rateBigNumber = BigNumber(rate);
383
- for (let i = 0; i < maxAttemptsToGetRate; ++i) {
384
- const rightNumberAttempt = rateBigNumber
385
- .times(leftNumber)
386
- .toFixed(
387
- rightCurrencyDigitsAfterDots,
388
- BigNumber.ROUND_FLOOR
389
- );
390
- if (!BigNumber(rightNumberAttempt).eq(BigNumber("0"))) {
391
- right = BigNumber(rightNumberAttempt);
392
- break;
393
- } else {
394
- leftNumber = leftNumber.times(multiplier);
387
+ if (BigNumber(rate).eq("0")) {
388
+ right = BigNumber("0");
389
+ } else if (
390
+ rate &&
391
+ (BigNumber.isBigNumber(rate) || !Number.isNaN(+rate))
392
+ ) {
393
+ for (let i = 0; i < maxAttemptsToGetRate; ++i) {
394
+ const rightNumberAttempt = rateBigNumber
395
+ .times(leftNumber)
396
+ .toFixed(
397
+ rightCurrencyDigitsAfterDots,
398
+ BigNumber.ROUND_FLOOR
399
+ );
400
+ if (!BigNumber(rightNumberAttempt).eq(BigNumber("0"))) {
401
+ right = BigNumber(rightNumberAttempt);
402
+ break;
403
+ } else {
404
+ leftNumber = leftNumber.times(multiplier);
405
+ }
395
406
  }
396
407
  }
397
408
  const leftAmountString = AmountUtils.toIntegerString(leftNumber);
@@ -402,9 +413,9 @@ export class AmountUtils {
402
413
  BigNumber.ROUND_FLOOR
403
414
  )
404
415
  : null;
405
- return `${leftAmountString} ${leftTicker} ~ ${
406
- rightAmountString ?? "?"
407
- } ${rightTicker}`;
416
+ return `${leftAmountString} ${leftTicker} ${
417
+ strictRate ? "=" : "~"
418
+ } ${rightAmountString ?? "?"} ${rightTicker}`;
408
419
  } catch (e) {
409
420
  // eslint-disable-next-line no-console
410
421
  console.log("composeRateText", e);
@@ -0,0 +1,209 @@
1
+ import sinon from "sinon";
2
+ import should from "should";
3
+
4
+ import { beforeEach, afterEach, describe, it } from "vitest";
5
+ import BigNumber from "bignumber.js";
6
+ import { AmountUtils } from "../../amountUtils.js";
7
+
8
+ describe("AmountUtils", function () {
9
+ let toIntegerStringStub;
10
+
11
+ beforeEach(function () {
12
+ toIntegerStringStub = sinon
13
+ .stub(AmountUtils, "toIntegerString")
14
+ .callsFake((number) => number.toFixed(0));
15
+ });
16
+
17
+ afterEach(function () {
18
+ toIntegerStringStub.restore();
19
+ });
20
+
21
+ describe("composeRateText", function () {
22
+ it("Should handle simple rate calculation", function () {
23
+ const result = AmountUtils.composeRateText("BTC", "ETH", "0.1");
24
+
25
+ result.should.equal("1 BTC ~ 0.10000000 ETH");
26
+ });
27
+
28
+ it("Should handle rate with strictRate set to true", function () {
29
+ const result = AmountUtils.composeRateText(
30
+ "BTC",
31
+ "ETH",
32
+ "0.1",
33
+ 8,
34
+ true
35
+ );
36
+
37
+ result.should.equal("1 BTC = 0.10000000 ETH");
38
+ });
39
+
40
+ it("Should handle rate with high precision", function () {
41
+ const result = AmountUtils.composeRateText(
42
+ "BTC",
43
+ "ETH",
44
+ "0.12345678903422",
45
+ 8
46
+ );
47
+
48
+ result.should.equal("1 BTC ~ 0.12345678 ETH");
49
+ });
50
+
51
+ it("Should handle very small rates by scaling up", function () {
52
+ const result = AmountUtils.composeRateText(
53
+ "BTC",
54
+ "ETH",
55
+ "0.000000000000001",
56
+ 8
57
+ );
58
+
59
+ result.should.equal("100000000 BTC ~ 0.00000010 ETH");
60
+ });
61
+
62
+ it("Should handle large rates", function () {
63
+ const result = AmountUtils.composeRateText(
64
+ "BTC",
65
+ "ETH",
66
+ "1000000000000000",
67
+ 8
68
+ );
69
+
70
+ result.should.equal("1 BTC ~ 1000000000000000.00000000 ETH");
71
+ });
72
+
73
+ it("Should return '?' for invalid rate input", function () {
74
+ const result = AmountUtils.composeRateText("BTC", "ETH", "invalid");
75
+
76
+ result.should.equal("1 BTC ~ ? ETH");
77
+ });
78
+
79
+ it("Should return correct format for null rate", function () {
80
+ const result = AmountUtils.composeRateText("BTC", "ETH", null);
81
+
82
+ result.should.equal("1 BTC ~ ? ETH");
83
+ });
84
+
85
+ it("Should ensure that toIntegerString is called with correct parameter", function () {
86
+ AmountUtils.composeRateText("BTC", "ETH", "0.1");
87
+
88
+ toIntegerStringStub.calledWith(BigNumber("1")).should.be.true();
89
+ });
90
+
91
+ it("Should handle rate with different rightCurrencyDigitsAfterDots", function () {
92
+ const result = AmountUtils.composeRateText(
93
+ "BTC",
94
+ "ETH",
95
+ "0.123456789",
96
+ 5
97
+ );
98
+
99
+ result.should.equal("1 BTC ~ 0.12345 ETH");
100
+ });
101
+
102
+ it("Should handle rate with max rightCurrencyDigitsAfterDots", function () {
103
+ const result = AmountUtils.composeRateText(
104
+ "BTC",
105
+ "ETH",
106
+ "0.123456789",
107
+ 10
108
+ );
109
+
110
+ result.should.equal("1 BTC ~ 0.1234567890 ETH");
111
+ });
112
+
113
+ it("Should ensure proper rounding of right amount", function () {
114
+ const result = AmountUtils.composeRateText(
115
+ "BTC",
116
+ "ETH",
117
+ "0.123456789",
118
+ 4
119
+ );
120
+
121
+ result.should.equal("1 BTC ~ 0.1234 ETH");
122
+ });
123
+
124
+ it("Should handle great rightCurrencyDigitsAfterDots", function () {
125
+ const result = AmountUtils.composeRateText(
126
+ "BTC",
127
+ "ETH",
128
+ "0.123456789",
129
+ 20
130
+ );
131
+
132
+ result.should.equal("1 BTC ~ 0.12345678900000000000 ETH");
133
+ });
134
+
135
+ it("Should handle empty rate", function () {
136
+ const result = AmountUtils.composeRateText("BTC", "ETH", "");
137
+
138
+ result.should.equal("1 BTC ~ ? ETH");
139
+ });
140
+
141
+ it("Should handle negative rate", function () {
142
+ const result = AmountUtils.composeRateText("BTC", "ETH", "-0.1");
143
+
144
+ result.should.equal("1 BTC ~ -0.10000000 ETH");
145
+ });
146
+
147
+ it("Should return proper result for rate equal to zero", function () {
148
+ const result = AmountUtils.composeRateText("BTC", "ETH", "0");
149
+
150
+ result.should.equal("1 BTC ~ 0.00000000 ETH");
151
+ });
152
+
153
+ it("Should ensure that toIntegerString is called the correct number of times", function () {
154
+ AmountUtils.composeRateText("BTC", "ETH", "0.1");
155
+
156
+ toIntegerStringStub.callCount.should.equal(1);
157
+ });
158
+
159
+ it("Should handle rate with exponential notation", function () {
160
+ const result = AmountUtils.composeRateText("BTC", "ETH", "1e-8");
161
+
162
+ result.should.equal("1 BTC ~ 0.00000001 ETH");
163
+ });
164
+
165
+ it("Should return correct format when rate has a lot of trailing zeros", function () {
166
+ const result = AmountUtils.composeRateText(
167
+ "BTC",
168
+ "ETH",
169
+ "0.1000000000000000000000"
170
+ );
171
+
172
+ result.should.equal("1 BTC ~ 0.10000000 ETH");
173
+ });
174
+
175
+ it("Should handle zero rightCurrencyDigitsAfterDots", function () {
176
+ const result = AmountUtils.composeRateText(
177
+ "BTC",
178
+ "ETH",
179
+ "0.123456789",
180
+ 0
181
+ );
182
+
183
+ result.should.equal("100 BTC ~ 12 ETH");
184
+ });
185
+
186
+ it("Should handle negative rightCurrencyDigitsAfterDots", function () {
187
+ const result = AmountUtils.composeRateText(
188
+ "BTC",
189
+ "ETH",
190
+ "0.123456789",
191
+ -1
192
+ );
193
+
194
+ result.should.equal("1 BTC ~ 0.12345678 ETH");
195
+ });
196
+
197
+ it("Should handle rate input with trailing spaces", function () {
198
+ const result = AmountUtils.composeRateText("BTC", "ETH", " 0.1 ");
199
+
200
+ result.should.equal("1 BTC ~ 0.10000000 ETH");
201
+ });
202
+
203
+ it("Should handle rate input in scientific notation", function () {
204
+ const result = AmountUtils.composeRateText("BTC", "ETH", "1e-5");
205
+
206
+ result.should.equal("1 BTC ~ 0.00001000 ETH");
207
+ });
208
+ });
209
+ });
@@ -34,6 +34,7 @@
34
34
  border-radius: 50px;
35
35
  font-weight: $bold;
36
36
  margin-right: 3px;
37
+ text-wrap: nowrap;
37
38
  }
38
39
 
39
40
  &-icon-wrapper {
@@ -41,7 +41,10 @@ export const NoticeIcon = ({
41
41
  className={s["notice-icon-image"]}
42
42
  />
43
43
  ) : (
44
- <div className={s["notice-icon-image"]}>
44
+ <div
45
+ className={s["notice-icon-image"]}
46
+ onClick={() => setShowTooltip((prev) => !prev)}
47
+ >
45
48
  <NoticeQuestionIcon />
46
49
  </div>
47
50
  )}
@@ -6,7 +6,7 @@ import { generateQrAndShowInCanvas } from "../../../common/adapters/qrUtils";
6
6
 
7
7
  import s from "./qr-code.module.scss";
8
8
 
9
- export const QrCode = ({ address }) => {
9
+ export const QrCode = ({ address, fill = false }) => {
10
10
  const canvasRef = useRef();
11
11
 
12
12
  useEffect(() => {
@@ -22,11 +22,17 @@ export const QrCode = ({ address }) => {
22
22
  })();
23
23
  }, [address]);
24
24
 
25
- return <div className={s["qr-code"]} ref={canvasRef} />;
25
+ return (
26
+ <div
27
+ className={s["qr-code"] + (fill ? " " + s["fill"] : "")}
28
+ ref={canvasRef}
29
+ />
30
+ );
26
31
  };
27
32
 
28
33
  QrCode.propTypes = {
29
34
  address: PropTypes.string.isRequired,
35
+ fill: PropTypes.bool,
30
36
  };
31
37
 
32
38
  QrCode.defaultProps = {
@@ -6,4 +6,10 @@
6
6
  @media (max-width: $tablet-width) {
7
7
  margin: 0 auto;
8
8
  }
9
+
10
+ &.fill {
11
+ position: absolute;
12
+ width: 100% !important;
13
+ height: 100% !important;
14
+ }
9
15
  }
@@ -275,8 +275,8 @@ export const SwapForm = ({
275
275
  setRecepientAddress,
276
276
  setRecepientAddressExtraId,
277
277
  recepientAddressExtraIdAvailable = false,
278
- isFixed,
279
- setIsFixed,
278
+ displayRateSelector = false,
279
+ dispatchRateModeChanged = (isFixed) => {},
280
280
  }) => {
281
281
  const DETAIL_REFRESH_INTERVAL_MS = 1.5 * 60000;
282
282
 
@@ -310,6 +310,7 @@ export const SwapForm = ({
310
310
  );
311
311
  const [isLoading, setIsLoading] = useReferredState(false); // Whether the form is in the progress of loading some data (new rates, for example)
312
312
  const [isAddressFieldEnabled, setIsAddressFieldEnabled] = useState(false);
313
+ const [isFixedRate, setIsFixedRate] = useState(null);
313
314
 
314
315
  const [confirmButtonTo, setConfirmButtonTo] = useState(
315
316
  composeConfirmButtonTo(
@@ -498,7 +499,8 @@ export const SwapForm = ({
498
499
  sendingAssetTicker,
499
500
  receivingAssetTicker,
500
501
  amount,
501
- isSwapAll.current
502
+ isSwapAll.current,
503
+ isFixedRate
502
504
  );
503
505
 
504
506
  if (
@@ -619,6 +621,12 @@ export const SwapForm = ({
619
621
  }, e);
620
622
  };
621
623
 
624
+ const handleRateModeChanged = (isFixed) => {
625
+ setIsFixedRate(isFixed);
626
+ dispatchRateModeChanged(isFixed);
627
+ requestDataRefresh(sendAssetAmount.current, true);
628
+ };
629
+
622
630
  useEffect(() => {
623
631
  if (isSwapAll.current === true) {
624
632
  requestDataRefresh(undefined, true, true);
@@ -943,7 +951,9 @@ export const SwapForm = ({
943
951
  {AmountUtils.composeRateText(
944
952
  sendingAssetTickerPrintable,
945
953
  receivingAssetTickerPrintable,
946
- swapRate
954
+ swapRate,
955
+ receivingAssetDecimalCount,
956
+ isFixedRate
947
957
  )}
948
958
  </span>
949
959
  </>
@@ -1098,13 +1108,11 @@ export const SwapForm = ({
1098
1108
  ""
1099
1109
  )}
1100
1110
 
1101
- {typeof isFixed === "boolean" &&
1102
- setIsFixed &&
1103
- typeof setIsFixed === "function" ? (
1111
+ {displayRateSelector ? (
1104
1112
  <div className={s["swap-form-rate-selector"]}>
1105
1113
  <RateSelector
1106
- isFixed={isFixed}
1107
- setIsFixed={setIsFixed}
1114
+ isFixed={isFixedRate}
1115
+ setIsFixed={handleRateModeChanged}
1108
1116
  translations={translations.rateSelector}
1109
1117
  />
1110
1118
  </div>
@@ -1161,7 +1169,7 @@ export const SwapForm = ({
1161
1169
  fullWidthOnMobiles
1162
1170
  isDisabled={!readyToSwap}
1163
1171
  to={formHasBalance ? "" : confirmButtonTo}
1164
- loader={formHasBalance || isAddressFieldEnabled}
1172
+ loader={formHasBalance}
1165
1173
  handleError={callHandlingErrors}
1166
1174
  />
1167
1175
  </div>
@@ -167,13 +167,25 @@ export class SwapspaceSwapProvider extends SwapProvider {
167
167
  */
168
168
  const code = item.code.toUpperCase();
169
169
  const network = item.network.toUpperCase();
170
+ /** Removing ticker and protocol name from coin name as we usually use them explicitly
171
+ * from coin object rather than counting on having it in the coin name itself.
172
+ * This processing is needed due to poor quality of swapspace coins names. */
173
+ let name = (item.name ?? "")
174
+ .replaceAll(`(${code})`, "")
175
+ .replaceAll(`(${network})`, "")
176
+ .replaceAll(/ +/g, " ")
177
+ .trim();
178
+ if (name === "") {
179
+ // Rolling back to original name if our processing leads in empty name
180
+ name = item.name;
181
+ }
170
182
  const ticker = `${code}${
171
183
  code === network ? "" : network
172
184
  }`;
173
185
  const defaultDecimalPlacesForCoinNotSupportedOOB = 8;
174
186
  const defaultMinConfirmationsForCoinNotSupportedOOB = 1;
175
187
  coin = new Coin(
176
- item.name,
188
+ name,
177
189
  ticker,
178
190
  code,
179
191
  defaultDecimalPlacesForCoinNotSupportedOOB,
@@ -192,6 +192,123 @@ describe("swapspaceSwapProvider", function () {
192
192
  newCoin.doesUseOutputs.should.be.equal(false);
193
193
  });
194
194
 
195
+ describe("Should process name when creating custom coins", function () {
196
+ [
197
+ {
198
+ item: { code: "BTC", network: "BTC", name: " Bitcoin " },
199
+ expectedName: "Bitcoin",
200
+ },
201
+ {
202
+ item: {
203
+ code: "BTC",
204
+ network: "BTC",
205
+ name: " Bitcoin (BTC) ",
206
+ },
207
+ expectedName: "Bitcoin",
208
+ },
209
+ {
210
+ item: { code: "BTC", network: "BTC", name: "Bitcoin" },
211
+ expectedName: "Bitcoin",
212
+ },
213
+ {
214
+ item: { code: "BTC", network: "BTC", name: "BTC" },
215
+ expectedName: "BTC",
216
+ },
217
+ {
218
+ item: {
219
+ code: "BTC",
220
+ network: "BTC",
221
+ name: "Bitcoin (BTC)",
222
+ },
223
+ expectedName: "Bitcoin",
224
+ },
225
+ {
226
+ item: {
227
+ code: "BTC",
228
+ network: "BTC",
229
+ name: "Bitcoin (BTC) (BTC)",
230
+ },
231
+ expectedName: "Bitcoin",
232
+ },
233
+ {
234
+ item: { code: "BTC", network: "BTC", name: "BTC (BTC)" },
235
+ expectedName: "BTC",
236
+ },
237
+ {
238
+ item: { code: "BTC", network: "BTC", name: "(BTC) (BTC)" },
239
+ expectedName: "(BTC) (BTC)",
240
+ },
241
+ {
242
+ item: { code: "USDT", network: "ERC20", name: "Tether" },
243
+ expectedName: "Tether",
244
+ },
245
+ {
246
+ item: { code: "USDT", network: "ERC20", name: "USDT" },
247
+ expectedName: "USDT",
248
+ },
249
+ {
250
+ item: {
251
+ code: "USDT",
252
+ network: "ERC20",
253
+ name: "Tether (USDT)",
254
+ },
255
+ expectedName: "Tether",
256
+ },
257
+ {
258
+ item: {
259
+ code: "USDT",
260
+ network: "ERC20",
261
+ name: "Tether (USDT)",
262
+ },
263
+ expectedName: "Tether",
264
+ },
265
+ {
266
+ item: {
267
+ code: "USDT",
268
+ network: "ERC20",
269
+ name: "Tether (USDT) (ERC20)",
270
+ },
271
+ expectedName: "Tether",
272
+ },
273
+ {
274
+ item: {
275
+ code: "USDT",
276
+ network: "ERC20",
277
+ name: "USDT (ERC20)",
278
+ },
279
+ expectedName: "USDT",
280
+ },
281
+ {
282
+ item: {
283
+ code: "USDT",
284
+ network: "ERC20",
285
+ name: "(USDT) (ERC20)",
286
+ },
287
+ expectedName: "(USDT) (ERC20)",
288
+ },
289
+ ].forEach((testCase) => {
290
+ it("Should construct coins with default params if _customCoinBuilder return null for some and useRestrictedCoinsSet is false", async () => {
291
+ const someResp = {
292
+ data: [testCase.item],
293
+ };
294
+ axiosGetStub.resetBehavior();
295
+ axiosGetStub.resolves(someResp);
296
+ const p = new SwapspaceSwapProvider(
297
+ "/",
298
+ new Cache(),
299
+ () => null,
300
+ false
301
+ );
302
+
303
+ await p._fetchSupportedCurrenciesIfNeeded();
304
+
305
+ p._supportedCoins[0].coin.latinName.should.be.equal(
306
+ testCase.expectedName
307
+ );
308
+ });
309
+ });
310
+ });
311
+
195
312
  it("Should construct coins with null protocol and ticker===<uppercase code> if _customCoinBuilder return null for item and useRestrictedCoinsSet is false and code and network are equal for item", async () => {
196
313
  const someResp = {
197
314
  data: [