Skip to content

Commit

Permalink
feat: add "Verify Address" button for Ledger Nano (#7521)
Browse files Browse the repository at this point in the history
* feat: add "Verify Address" button for Ledger Nano

* feat: improvements

* refactor: improve literals

* chore: change menu item order

---------

Co-authored-by: Begoña Alvarez <[email protected]>
  • Loading branch information
cpl121 and begonaalvarezd authored Oct 11, 2023
1 parent 6ffad61 commit 8cb5111
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
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

0 comments on commit 8cb5111

Please sign in to comment.