Fix wallet selection

This commit is contained in:
armaniferrante 2021-04-21 11:13:34 -07:00
parent cc9d882ffe
commit 275801931e
No known key found for this signature in database
GPG Key ID: 58BEF301E91F7828
2 changed files with 8 additions and 3 deletions

View File

@ -241,6 +241,7 @@ function NetworkSelector() {
function WalletSelector() { function WalletSelector() {
const { const {
accounts, accounts,
derivedAccounts,
hardwareWalletAccount, hardwareWalletAccount,
setHardwareWalletAccount, setHardwareWalletAccount,
setWalletSelector, setWalletSelector,
@ -290,7 +291,7 @@ function WalletSelector() {
onAdd={({ name, importedAccount }) => { onAdd={({ name, importedAccount }) => {
addAccount({ name, importedAccount }); addAccount({ name, importedAccount });
setWalletSelector({ setWalletSelector({
walletIndex: importedAccount ? undefined : accounts.length, walletIndex: importedAccount ? undefined : derivedAccounts.length,
importedPubkey: importedAccount importedPubkey: importedAccount
? importedAccount.publicKey.toString() ? importedAccount.publicKey.toString()
: undefined, : undefined,

View File

@ -280,7 +280,7 @@ export function WalletProvider({ children }) {
} }
} }
const accounts = useMemo(() => { const [accounts, derivedAccounts] = useMemo(() => {
if (!seed) { if (!seed) {
return []; return [];
} }
@ -316,7 +316,8 @@ export function WalletProvider({ children }) {
}; };
}); });
return derivedAccounts.concat(importedAccounts); const accounts = derivedAccounts.concat(importedAccounts);
return [accounts, derivedAccounts];
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [seed, walletCount, walletSelector, privateKeyImports, walletNames]); }, [seed, walletCount, walletSelector, privateKeyImports, walletNames]);
@ -349,6 +350,7 @@ export function WalletProvider({ children }) {
privateKeyImports, privateKeyImports,
setPrivateKeyImports, setPrivateKeyImports,
accounts, accounts,
derivedAccounts,
addAccount, addAccount,
setAccountName, setAccountName,
derivationPath, derivationPath,
@ -466,6 +468,7 @@ export function useBalanceInfo(publicKey) {
export function useWalletSelector() { export function useWalletSelector() {
const { const {
accounts, accounts,
derivedAccounts,
addAccount, addAccount,
setWalletSelector, setWalletSelector,
setAccountName, setAccountName,
@ -475,6 +478,7 @@ export function useWalletSelector() {
return { return {
accounts, accounts,
derivedAccounts,
setWalletSelector, setWalletSelector,
addAccount, addAccount,
setAccountName, setAccountName,