[LWDM] A key error occurs for accounts that are already delegated#17886
[LWDM] A key error occurs for accounts that are already delegated#17886amaslakov wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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
getTezosEarnFlowand reuse it from bothAccountHeaderManageActionsandDelegation/index.tsx, routing delegated accounts to the staking flow withskipDelegation: true. - In
validateIntent, treatdelegate.unchangedasInvalidAddressBecauseAlreadyDelegatedfor bothstakeanddelegateintents (previously onlystake). - Add unit tests for
getTezosEarnFlowand the newdelegate.unchangedmapping fordelegateintent; 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. |
|
Web Tools Build Status
|
Rsdoctor Bundle Diff AnalysisFound 7 projects in monorepo, 2 projects with changes. 📊 Quick Summary
📋 Detailed Reports (Click to expand)📁 desktop-rendererPath:
📦 Download Diff Report: desktop-renderer Bundle Diff 📁 mobilePath:
📦 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.
0f2cc39 to
2d5d03e
Compare
|



✅ Checklist
npx changesetwas attached.📝 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
🧐 Checklist for the PR Reviewers