-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace hardcoded sanchonet with the network from network metrics
- Loading branch information
1 parent
2f3d2f0
commit 4683985
Showing
28 changed files
with
7,648 additions
and
2,846 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,51 @@ | ||
import React, { | ||
createContext, | ||
PropsWithChildren, | ||
useContext, | ||
useMemo, | ||
} from "react"; | ||
|
||
type AppContextType = { | ||
networkName: string; | ||
network: string; | ||
cExplorerBaseUrl: string; | ||
}; | ||
|
||
const AppContext = createContext<AppContextType | null>(null); | ||
|
||
/** | ||
* Provides app context to its children components. | ||
* | ||
* @param children - The child components to render. | ||
*/ | ||
const AppContextMockProvider = ({ children }: PropsWithChildren) => { | ||
const value = useMemo( | ||
() => ({ | ||
networkName: "Mainnet", | ||
network: "mainnet", | ||
cExplorerBaseUrl: "https://cexplorer.io", | ||
}), | ||
[], | ||
); | ||
|
||
return <AppContext.Provider value={value}>{children}</AppContext.Provider>; | ||
}; | ||
|
||
/** | ||
* Custom hook that provides access to the app context. | ||
* Throws an error if used outside of an AppContextMockProvider. | ||
* @returns The app context. | ||
*/ | ||
const useAppContext = () => { | ||
const context = useContext(AppContext); | ||
|
||
if (!context) { | ||
throw new Error( | ||
"useAppContext must be used within an AppContextMockProvider", | ||
); | ||
} | ||
|
||
return context; | ||
}; | ||
|
||
export { AppContextMockProvider, useAppContext }; |
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
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
Oops, something went wrong.