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

feat: add "Verify Address" button for Ledger Nano #7521

Merged
merged 6 commits into from
Oct 11, 2023
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
36 changes: 35 additions & 1 deletion packages/desktop/components/modals/AccountActionsMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

import { selectedAccount } from '@core/account/stores'
import { localize } from '@core/i18n'
import { activeAccounts, visibleActiveAccounts } from '@core/profile/stores'
import { activeAccounts, isActiveLedgerProfile, visibleActiveAccounts } from '@core/profile/stores'
import { deleteAccount } from '@core/profile-manager/actions'

import { Icon } from '@auxiliary/icon/enums'
import { openPopup, PopupId } from '@auxiliary/popup'
import { profileManager } from '@core/profile-manager'
import { checkOrConnectLedger } from '@core/ledger'
import { showAppNotification } from '@auxiliary/notification'
import { handleError } from '@core/error/handlers'

export let modal: Modal = undefined

Expand All @@ -24,6 +28,29 @@
modal?.close()
}

function onVerifyAddressClick(): void {
const ADDRESS_INDEX = 0
checkOrConnectLedger(() => {
try {
if ($profileManager && $selectedAccount && $isActiveLedgerProfile) {
$profileManager.generateEd25519Address($selectedAccount.index, ADDRESS_INDEX, {
internal: false,
ledgerNanoPrompt: true,
})
showAppNotification({
type: 'info',
message: localize('general.verifyLedgerDepositAddress'),
})
}
} catch (err) {
handleError(err)
} finally {
modal?.close()
}
return Promise.resolve()
})
}

function onDeleteAccountClick(): void {
openPopup({
id: PopupId.DeleteAccount,
Expand All @@ -40,6 +67,13 @@
<account-actions-menu class="flex flex-col">
<MenuItem icon={Icon.Doc} title={localize('actions.viewBalanceBreakdown')} onClick={onViewBalanceClick} />
<MenuItem icon={Icon.Customize} title={localize('actions.customizeAcount')} onClick={onCustomiseAccountClick} />
{#if $isActiveLedgerProfile}
<MenuItem
icon={Icon.Ledger}
title={localize('actions.verifyDepositAddress')}
onClick={onVerifyAddressClick}
/>
{/if}
<ToggleHiddenAccountMenuItem onClick={modal?.close} />
<hr />
{#if showDeleteAccount}
Expand Down
4 changes: 3 additions & 1 deletion packages/shared/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@
"viewDownloads" : "View downloads",
"viewStatus": "View status",
"viewBalanceBreakdown": "View balance breakdown",
"verifyDepositAddress": "Verify deposit address",
"showHiddenAccounts": "Show hidden wallets",
"confirm": "Confirm",
"hideNetworkStatistics": "Hide network statistics",
Expand Down Expand Up @@ -1664,7 +1665,8 @@
"jwt": "JSON web token",
"internalTransaction": "Internal transaction",
"coinType":"Coin type",
"custom": "Custom"
"custom": "Custom",
"verifyLedgerDepositAddress": "Please check the ledger device and verify that the deposit address matches the one displayed on the ledger device"
},
"filters":{
"title": "Filters",
Expand Down
Loading