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

View File

@ -280,7 +280,7 @@ export function WalletProvider({ children }) {
}
}
const accounts = useMemo(() => {
const [accounts, derivedAccounts] = useMemo(() => {
if (!seed) {
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
}, [seed, walletCount, walletSelector, privateKeyImports, walletNames]);
@ -349,6 +350,7 @@ export function WalletProvider({ children }) {
privateKeyImports,
setPrivateKeyImports,
accounts,
derivedAccounts,
addAccount,
setAccountName,
derivationPath,
@ -466,6 +468,7 @@ export function useBalanceInfo(publicKey) {
export function useWalletSelector() {
const {
accounts,
derivedAccounts,
addAccount,
setWalletSelector,
setAccountName,
@ -475,6 +478,7 @@ export function useWalletSelector() {
return {
accounts,
derivedAccounts,
setWalletSelector,
addAccount,
setAccountName,