Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wallet manager local storage #348

Merged
merged 2 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Bug fixes

- [$348](https://github.com/alleslabs/celatone-frontend/pull/348) Workaround for the issue that walletManager local storage is not cleared when switching networks
- [$340](https://github.com/alleslabs/celatone-frontend/pull/340) Remove resend and redo button in accordion if relation is related (Past txs page)
- [#337](https://github.com/alleslabs/celatone-frontend/pull/337) Fix beforeunload keep showing up Leave modal
- [#330](https://github.com/alleslabs/celatone-frontend/pull/330) Fix proposal table component propagation
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "celatone",
"version": "0.1.0",
"version": "1.0.5",
"private": true,
"author": "sozonome",
"author": "Alles Labs",
"scripts": {
"dev": "next dev",
"build": "next build",
Expand Down
36 changes: 28 additions & 8 deletions src/lib/app-provider/hooks/useCurrentNetwork.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
import { useWallet } from "@cosmos-kit/react";
import { useRouter } from "next/router";

import { getNetworkByChainName } from "lib/data";
import type { Network } from "lib/data";

export const useCurrentNetwork = () => {
const { currentChainName } = useWallet();
const network = getNetworkByChainName(currentChainName);

return {
network,
isMainnet: network === "mainnet",
isTestnet: network === "testnet",
isLocalnet: network === "localnet",
};
const router = useRouter();

// Revisit: this is a hack to fix the issue of the walletManager being
try {
const network = getNetworkByChainName(currentChainName);
return {
network,
isMainnet: network === "mainnet",
isTestnet: network === "testnet",
isLocalnet: network === "localnet",
};
} catch (e) {
window.localStorage.removeItem("walletManager");

// eslint-disable-next-line no-console
console.log("remove walletManager");
router.reload();

// This is mock value, it will be replaced by the real value after the page is reloaded
return {
network: "mainnet" as Network,
isMainnet: true,
isTestnet: false,
isLocalnet: false,
};
}
};
Loading