@rango-dev/ui 0.1.11-next.2 → 0.1.11-next.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/ui",
3
- "version": "0.1.11-next.2",
3
+ "version": "0.1.11-next.3",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -6,6 +6,7 @@ import { ArrowRightIcon } from '../Icon';
6
6
  import { Spacer } from '../Spacer';
7
7
  import { Spinner } from '../Spinner';
8
8
  import { Token } from './Token';
9
+ import { limitDecimalPlaces } from '../../helper';
9
10
 
10
11
  const Container = styled('div', {
11
12
  position: 'relative',
@@ -75,7 +76,7 @@ export function SwapDetail({
75
76
  logo: firstStep.fromBlockchainLogo || '',
76
77
  name: firstStep.fromBlockchain,
77
78
  },
78
- amount: swap.inputAmount,
79
+ amount: limitDecimalPlaces(swap.inputAmount),
79
80
  }}
80
81
  />
81
82
  <Spacer size={12} />
@@ -92,10 +93,11 @@ export function SwapDetail({
92
93
  logo: lastStep.toBlockchainLogo,
93
94
  name: lastStep.toBlockchain,
94
95
  },
95
- amount:
96
+ amount: limitDecimalPlaces(
96
97
  lastStep.outputAmount ||
97
- lastStep.expectedOutputAmountHumanReadable ||
98
- '',
98
+ lastStep.expectedOutputAmountHumanReadable ||
99
+ ''
100
+ ),
99
101
  }}
100
102
  />
101
103
  </div>
@@ -5,6 +5,7 @@ import { Spacer } from '../Spacer';
5
5
  const TokenContainer = styled('div', {
6
6
  display: 'flex',
7
7
  alignItems: 'center',
8
+ width: '160px',
8
9
 
9
10
  '& .amount': {
10
11
  fontWeight: 'bold',
@@ -1,11 +1,12 @@
1
- export const containsText = (text: string, searchText: string) =>
2
- text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
1
+ export function containsText(text: string, searchText: string): boolean {
2
+ return text.toLowerCase().indexOf(searchText.toLowerCase()) > -1;
3
+ }
3
4
 
4
- export const getConciseAddress = (
5
+ export function getConciseAddress(
5
6
  address: string | null,
6
7
  maxChars = 8,
7
8
  ellipsisLength = 3
8
- ): string | null => {
9
+ ): string | null {
9
10
  if (!address) return null;
10
11
  if (address.length < 2 * maxChars + ellipsisLength) return address;
11
12
  const start = Math.ceil((address.length - maxChars) / 2);
@@ -13,4 +14,18 @@ export const getConciseAddress = (
13
14
  return `${address.substr(start, maxChars)}${'.'.repeat(
14
15
  ellipsisLength
15
16
  )}${address.substr(end)}`;
16
- };
17
+ }
18
+
19
+ export function limitDecimalPlaces(
20
+ numberString: string,
21
+ maxDecimalPlaces = 4
22
+ ): string {
23
+ const number = parseFloat(numberString);
24
+ if (isNaN(number))
25
+ return numberString; // Return the original string if it's not a valid number
26
+ else {
27
+ const multiplier = Math.pow(10, maxDecimalPlaces);
28
+ const roundedNumber = Math.round(number * multiplier) / multiplier;
29
+ return roundedNumber.toString();
30
+ }
31
+ }