diff --git a/src/components/General/ValidatorNameAddress.tsx b/src/components/General/ValidatorNameAddress.tsx index 24b52dff..fc30c1f3 100644 --- a/src/components/General/ValidatorNameAddress.tsx +++ b/src/components/General/ValidatorNameAddress.tsx @@ -2,7 +2,7 @@ import { Text } from '@status-im/components' import { XStack, YStack } from 'tamagui' import { CopyIcon, VerifiedIcon, ContactIcon } from '@status-im/icons' -import { getFormattedValidatorAddress } from '../../utilities' +import { copyFunction, getFormattedValidatorAddress } from '../../utilities' type ValidatorNameAddressProps = { name: string @@ -18,7 +18,7 @@ const ValidatorNameAddress = ({ isAvatarChipIncluded, }: ValidatorNameAddressProps) => { const onCopyAddress = () => { - navigator.clipboard.writeText(address) + copyFunction(address) } return ( diff --git a/src/pages/PairDevice/GenerateId.tsx b/src/pages/PairDevice/GenerateId.tsx index bdd0d04c..0b037249 100644 --- a/src/pages/PairDevice/GenerateId.tsx +++ b/src/pages/PairDevice/GenerateId.tsx @@ -7,6 +7,7 @@ import { Separator, YStack } from 'tamagui' import { v4 as uuidv4 } from 'uuid' import styles from './pairDevice.module.css' +import { copyFunction } from '../../utilities' type GenerateIdProps = { isAwaitingPairing: boolean @@ -24,7 +25,7 @@ const GenerateId = ({ isAwaitingPairing }: GenerateIdProps) => { } const copyGeneratedIdHandler = () => { - navigator.clipboard.writeText(generatedId) + copyFunction(generatedId) } return ( diff --git a/src/pages/ValidatorOnboarding/KeyGeneration/RecoveryPhrase.tsx b/src/pages/ValidatorOnboarding/KeyGeneration/RecoveryPhrase.tsx index 59c8b928..b2b5259c 100644 --- a/src/pages/ValidatorOnboarding/KeyGeneration/RecoveryPhrase.tsx +++ b/src/pages/ValidatorOnboarding/KeyGeneration/RecoveryPhrase.tsx @@ -9,6 +9,7 @@ import wordlist from 'web-bip39/wordlists/english' import { RootState } from '../../../redux/store' import { setGeneratedMnemonic } from '../../../redux/ValidatorOnboarding/KeyGeneration/slice' import styles from './index.module.css' +import { copyFunction } from '../../../utilities' type RecoveryPhraseProps = { isKeystoreFiles: boolean @@ -39,8 +40,7 @@ const RecoveryPhrase = ({ isKeystoreFiles }: RecoveryPhraseProps) => { } const copyRecoveryPhraseHandler = () => { - const text = generatedMnemonic.join(' ') - navigator.clipboard.writeText(text) + copyFunction(generatedMnemonic.join(' ')) if (!isTimeoutActive) { setIsCopied(true) diff --git a/src/utilities.ts b/src/utilities.ts index 2db499a0..518321f0 100644 --- a/src/utilities.ts +++ b/src/utilities.ts @@ -68,3 +68,7 @@ export const getHeightPercentages = (amountOfElements: number) => { return `${percentages}%` } + +export const copyFunction = (text: string) => { + navigator.clipboard.writeText(text) +} \ No newline at end of file