Skip to content

Commit 67eca1f

Browse files
authored
Merge pull request #350 from alleslabs/release/v1.0.5v2
Fix wallet manager local storage (For v1.0.5)
2 parents daf3e57 + ea75940 commit 67eca1f

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5555

5656
### Bug fixes
5757

58+
- [$348](https://github.com/alleslabs/celatone-frontend/pull/348) Workaround for the issue that walletManager local storage is not cleared when switching networks
5859
- [$340](https://github.com/alleslabs/celatone-frontend/pull/340) Remove resend and redo button in accordion if relation is related (Past txs page)
5960
- [#337](https://github.com/alleslabs/celatone-frontend/pull/337) Fix beforeunload keep showing up Leave modal
6061
- [#330](https://github.com/alleslabs/celatone-frontend/pull/330) Fix proposal table component propagation

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "celatone",
3-
"version": "0.1.0",
3+
"version": "1.0.5",
44
"private": true,
5-
"author": "sozonome",
5+
"author": "Alles Labs",
66
"scripts": {
77
"dev": "next dev",
88
"build": "next build",
Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,35 @@
11
import { useWallet } from "@cosmos-kit/react";
2+
import { useRouter } from "next/router";
23

34
import { getNetworkByChainName } from "lib/data";
5+
import type { Network } from "lib/data";
46

57
export const useCurrentNetwork = () => {
68
const { currentChainName } = useWallet();
7-
const network = getNetworkByChainName(currentChainName);
8-
9-
return {
10-
network,
11-
isMainnet: network === "mainnet",
12-
isTestnet: network === "testnet",
13-
isLocalnet: network === "localnet",
14-
};
9+
const router = useRouter();
10+
11+
// Revisit: this is a hack to fix the issue of the walletManager being
12+
try {
13+
const network = getNetworkByChainName(currentChainName);
14+
return {
15+
network,
16+
isMainnet: network === "mainnet",
17+
isTestnet: network === "testnet",
18+
isLocalnet: network === "localnet",
19+
};
20+
} catch (e) {
21+
window.localStorage.removeItem("walletManager");
22+
23+
// eslint-disable-next-line no-console
24+
console.log("remove walletManager");
25+
router.reload();
26+
27+
// This is mock value, it will be replaced by the real value after the page is reloaded
28+
return {
29+
network: "mainnet" as Network,
30+
isMainnet: true,
31+
isTestnet: false,
32+
isLocalnet: false,
33+
};
34+
}
1535
};

0 commit comments

Comments
 (0)