-
Notifications
You must be signed in to change notification settings - Fork 15
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 #129 from alleslabs/fix/persist-wallet
fix: wallet disconnection on network change
- Loading branch information
Showing
4 changed files
with
31 additions
and
16 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { useWallet } from "@cosmos-kit/react"; | ||
import { useRouter } from "next/router"; | ||
import { useEffect, useRef } from "react"; | ||
|
||
import { getChainNameByNetwork } from "lib/data"; | ||
|
||
export const useNetworkChange = () => { | ||
const router = useRouter(); | ||
const { currentChainName, setCurrentChain } = useWallet(); | ||
const networkRef = useRef<string>(); | ||
|
||
/** | ||
* @todos Change default to mainnet later (currently is testnet) | ||
*/ | ||
|
||
useEffect(() => { | ||
const networkRoute = (router.query.network as string) || "testnet"; | ||
|
||
if (networkRoute !== networkRef.current) { | ||
networkRef.current = networkRoute; | ||
const chainName = getChainNameByNetwork(networkRoute); | ||
if (currentChainName !== chainName) setCurrentChain(chainName); | ||
} | ||
}, [router.query.network, currentChainName, setCurrentChain]); | ||
}; |
2cc39df
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-alles-labs.vercel.app
osmosis-celatone-frontend-staging-git-develop-alles-labs.vercel.app
celatone-frontend-staging.vercel.app
osmosis-staging.celat.one
2cc39df
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-staging – ./
terra-celatone-frontend-staging.vercel.app
terra-celatone-frontend-staging-alles-labs.vercel.app
terra-celatone-frontend-staging-git-develop-alles-labs.vercel.app
terra-staging.celat.one