Skip to content

Commit

Permalink
fix: [ADN-409] Fix Cannot Sign Transaction popup
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Feb 1, 2024
1 parent af1aba3 commit 6c10f87
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 15 deletions.
2 changes: 0 additions & 2 deletions packages/adena-extension/src/hooks/use-current-account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ export const useCurrentAccount = (): {
return false;
}
await accountService.changeCurrentAccount(changedAccount);
const clone = wallet.clone();
clone.currentAccountId = changedAccount.id;
setCurrentAccount(changedAccount);
dispatchChangedEvent(changedAccount);
return true;
Expand Down
2 changes: 1 addition & 1 deletion packages/adena-extension/src/hooks/use-remove-account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const useRemoveAccount = (): {
clone.removeAccount(account);
const nextAccount = clone.accounts[clone.accounts.length - 1];
clone.currentAccountId = nextAccount.id;
await updateWallet(clone);
await changeCurrentAccount(nextAccount);
await updateWallet(clone);
return true;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ const useGoogleLoginScreen = (): UseGoogleLoginReturn => {
const web3AuthKeyring = await Web3AuthKeyring.fromPrivateKeyStr(privateKey);
const account = await SingleAccount.createBy(web3AuthKeyring, clone.nextAccountName);
clone.addAccount(account);
await changeCurrentAccount(account);
clone.addKeyring(web3AuthKeyring);
const storedAccount = clone.accounts.find((storedAccount) => storedAccount.id === account.id);
if (storedAccount) {
await changeCurrentAccount(storedAccount);
}
await updateWallet(clone);
navigate(RoutePath.WebAccountAddedComplete);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ const useSetupAirgapScreen = (): UseSetupAirgapScreenReturn => {
const clone = wallet.clone();
clone.addAccount(account);
clone.addKeyring(addressKeyring);

await changeCurrentAccount(account);
const storedAccount = clone.accounts.find((storedAccount) => storedAccount.id === account.id);
if (storedAccount) {
await changeCurrentAccount(storedAccount);
}
await updateWallet(clone);
navigate(RoutePath.WebAccountAddedComplete);
}, [address, walletService]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,11 @@ const useAccountImportScreen = ({ wallet }: { wallet: Wallet }): UseAccountImpor
const clone = wallet.clone();
clone.addAccount(account);
clone.addKeyring(keyring);

const storedAccount = clone.accounts.find((storedAccount) => storedAccount.id === account.id);
if (storedAccount) {
await changeCurrentAccount(storedAccount);
}
await updateWallet(clone);
await changeCurrentAccount(account);
navigate(RoutePath.WebAccountAddedComplete);
}
}, [step, privateKey, ableToSkipQuestionnaire, makePrivateKeyAccountAndKeyring]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ const useWalletCreateScreen = (): UseWalletCreateReturn => {
const clone = wallet.clone();
clone.addAccount(account);
clone.addKeyring(keyring);
const storedAccount = clone.accounts.find(
(storedAccount) => storedAccount.id === account.id,
);
if (storedAccount) {
await changeCurrentAccount(storedAccount);
}
await updateWallet(clone);
await changeCurrentAccount(account);
navigate(RoutePath.WebAccountAddedComplete);
} else {
const createdWallet = await AdenaWallet.createByMnemonic(seeds);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const RemoveAccount = (): JSX.Element => {
}
setState('LOADING');
await removeAccount(currentAccount);
navigate(RoutePath.Home);
navigate(RoutePath.Wallet);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import AccountDetails from '@components/pages/account-details/account-details';
import { useLoadAccounts } from '@hooks/use-load-accounts';
import { useNetwork } from '@hooks/use-network';
import { useAccountName } from '@hooks/use-account-name';
import { useCurrentAccount } from '@hooks/use-current-account';
import { CommonFullContentLayout } from '@components/atoms';
import useLink from '@hooks/use-link';
import { AdenaStorage } from '@common/storage';
Expand All @@ -20,7 +19,6 @@ const AccountDetailsContainer: React.FC = () => {
const { accounts } = useLoadAccounts();
const { currentNetwork } = useNetwork();
const { accountNames, changeAccountName } = useAccountName();
const { changeCurrentAccount } = useCurrentAccount();
const [originName, setOriginName] = useState('');
const [name, setName] = useState('');
const [address, setAddress] = useState<string>('');
Expand Down Expand Up @@ -55,9 +53,6 @@ const AccountDetailsContainer: React.FC = () => {
}, [address]);

const moveExportPrivateKey = useCallback(async () => {
if (account) {
await changeCurrentAccount(account);
}
const sessionStorage = AdenaStorage.session();
await sessionStorage.set(WALLET_EXPORT_TYPE_STORAGE_KEY, 'PRIVATE_KEY');
openSecurity();
Expand Down

0 comments on commit 6c10f87

Please sign in to comment.