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 { isWalletConnected } = useSelector((state: RootState) => state.deposit)
const validatorRequests = [ const validatorRequests = [
{ name: '1', address: 'zQ3...9d4Gs0' }, { name: '1', address: 'zQ3asdf9d4Gs0' },
{ name: '2', address: 'zQ3...9d4Gs0' }, { name: '2', address: 'zQ3asdf9d4Gs0' },
] ]
const isTransactionConfirmation = false const isTransactionConfirmation = false

View File

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

View File

@ -26,3 +26,10 @@ export const convertSecondsToTimerFormat = (seconds: number) => {
export const formatNumberForGauge = (n: number): string => { export const formatNumberForGauge = (n: number): string => {
return n.toString().replace(/\./g, ',') 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}`
}