Skip to content

[LWDM] A key error occurs for accounts that are already delegated#17886

Open
amaslakov wants to merge 1 commit into
developfrom
LIVE-31485-tezos-lwd-a-key-error-occurs-for-accounts-that-are-already-delegated
Open

[LWDM] A key error occurs for accounts that are already delegated#17886
amaslakov wants to merge 1 commit into
developfrom
LIVE-31485-tezos-lwd-a-key-error-occurs-for-accounts-that-are-already-delegated

Conversation

@amaslakov
Copy link
Copy Markdown
Contributor

@amaslakov amaslakov commented May 27, 2026

✅ Checklist

  • npx changeset was attached.
  • Covered by automatic tests.
  • Impact of the changes:
    • Delegated Tezos accounts: header/panel Earn → Stake, not Delegate (fixes delegate.unchanged).
    • Re-delegating to same baker: shows "already delegated" instead of missing-key error.
    • coin-tezos change also hits mobile — [check] mobile locale key.
    • Changeset: ledger-live-desktop + @ledgerhq/coin-tezos patch.
    • "Change baker" moved from header Earn to Row context-menu.

📝 Description

Both Earn entry points (account header, delegation panel) now open the staking flow for delegated accounts instead of a delegation the node rejects as delegate.unchanged. That error now maps to "already delegated to this validator" instead of a missing key.

❓ Context

  • JIRA or GitHub link: LIVE-31485
  • ADR link (if any):

🧐 Checklist for the PR Reviewers

  • The code aligns with the requirements described in the linked JIRA or GitHub issue.
  • The PR description clearly documents the changes made and explains any technical trade-offs or design decisions.
  • There are no undocumented trade-offs, technical debt, or maintainability issues.
  • The PR has been tested thoroughly, and any potential edge cases have been considered and handled.
  • Any new dependencies have been justified and documented.
  • Performance considerations have been taken into account. (changes have been profiled or benchmarked if necessary)

Copilot AI review requested due to automatic review settings May 27, 2026 16:59
@amaslakov amaslakov requested review from a team as code owners May 27, 2026 16:59
@live-github-bot live-github-bot Bot added desktop Has changes in LLD coin-modules labels May 27, 2026
@live-github-bot live-github-bot Bot changed the title [TEZOS][LWD] A key error occurs for accounts that are already delegated [LWDM] A key error occurs for accounts that are already delegated May 27, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 fixes the Tezos Earn flow so that already-delegated accounts open the staking flow (rather than triggering a node-rejected delegate.unchanged delegation), and maps that error to the user-friendly InvalidAddressBecauseAlreadyDelegated for both stake and delegate intents. The Earn entry-point logic from the account header and the delegation panel is consolidated into a single pure helper getTezosEarnFlow, with shared cases for empty/no-funds, earning-choice, stake (skipping delegation), and (re)delegate.

Changes:

  • Extract Earn routing into getTezosEarnFlow and reuse it from both AccountHeaderManageActions and Delegation/index.tsx, routing delegated accounts to the staking flow with skipDelegation: true.
  • In validateIntent, treat delegate.unchanged as InvalidAddressBecauseAlreadyDelegated for both stake and delegate intents (previously only stake).
  • Add unit tests for getTezosEarnFlow and the new delegate.unchanged mapping for delegate intent; add a changeset.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
libs/coin-modules/coin-tezos/src/logic/validateIntent.ts Drop intentType === "stake" guard so delegate.unchanged maps to InvalidAddressBecauseAlreadyDelegated for delegate too.
libs/coin-modules/coin-tezos/src/logic/validateIntent.test.ts New test verifying the mapping for type: "delegate".
apps/ledger-live-desktop/src/renderer/families/tezos/earnFlow.ts New pure helper getTezosEarnFlow returning a discriminated flow type.
apps/ledger-live-desktop/src/renderer/families/tezos/Delegation/index.tsx Use getTezosEarnFlow to route Earn button, including MODAL_NO_FUNDS_STAKE, stake-with-skipDelegation, and redelegate paths.
apps/ledger-live-desktop/src/renderer/families/tezos/AccountHeaderManageActions.ts Refactor header Earn click to use getTezosEarnFlow; switch from delegation/isStaked to isDelegated.
apps/ledger-live-desktop/src/renderer/families/tezos/tests/earnFlow.test.ts Unit tests covering all branches of getTezosEarnFlow.
.changeset/five-comics-matter.md Changeset describing the desktop + coin-tezos patch.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

⚠️ E2E tests are required

Changes detected require e2e testing before merge (even before asking for any review).

🖥️ Desktop

-> Run Desktop E2E

  • Select "Run workflow"
  • Branch: LIVE-31485-tezos-lwd-a-key-error-occurs-for-accounts-that-are-already-delegated
  • Device: nanoSP or stax

📱 Mobile

-> Run Mobile E2E

  • Select "Run workflow"
  • Branch: LIVE-31485-tezos-lwd-a-key-error-occurs-for-accounts-that-are-already-delegated
  • Device: nanoX

Affected coins modules: tezos

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Web Tools Build Status

Build Status Deployment
Web Tools Build ✅ Deployed https://web-tools-4fvtzdnda-ledger-hq-prd.vercel.app
Native Storybook Build ⏭️ Skipped
React Storybook Build ⏭️ Skipped

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Rsdoctor Bundle Diff Analysis

Found 7 projects in monorepo, 2 projects with changes.

📊 Quick Summary
Project Total Size Change
desktop-main 2.5 MB 0
desktop-preloader 7.1 KB 0
desktop-renderer 77.3 MB +816.0 B (0.0%)
desktop-webviewDappPreloader 37.0 KB 0
desktop-webviewPreloader 200.0 B 0
desktop-workers 37.0 KB 0
mobile 220.4 MB -54.0 B (-0.0%)
📋 Detailed Reports (Click to expand)

📁 desktop-renderer

Path: rsdoctor/desktop-renderer/rsdoctor-data.json

📌 Baseline Commit: 994acb8df6 | PR: #17885

Metric Current Baseline Change
📊 Total Size 77.3 MB 77.3 MB +816.0 B (0.0%)
📄 JavaScript 30.4 MB 30.4 MB +816.0 B (0.0%)
🎨 CSS 193.6 KB 193.6 KB 0
🌐 HTML 1.8 KB 1.8 KB 0
📁 Other Assets 46.7 MB 46.7 MB 0

📦 Download Diff Report: desktop-renderer Bundle Diff

📁 mobile

Path: rsdoctor/mobile/rsdoctor-data.json

📌 Baseline Commit: 994acb8df6 | PR: #17885

Metric Current Baseline Change
📊 Total Size 220.4 MB 220.4 MB -54.0 B (-0.0%)
📄 JavaScript 105.6 MB 105.6 MB -26.0 B (-0.0%)
🎨 CSS 0 B 0 B 0
🌐 HTML 0 B 0 B 0
📁 Other Assets 114.8 MB 114.8 MB -28.0 B (-0.0%)

📦 Download Diff Report: mobile Bundle Diff

Generated by Rsdoctor GitHub Action

… error

Both Earn entry points (account header, delegation panel) now open the staking flow for
delegated accounts instead of a delegation the node rejects as delegate.unchanged. That
error now maps to "already delegated to this validator" instead of a missing key.
@amaslakov amaslakov force-pushed the LIVE-31485-tezos-lwd-a-key-error-occurs-for-accounts-that-are-already-delegated branch from 0f2cc39 to 2d5d03e Compare May 27, 2026 17:18
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

coin-modules desktop Has changes in LLD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants