-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add network api information #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
This PR introduces network API support by adding new types, API call logic, and integrating the network information into various components. Key changes include:
- Adding Zod-based schemas in lib/network_api/types.ts and a corresponding NetworkApi class.
- Updating various UI components (e.g., Header, Hero, StatsTilesServer) to consume the new network API data.
- Refining constants and context values to support new UI features such as staking reward displays.
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
lib/network_api/types.ts | Added new Zod schemas for network, token, and price information. |
lib/network_api/NetworkApi.ts | Introduced a new class to fetch network API data with revalidation options. |
hooks/screen.tsx | Updated useWindowSize import and handled width type conversion. |
components/StakingRewardImageText/*.tsx | Integrated network API data for staking reward display. |
components/FlexibleContent/Modules/Hero/*.tsx | Modified hero components to fetch and pass network API data. |
components/Contexts/SettingsContext.tsx | Extended context to include additional navigation properties. |
.env.local.template | Removed legacy DATA_API keys and added NETWORK_API configuration. |
Comments suppressed due to low confidence (1)
components/FlexibleContent/Modules/StatsTiles/StatsTilesServer.tsx:21
- [nitpick] The magic string 'SESH in Staking Reward Pool' is used to match a specific tile copy. Consider extracting it to a constant to avoid potential typos and improve maintainability.
if (stakingRewardPool && tile.copy === 'SESH in Staking Reward Pool') {
const data = await NETWORK_API.getInfo(REVALIDATIONS['1H']); | ||
const stakingRequirement = data?.token.staking_requirement; | ||
const nodeCount = data?.network.network_size; | ||
const totalStaked = data?.network.network_staked_tokens; | ||
const stakingRewardPool = data?.token.staking_reward_pool; | ||
|
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.
Consider adding error handling or fallback logic in case NETWORK_API.getInfo returns null, to ensure that subsequent usage of the data does not result in runtime issues.
const data = await NETWORK_API.getInfo(REVALIDATIONS['1H']); | |
const stakingRequirement = data?.token.staking_requirement; | |
const nodeCount = data?.network.network_size; | |
const totalStaked = data?.network.network_staked_tokens; | |
const stakingRewardPool = data?.token.staking_reward_pool; | |
let data; | |
try { | |
data = await NETWORK_API.getInfo(REVALIDATIONS['1H']); | |
} catch (error) { | |
console.error('Failed to fetch network info:', error); | |
data = null; | |
} | |
const stakingRequirement = data?.token?.staking_requirement ?? 0; | |
const nodeCount = data?.network?.network_size ?? 0; | |
const totalStaked = data?.network?.network_staked_tokens ?? 0; | |
const stakingRewardPool = data?.token?.staking_reward_pool ?? 0; |
Copilot uses AI. Check for mistakes.
|
||
export function useScreenWidth() { | ||
const { width } = useWindowSize(); | ||
const { width: _width } = useWindowSize(); | ||
const width = Number(_width); |
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.
[nitpick] Ensure that the explicit conversion of _width to a number is necessary; if _width is already numeric, this conversion might be redundant.
const width = Number(_width); | |
const width = _width; |
Copilot uses AI. Check for mistakes.
No description provided.