Skip to content

Commit

Permalink
fix dangling session proxies hwn changing role
Browse files Browse the repository at this point in the history
  • Loading branch information
brenzi committed Dec 17, 2024
1 parent f4f7f1f commit 3ec3b28
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
3 changes: 0 additions & 3 deletions components/overlays/SessionProxiesOverlay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ const modifySessionProxyRole = async (
" expiry update to: " +
expiry,
);
// clear the cached proxy entry at old role. it will be added again with the new role
// at the next fetchIncogniteeBalance
accountStore.removeProxyForRole(bestSessionProxyRole.value);
const nonce = new u32(
new TypeRegistry(),
accountStore.nonce[incogniteeSidechain.value],
Expand Down
27 changes: 16 additions & 11 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ import { useSystemHealth } from "@/store/systemHealth";
import { useNotes } from "~/store/notes";
import { formatMoment } from "~/helpers/date";
import { Note, NoteDirection } from "~/lib/notes";
import { SessionProxyRole } from "@/lib/sessionProxyStorage.ts";
import {
SessionProxyRole,
sessionProxyRoleOrder,
} from "@/lib/sessionProxyStorage.ts";
import MessagingTab from "~/components/tabs/MessagingTab.vue";
import SwapTab from "~/components/tabs/SwapTab.vue";
import GovTab from "~/components/tabs/GovTab.vue";
Expand Down Expand Up @@ -275,16 +278,18 @@ const fetchIncogniteeBalance = async () => {
};
const storeSessionProxies = (proxies) => {
for (const proxy of proxies) {
const localKeyring = new Keyring({ type: "sr25519" });
const seed = hexToU8a(proxy.seed.toString());
const account = localKeyring.addFromSeed(seed);
accountStore.addSessionProxy(
account,
seed,
proxy.role.toString() as SessionProxyRole,
);
}
// Add the first entry for each role in proxies to the store
sessionProxyRoleOrder.forEach((role) => {
const proxy = proxies.find((p) => p.role.toString() === role);
if (proxy) {
const localKeyring = new Keyring({ type: "sr25519" });
const seed = hexToU8a(proxy.seed.toString());
const account = localKeyring.addFromSeed(seed);
accountStore.addSessionProxy(account, seed, role);
} else {
accountStore.removeProxyForRole(role);
}
});
};
const fetchNetworkStatus = async () => {
const promises = [];
Expand Down

0 comments on commit 3ec3b28

Please sign in to comment.