Skip to content

SHARD-1842: better error messaging around Stake Lock #110

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

Merged
merged 1 commit into from
Apr 5, 2025

Conversation

PudgyPug
Copy link
Contributor

@PudgyPug PudgyPug commented Apr 4, 2025

PR Type

Enhancement


Description

  • Added stakeable field to NodeStatus for restake cooldown.

  • Implemented isStakeLocked and isRestakeForbidden checks in StakeDisplay.

  • Updated UI to display restake cooldown messages.

  • Refactored tooltip logic for stake lock status.


Changes walkthrough 📝

Relevant files
Enhancement
StakeDisplay.tsx
Implement stake lock and restake cooldown logic                   

components/molecules/StakeDisplay.tsx

  • Added isStakeLocked and isRestakeForbidden checks.
  • Updated button states and tooltips based on stake status.
  • Displayed cooldown messages for restaking.
  • +12/-3   
    node-status.ts
    Extend NodeStatus with restake cooldown properties             

    model/node-status.ts

  • Added stakeable field to NodeStatus.
  • Included restake cooldown properties.
  • +5/-0     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • Copy link

    github-actions bot commented Apr 4, 2025

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

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

    UI Logic Enhancement

    The logic for disabling buttons and displaying tooltips has been enhanced with new conditions for isStakeLocked and isRestakeForbidden. Ensure these conditions are correctly implemented and tested.

    const isStakeLocked = nodeStatus?.stakeState?.unlocked === false && nodeStatus?.stakeState?.remainingTime > 0
    const isRestakeForbidden = nodeStatus?.stakeable?.restakeAllowed === false && nodeStatus?.stakeable?.remainingTime > 0
    
    const isRemoveButtonDisabled =
      (!hasStakeOnDifferentNode && (!hasNodeStopped || !nodeStatus?.stakeState || !nodeStatus?.stakeState.unlocked)) ||
      stakeForConnectedAddressOrNode === 0 ||
      cooldown > 0
    
    function unstakeTooltip() {
      if (hasNodeStopped) {
        if (isStakeLocked) {
          return `Node is currently stopped and is being removed from the active validator list. Please wait for another ${formatRemainingTime(

    Comment on lines +66 to +67
    const isStakeLocked = nodeStatus?.stakeState?.unlocked === false && nodeStatus?.stakeState?.remainingTime > 0
    const isRestakeForbidden = nodeStatus?.stakeable?.restakeAllowed === false && nodeStatus?.stakeable?.remainingTime > 0
    Copy link

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: Ensure that nodeStatus is defined before accessing its properties to prevent potential runtime errors. [possible issue, importance: 7]

    Suggested change
    const isStakeLocked = nodeStatus?.stakeState?.unlocked === false && nodeStatus?.stakeState?.remainingTime > 0
    const isRestakeForbidden = nodeStatus?.stakeable?.restakeAllowed === false && nodeStatus?.stakeable?.remainingTime > 0
    const isStakeLocked = nodeStatus && nodeStatus.stakeState?.unlocked === false && nodeStatus.stakeState?.remainingTime > 0
    const isRestakeForbidden = nodeStatus && nodeStatus.stakeable?.restakeAllowed === false && nodeStatus.stakeable?.remainingTime > 0

    @mhanson-github mhanson-github merged commit a70c3d2 into mainnet-launch Apr 5, 2025
    5 checks passed
    @mhanson-github mhanson-github deleted the SHARD-1842 branch April 10, 2025 02:17
    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.

    4 participants