From a78bddb644eceb76464d8899f0ee79d3559020b6 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Fri, 19 May 2023 17:15:33 +0700 Subject: [PATCH 1/2] fix: wallet manager local storage --- package.json | 4 +-- .../app-provider/hooks/useCurrentNetwork.ts | 36 ++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 8a0c05ed8..bf28f2402 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/lib/app-provider/hooks/useCurrentNetwork.ts b/src/lib/app-provider/hooks/useCurrentNetwork.ts index 236dba279..d7675b535 100644 --- a/src/lib/app-provider/hooks/useCurrentNetwork.ts +++ b/src/lib/app-provider/hooks/useCurrentNetwork.ts @@ -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, + }; + } }; From 9858ae730b914a99241b7653d7cc4203fbbdbfc1 Mon Sep 17 00:00:00 2001 From: evilpeach Date: Fri, 19 May 2023 17:21:34 +0700 Subject: [PATCH 2/2] docs: add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2afc77c23..0a4755ed0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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