Skip to content
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

Improve network types #178

Merged
merged 4 commits into from
Nov 27, 2024
Merged

Improve network types #178

merged 4 commits into from
Nov 27, 2024

Conversation

marc-aurele-besner
Copy link
Collaborator

@marc-aurele-besner marc-aurele-besner commented Nov 22, 2024

User description

Improve network types

Switch network type to use the NetworkId and NetworkName enum in the object type


PR Type

enhancement


Description

  • Updated the useNetwork hook to utilize the NetworkId type for better type safety.
  • Modified the Network type to use NetworkId and NetworkName enums, enhancing consistency and reducing errors.
  • Improved type definitions in the auto-utils package for network-related data.

Changes walkthrough 📝

Relevant files
Enhancement
useNetwork.tsx
Update network handling to use `NetworkId` type                   

examples/next/src/hooks/useNetwork.tsx

  • Imported NetworkId from @autonomys/auto-utils.
  • Changed networkId parameter type to NetworkId.
  • Cast networkName to NetworkId in handleNetworkChange.
  • +3/-3     
    network.ts
    Switch `Network` type to use enums for ID and name             

    packages/auto-utils/src/types/network.ts

  • Imported NetworkId and NetworkName from ../constants/network.
  • Updated Network type to use NetworkId and NetworkName.
  • +3/-2     

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Type Safety
    Ensure that the networkName variable always conforms to the NetworkId type before it's passed to handleNetworkChange.

    Copy link

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @marc-aurele-besner marc-aurele-besner merged commit dc475c9 into main Nov 27, 2024
    1 check passed
    @marc-aurele-besner marc-aurele-besner deleted the feat/improve-network-types branch November 27, 2024 16:25
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants