Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add note when import filecoin private key, also make desc link clickable (uplift to 1.41.x) #13856

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions components/brave_wallet/browser/brave_wallet_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ constexpr webui::LocalizedString kLocalizedStrings[] = {
IDS_BRAVE_WALLET_ACCOUNT_SETTINGS_DISCLAIMER},
{"braveWalletFilExportPrivateKeyFormatDescription",
IDS_BRAVE_WALLET_FIL_EXPORT_PRIVATE_KEY_FORMAT_DESCRIPTION},
{"braveWalletFilImportPrivateKeyFormatDescription",
IDS_BRAVE_WALLET_FIL_IMPORT_PRIVATE_KEY_FORMAT_DESCRIPTION},
{"braveWalletAccountSettingsShowKey",
IDS_BRAVE_WALLET_ACCOUNT_SETTINGS_SHOW_KEY},
{"braveWalletAccountSettingsHideKey",
Expand Down
6 changes: 6 additions & 0 deletions components/brave_wallet_ui/common/constants/urls.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) 2022 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// you can obtain one at http://mozilla.org/MPL/2.0/.

export const FILECOIN_FORMAT_DESCRIPTION_URL = 'https://lotus.filecoin.io/lotus/manage/lotus-cli/#lotus-wallet-import'
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import {
AccountSettingsNavOptions,
HardwareAccountSettingsNavOptions
} from '../../../../options/account-settings-nav-options'
import { FILECOIN_FORMAT_DESCRIPTION_URL } from '../../../../common/constants/urls'
import { reduceAddress } from '../../../../utils/reduce-address'
import { copyToClipboard } from '../../../../utils/copy-to-clipboard'
import { NavButton } from '../../../extension'
import { Tooltip } from '../../../shared'
import { getLocale } from '../../../../../common/locale'
import { getLocale, getLocaleWithTag } from '../../../../../common/locale'

// Styled Components
import {
Expand Down Expand Up @@ -151,6 +152,9 @@ const AddAccountModal = (props: Props) => {
: AccountSettingsNavOptions()
}, [account])

const filPrivateKeyFormatDescriptionTextParts =
getLocaleWithTag('braveWalletFilExportPrivateKeyFormatDescription')

return (
<PopupModal title={title} onClose={onClickClose}>
{!hideNav &&
Expand Down Expand Up @@ -200,7 +204,13 @@ const AddAccountModal = (props: Props) => {
</WarningWrapper>
{showPrivateKey && account.coin === BraveWallet.CoinType.FIL &&
<WarningWrapper>
<WarningText>{getLocale('braveWalletFilExportPrivateKeyFormatDescription')}</WarningText>
<WarningText>
{filPrivateKeyFormatDescriptionTextParts.beforeTag}
<a target='_blank' href={FILECOIN_FORMAT_DESCRIPTION_URL}>
{filPrivateKeyFormatDescriptionTextParts.duringTag}
</a>
{filPrivateKeyFormatDescriptionTextParts.afterTag}
</WarningText>
</WarningWrapper>
}
{showPrivateKey &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ export const WarningText = styled.span`
letter-spacing: 0.01em;
text-align: center;
color: ${(p) => p.theme.color.text02};
a {
color: inherit;
text-decoration: underline;
}
`

export const PrivateKeyBubble = styled(WalletButton)`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { useDispatch, useSelector } from 'react-redux'
import { useHistory, useParams } from 'react-router'

// utils
import { getLocale } from '$web-common/locale'
import { FILECOIN_FORMAT_DESCRIPTION_URL } from '../../../../common/constants/urls'
import { getLocale, getLocaleWithTag } from '$web-common/locale'
import { copyToClipboard } from '../../../../utils/copy-to-clipboard'

// options
Expand Down Expand Up @@ -38,6 +39,11 @@ import {
StyledWrapper
} from './style'

import {
WarningText,
WarningWrapper
} from '../account-settings-modal/style'

interface Params {
accountTypeName: string
}
Expand Down Expand Up @@ -187,6 +193,9 @@ export const ImportAccountModal = () => {
? getLocale('braveWalletCreateAccountImportAccount').replace('$1', selectedAccountType.name)
: getLocale('braveWalletAddAccountImport')

const filPrivateKeyFormatDescriptionTextParts =
getLocaleWithTag('braveWalletFilImportPrivateKeyFormatDescription')

// render
return (
<PopupModal title={modalTitle} onClose={onClickClose}>
Expand All @@ -206,6 +215,17 @@ export const ImportAccountModal = () => {
<DisclaimerText>{getLocale('braveWalletImportAccountDisclaimer')}</DisclaimerText>
</ImportDisclaimer>

{selectedAccountType?.coin === BraveWallet.CoinType.FIL &&
<WarningWrapper>
<WarningText>
{filPrivateKeyFormatDescriptionTextParts.beforeTag}
<a target='_blank' href={FILECOIN_FORMAT_DESCRIPTION_URL}>
{filPrivateKeyFormatDescriptionTextParts.duringTag}
</a>
{filPrivateKeyFormatDescriptionTextParts.afterTag}</WarningText>
</WarningWrapper>
}

{selectedAccountType?.coin === BraveWallet.CoinType.ETH &&
<SelectWrapper>
<Select
Expand Down
3 changes: 2 additions & 1 deletion components/resources/wallet_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@
<message name="IDS_BRAVE_WALLET_ICON_URL" desc="Visible assets modal Icon URL label">Icon URL</message>
<message name="IDS_BRAVE_WALLET_ADD_ASSET" desc="Asset Panel add asset button">Add asset</message>
<message name="IDS_BRAVE_WALLET_ACCOUNT_SETTINGS_DISCLAIMER" desc="Account settings modal warning">WARNING: Never share your recovery phrase. Anyone with this phrase can take your assets forever.</message>
<message name="IDS_BRAVE_WALLET_FIL_EXPORT_PRIVATE_KEY_FORMAT_DESCRIPTION" desc="Filecoin private key format description">NOTE: Private key is provided as a hex-encoded JSON that contains private key and protocol information. See https://lotus.filecoin.io/lotus/manage/lotus-cli/#lotus-wallet-import for more info.</message>
<message name="IDS_BRAVE_WALLET_FIL_EXPORT_PRIVATE_KEY_FORMAT_DESCRIPTION" desc="Filecoin private key format description">NOTE: Private key is provided as a hex-encoded JSON that contains private key and protocol information. <ph name="LINK_START">$1</ph>Learn more<ph name="LINK_END">$2</ph>.</message>
<message name="IDS_BRAVE_WALLET_FIL_IMPORT_PRIVATE_KEY_FORMAT_DESCRIPTION" desc="Filecoin private key format description">NOTE: Private key must be provided as a hex-encoded JSON that contains private key and protocol information. <ph name="LINK_START">$1</ph>Learn more<ph name="LINK_END">$2</ph>.</message>
<message name="IDS_BRAVE_WALLET_ACCOUNT_SETTINGS_SHOW_KEY" desc="Account settings modal show key button">Show key</message>
<message name="IDS_BRAVE_WALLET_ACCOUNT_SETTINGS_HIDE_KEY" desc="Account settings modal hide key button">Hide key</message>
<message name="IDS_BRAVE_WALLET_ACCOUNT_SETTINGS_UPDATE_ERROR" desc="Account settings modal failed to updated name error">Failed to update account name, please try again.</message>
Expand Down