@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/dist/helper/index.d.ts +3 -2
- package/dist/ui.cjs.development.js +19 -6
- package/dist/ui.cjs.development.js.map +1 -1
- package/dist/ui.cjs.production.min.js +1 -1
- package/dist/ui.cjs.production.min.js.map +1 -1
- package/dist/ui.esm.js +19 -6
- package/dist/ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/SwapDetail/SwapDetail.tsx +6 -4
- package/src/components/SwapDetail/Token.tsx +1 -0
- package/src/helper/index.ts +20 -5
package/package.json
CHANGED
|
@@ -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
|
-
|
|
98
|
-
|
|
98
|
+
lastStep.expectedOutputAmountHumanReadable ||
|
|
99
|
+
''
|
|
100
|
+
),
|
|
99
101
|
}}
|
|
100
102
|
/>
|
|
101
103
|
</div>
|
package/src/helper/index.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export
|
|
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
|
|
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
|
+
}
|