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

fix: ledger regenerate address #2413

Merged
merged 1 commit into from
Feb 23, 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
11 changes: 6 additions & 5 deletions packages/shared/lib/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,14 @@ export const resetWallet = (): void => {
walletSetupType.set(null)
}

// used to make selectedAccount reactive to changes in the wallet
const _selectedAccountId = writable<AccountIdentifier | null>(null)
// Created to help selectedAccount reactivity.
// Use it to detected switches on selectedAccount
export const selectedAccountId = writable<AccountIdentifier | null>(null)

export const selectedAccount = derived([_selectedAccountId, get(wallet).accounts], ([$_selectedAccountId, $accounts]) =>
$accounts.find((acc) => acc.id === $_selectedAccountId)
export const selectedAccount = derived([selectedAccountId, get(wallet).accounts], ([$selectedAccountId, $accounts]) =>
$accounts.find((acc) => acc.id === $selectedAccountId)
)
export const setSelectedAccount = (id: AccountIdentifier): void => _selectedAccountId.set(id)
export const setSelectedAccount = (id: AccountIdentifier): void => selectedAccountId.set(id)
export const getAccountById = (id: AccountIdentifier): WalletAccount | null => {
const accounts = get(wallet)?.accounts
return get(accounts)?.find((account) => account.id === id) || null
Expand Down
9 changes: 3 additions & 6 deletions packages/shared/routes/dashboard/wallet/Wallet.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
processMigratedTransactions,
removeEventListeners,
selectedAccount,
selectedAccountId,
setSelectedAccount,
transferState,
updateBalanceOverview,
Expand Down Expand Up @@ -112,12 +113,8 @@
let isGeneratingAddress = false

// If account changes force regeneration of Ledger receive address
$: {
// TODO: fix this, selectedAccount changes triggers too many times
selectedAccount?.id
if ($isLedgerProfile) {
hasGeneratedALedgerReceiveAddress.set(false)
}
$: if ($selectedAccountId && $isLedgerProfile) {
hasGeneratedALedgerReceiveAddress.set(false)
}

$: if ($accountsLoaded) {
Expand Down