feat: create validator address format function

This commit is contained in:
RadoslavDimchev 2023-09-22 17:10:10 +03:00
parent 7b028aebf4
commit b441051a51
3 changed files with 12 additions and 3 deletions

View File

@ -18,8 +18,8 @@ const Deposit = () => {
const { isWalletConnected } = useSelector((state: RootState) => state.deposit)
const validatorRequests = [
{ name: '1', address: 'zQ3...9d4Gs0' },
{ name: '2', address: 'zQ3...9d4Gs0' },
{ name: '1', address: 'zQ3asdf9d4Gs0' },
{ name: '2', address: 'zQ3asdf9d4Gs0' },
]
const isTransactionConfirmation = false

View File

@ -1,6 +1,8 @@
import { Avatar, DividerLine, Text } from '@status-im/components'
import { XStack, YStack } from 'tamagui'
import { getFormattedValidatorAddress } from '../../../utilities'
type ValidatorRequestProps = {
validator: {
name: string
@ -25,7 +27,7 @@ const ValidatorRequest = ({ validator }: ValidatorRequestProps) => {
Validator {validator.name}
</Text>
<Text size={13} color="#647084">
{validator.address}
{getFormattedValidatorAddress(validator.address)}
</Text>
</YStack>
</XStack>

View File

@ -26,3 +26,10 @@ export const convertSecondsToTimerFormat = (seconds: number) => {
export const formatNumberForGauge = (n: number): string => {
return n.toString().replace(/\./g, ',')
}
export const getFormattedValidatorAddress = (address: string) => {
// zQ3asdf9d4Gs0 -> zQ3...9d4Gs0
const start = address.slice(0, 3)
const end = address.slice(-6)
return `${start}...${end}`
}