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

Sync Production with main #784

Merged
merged 10 commits into from
Jul 31, 2024
Merged

Sync Production with main #784

merged 10 commits into from
Jul 31, 2024

Conversation

marc-aurele-besner
Copy link
Collaborator

@marc-aurele-besner marc-aurele-besner commented Jul 31, 2024

User description

Sync Production with main

Including:


PR Type

Bug fix, Enhancement


Description

  • Fixed and enhanced the account extrinsics list query logic by adding a memoized where variable and updating the fullDataDownloader to include it.
  • Fixed the account rewards full download logic by adding accountId to the query variables.
  • Allowed visitors to see the RPC operators list by removing the subspaceAccount check in the OperatorsList component.
  • Simplified the wallet provider setup logic by removing an unnecessary injector check.
  • Fixed the page count calculation logic to correctly include the last page if there are remaining items.

Changes walkthrough 📝

Relevant files
Bug fix
AccountExtrinsicList.tsx
Fix and enhance account extrinsics list query logic           

explorer/src/components/Account/AccountExtrinsicList.tsx

  • Added where variable to memoized query variables.
  • Updated fullDataDownloader to include where in the query.
  • Refactored the variables memoization to use the new where variable.
  • +17/-9   
    AccountRewardList.tsx
    Fix account rewards full download logic                                   

    explorer/src/components/Account/AccountRewardList.tsx

    • Added accountId to the fullDataDownloader query variables.
    +2/-1     
    table.ts
    Fix page count calculation logic                                                 

    explorer/src/utils/table.ts

  • Fixed page count calculation to include the last page if there are
    remaining items.
  • +1/-1     
    Enhancement
    OperatorsList.tsx
    Allow visitors to see RPC operators list                                 

    explorer/src/components/Staking/OperatorsList.tsx

  • Allowed visitors to see RPC operators list by removing subspaceAccount
    check.
  • +1/-1     
    WalletProvider.tsx
    Simplify wallet provider setup logic                                         

    explorer/src/providers/WalletProvider.tsx

    • Removed unnecessary injector check before calling setup.
    +0/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    Copy link

    netlify bot commented Jul 31, 2024

    Deploy Preview for astral-prod ready!

    Name Link
    🔨 Latest commit 0810d96
    🔍 Latest deploy log https://app.netlify.com/sites/astral-prod/deploys/66aa32282ca8e40008d039d8
    😎 Deploy Preview https://deploy-preview-784--astral-prod.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    Copy link

    netlify bot commented Jul 31, 2024

    Deploy Preview for dev-astral ready!

    Name Link
    🔨 Latest commit 0810d96
    🔍 Latest deploy log https://app.netlify.com/sites/dev-astral/deploys/66aa3228d047d6000855ae47
    😎 Deploy Preview https://deploy-preview-784--dev-astral.netlify.app
    📱 Preview on mobile
    Toggle QR Code...

    QR Code

    Use your smartphone camera to open QR code link.

    To edit notification comments on pull requests, go to your Netlify site configuration.

    Copy link

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Dependency Management
    The where variable is added to the dependencies of the useMemo for variables and fullDataDownloader. Ensure that changes in where do not cause unnecessary re-renders or data fetches.

    Data Handling
    The addition of accountId to the query variables in downloadFullData should be carefully reviewed to ensure that it does not lead to incorrect or unexpected data being fetched when accountId is an empty string.

    Logic Change
    Removing the subspaceAccount check might allow unauthorized or unintended access to data. Ensure that this change aligns with the intended access controls and does not expose sensitive data.

    Calculation Adjustment
    The change in page count calculation now accounts for any remainder items by adding an additional page. This logic should be verified to ensure it correctly handles all edge cases, especially when totalCount is zero or very low.

    Copy link

    github-actions bot commented Jul 31, 2024

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Possible bug
    Add a guard clause to prevent function calls on undefined objects

    Reinstate the guard clause to check for injector before calling setup(). This
    prevents the setup function from being called when injector is not available, which
    could lead to runtime errors.

    explorer/src/providers/WalletProvider.tsx [183]

    -setup()
    +if (injector) setup()
     
    Suggestion importance[1-10]: 10

    Why: Reinstate the guard clause to check for injector before calling setup() is essential to prevent runtime errors. This is a critical fix that ensures the setup function is only called when injector is available.

    10
    Ensure conditions are checked to prevent errors

    Restore the check for subspaceAccount in the conditional statement to ensure that
    the logic only executes when subspaceAccount is truthy. This prevents potential
    errors or unintended behavior when subspaceAccount is falsy.

    explorer/src/components/Staking/OperatorsList.tsx [518]

    -if (useRpcData) {
    +if (useRpcData && subspaceAccount) {
     
    Suggestion importance[1-10]: 9

    Why: Restoring the check for subspaceAccount in the conditional statement is crucial to prevent potential errors or unintended behavior when subspaceAccount is falsy. This is a significant improvement for code safety and reliability.

    9
    Best practice
    Use nullish coalescing to handle default values more accurately

    Consider using nullish coalescing (??) instead of logical OR (||) when setting the
    accountId in the where object. This ensures that only null or undefined values are
    replaced with the default empty string, preserving other falsy values like 0 or
    false that might be valid.

    explorer/src/components/Account/AccountExtrinsicList.tsx [66]

     signer: {
    -  id_eq: accountId,
    +  id_eq: accountId ?? '',
     },
     
    Suggestion importance[1-10]: 8

    Why: The suggestion to use nullish coalescing (??) instead of logical OR (||) is valid and improves the robustness of the code by ensuring that only null or undefined values are replaced with the default empty string, preserving other falsy values like 0 or false that might be valid.

    8
    Enhancement
    Simplify the page count calculation using the Math.ceil function

    Simplify the calculation of table pages by using the ceiling function from the Math
    library, which directly computes the number of pages needed without manual
    adjustments.

    explorer/src/utils/table.ts [2]

    -Math.max(1, Math.floor(totalCount / pageSize)) + (totalCount % pageSize > 0 ? 1 : 0)
    +Math.max(1, Math.ceil(totalCount / pageSize))
     
    Suggestion importance[1-10]: 7

    Why: The suggestion to use Math.ceil simplifies the calculation of table pages and makes the code more readable. While this is a good enhancement, it is not as critical as the other suggestions.

    7

    @marc-aurele-besner marc-aurele-besner merged commit 2a323dc into production Jul 31, 2024
    27 of 28 checks passed
    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.

    1 participant