diff --git a/apps/web/src/components/Onboarding/SetupPassword/useGetSetupPasswordSubmitHandler.tsx b/apps/web/src/components/Onboarding/SetupPassword/useGetSetupPasswordSubmitHandler.tsx
index bf703ccbe2..3cbf9caaa5 100644
--- a/apps/web/src/components/Onboarding/SetupPassword/useGetSetupPasswordSubmitHandler.tsx
+++ b/apps/web/src/components/Onboarding/SetupPassword/useGetSetupPasswordSubmitHandler.tsx
@@ -33,8 +33,8 @@ const useGetSecretKeyHandler = () => {
allFormValues.current?.secretKey,
allFormValues.current?.secretKeyPassword
);
- setupPersistence(secretKey);
await restoreFromSecretKey(secretKey, password, DEFAULT_ACCOUNT_LABEL);
+ setupPersistence(secretKey);
};
};
@@ -60,9 +60,7 @@ const useGetMnemonicHandler = () => {
isVerified: !isNewMnemonic,
});
- // Initialize persistence with mnemonic
setupPersistence(mnemonic);
-
if (isNewMnemonic) {
dispatch(accountsActions.setPassword(password));
dispatch(accountsActions.setCurrent(accounts[0].address.pkh));
@@ -77,7 +75,6 @@ const useGetVerificationHandler = () => {
return async (password: string) => {
const mnemonic = await getDecryptedMnemonic(currentAccount as MnemonicAccount, password);
- setupPersistence(mnemonic);
return openWith(, { size: "xl" });
};
};
diff --git a/apps/web/src/utils/store.ts b/apps/web/src/utils/store.ts
index 55e5cc3ab1..a6eb1b6dcc 100644
--- a/apps/web/src/utils/store.ts
+++ b/apps/web/src/utils/store.ts
@@ -1,4 +1,4 @@
-import { getOrCreateUserNonce, initializePersistence, makeStore } from "@umami/state";
+import { accountsActions, getOrCreateUserNonce, initializePersistence, makeStore} from "@umami/state";
import { persistor, setupPersistor } from "./persistor";
@@ -17,6 +17,7 @@ export const setupPersistence = (key: string) => {
}
const { persistor } = initializePersistence(store, nonce);
setupPersistor(persistor);
+ store.dispatch(accountsActions.setDefaultAccount());
} catch (error) {
console.error("Failed to initialize persistence:", error);
return null;
diff --git a/packages/state/src/beacon/WalletClient.ts b/packages/state/src/beacon/WalletClient.ts
index d7f1690f31..9fec0fa4a7 100644
--- a/packages/state/src/beacon/WalletClient.ts
+++ b/packages/state/src/beacon/WalletClient.ts
@@ -21,7 +21,7 @@ export const logout = (persistor: Persistor) =>
const migrationCompleted = localStorage.getItem("migration_to_2_3_5_completed");
localStorage.clear(); // TODO: fix for react-native
-
+ sessionStorage.clear();
if (migrationCompleted) {
localStorage.setItem("migration_to_2_3_5_completed", "true");
}
diff --git a/packages/state/src/reducer.ts b/packages/state/src/reducer.ts
index fd97cf8568..87c6e3ffcf 100644
--- a/packages/state/src/reducer.ts
+++ b/packages/state/src/reducer.ts
@@ -90,12 +90,14 @@ export const makePersistConfigs = (storage_: Storage | undefined, password?: str
migrate: createAsyncMigrate(accountsMigrations, { debug: false }),
blacklist: ["password"],
transforms: [
- encryptTransform({
- secretKey: password,
- onError: error => {
- console.error("Error encrypting accounts state:", error);
- },
- }),
+ encryptTransform(
+ {
+ secretKey: password,
+ onError: error => {
+ console.error("Error encrypting accounts state:", error);
+ },
+ }, { blacklist: ["defaultAccount"] }
+ ),
],
};
diff --git a/packages/state/src/slices/accounts/State.ts b/packages/state/src/slices/accounts/State.ts
index 839db70853..19f3994433 100644
--- a/packages/state/src/slices/accounts/State.ts
+++ b/packages/state/src/slices/accounts/State.ts
@@ -8,6 +8,7 @@ export type AccountsState = {
seedPhrases: Record;
secretKeys: Record;
current?: RawPkh | undefined;
+ defaultAccount?: ImplicitAccount | undefined;
password?: string | undefined;
alerts: {
isSocialLoginWarningShown: boolean;
diff --git a/packages/state/src/slices/accounts/accounts.ts b/packages/state/src/slices/accounts/accounts.ts
index bb16ee00d3..fe973d9917 100644
--- a/packages/state/src/slices/accounts/accounts.ts
+++ b/packages/state/src/slices/accounts/accounts.ts
@@ -14,6 +14,7 @@ import { remove } from "lodash";
import { type AccountsState } from "./State";
import { changeMnemonicPassword } from "../../thunks/changeMnemonicPassword";
+import { IDP } from "@umami/social-auth";
export const accountsInitialState: AccountsState = {
items: [],
@@ -98,6 +99,9 @@ export const accountsSlice = createSlice({
);
if (accountToRename) {
accountToRename.label = newName;
+ if (state.defaultAccount?.address.pkh === accountToRename.address.pkh) {
+ state.defaultAccount.label = newName;
+ }
}
},
/**
@@ -137,6 +141,11 @@ export const accountsSlice = createSlice({
setCurrent: (state, { payload: address }: { payload: RawPkh | undefined }) => {
state.current = address;
},
+ setDefaultAccount: (state) => {
+ if (!state.defaultAccount) {
+ state.defaultAccount = hideConfidentialData(state.items[0]);
+ }
+ },
setIsVerified: (
state,
{ payload: { pkh, isVerified } }: { payload: { pkh: RawPkh; isVerified: boolean } }
@@ -176,4 +185,19 @@ const concatUnique = (existingAccounts: ImplicitAccount[], newAccounts: Implicit
return [...existingAccounts, ...newAccounts];
};
+function hideConfidentialData(acct: ImplicitAccount): ImplicitAccount {
+ // create a new object from account
+ const account = ({ ...acct } as ImplicitAccount);
+ if (account.type === "social") {
+ if (account.label.includes("@")) {
+ account.label = account.label.slice(0, 2) + "..." + account.label.slice(account.label.indexOf("@"));
+ }
+ }
+ account.pk = "********";
+ if (account.type === "mnemonic") {
+ account.seedFingerPrint = "********";
+ }
+ return account;
+}
+
export const accountsActions = accountsSlice.actions;
diff --git a/packages/state/src/thunks/secretKeyAccount.ts b/packages/state/src/thunks/secretKeyAccount.ts
index c4997ea5fa..5ceff4878a 100644
--- a/packages/state/src/thunks/secretKeyAccount.ts
+++ b/packages/state/src/thunks/secretKeyAccount.ts
@@ -57,5 +57,6 @@ export const restoreFromSecretKey =
password,
});
dispatch(accountsActions.addAccount(account));
+ dispatch(accountsActions.setDefaultAccount());
dispatch(accountsActions.addSecretKey({ pkh: account.address.pkh, encryptedSecretKey }));
};