Skip to content

Commit

Permalink
Fix UI issue with showing mini secret key
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Aug 16, 2023
1 parent fccd890 commit b3b853e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/components/auth/ProfileModal/contents/PrivateKeyContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import { useMemo } from 'react'

function PrivateKeyContent() {
const encodedSecretKey = useMyAccount((state) => state.encodedSecretKey)
const secretKey = useMemo(() => {
const { secretKey, isUsingMiniSecret } = useMemo(() => {
const decodedSecretKey = decodeSecretKey(encodedSecretKey ?? '')
if (isSecretKeyUsingMiniSecret(decodedSecretKey)) {
return `0x${decodedSecretKey}`
return { secretKey: `0x${decodedSecretKey}`, isUsingMiniSecret: true }
}

return Buffer.from(decodedSecretKey, 'hex').toString()
return {
secretKey: Buffer.from(decodedSecretKey, 'hex').toString(),
isUsingMiniSecret: false,
}
}, [encodedSecretKey])

const sendEvent = useSendEvent()
Expand All @@ -26,7 +29,12 @@ function PrivateKeyContent() {
Grill secret key is like a long password. We recommend keeping it in a
safe place, so you can recover your account.
</p>
<CopyText onCopyClick={onCopyClick} isCodeText text={secretKey || ''} />
<CopyText
onCopyClick={onCopyClick}
isCodeText
wordBreakType={isUsingMiniSecret ? 'all' : 'words'}
text={secretKey || ''}
/>
</div>
)
}
Expand Down

0 comments on commit b3b853e

Please sign in to comment.