-
Notifications
You must be signed in to change notification settings - Fork 20
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 #350 from alleslabs/release/v1.0.5v2
Fix wallet manager local storage (For v1.0.5)
- 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, | ||
}; | ||
} | ||
}; |
67eca1f
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 – ./
osmosis-celatone-frontend-alleslabs.vercel.app
osmosis-celatone-frontend-git-main-alleslabs.vercel.app
celatone-frontend.vercel.app
celatone.osmosis.zone
osmosis.celat.one
67eca1f
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:
terra-celatone-frontend – ./
terra-celatone-frontend.vercel.app
terra-celatone-frontend-alleslabs.vercel.app
terra-celatone-frontend-git-main-alleslabs.vercel.app