-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from alleslabs/fix/wallet-manager
fix: wallet manager local storage
- Loading branch information
Showing
3 changed files
with
31 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; | ||
} | ||
}; |
e1db5be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
osmosis-celatone-frontend-staging – ./
osmosis-celatone-frontend-staging-alleslabs.vercel.app
osmosis-celatone-frontend-staging-git-develop-alleslabs.vercel.app
celatone-frontend-staging.vercel.app
osmosis-staging.celat.one
celatone-staging.osmosis.zone