Skip to content

Commit

Permalink
Merge pull request #348 from alleslabs/fix/wallet-manager
Browse files Browse the repository at this point in the history
fix: wallet manager local storage
  • Loading branch information
evilpeach committed May 19, 2023
2 parents 9b6d005 + 9858ae7 commit e1db5be
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
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,
};
}
};

1 comment on commit e1db5be

@vercel
Copy link

@vercel vercel bot commented on e1db5be May 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.