Skip to content

Fixed forest-wallet set-default failing when the keystore has no default entry.#7087

Open
sudo-shashank wants to merge 3 commits into
mainfrom
shashank/fix-wallet-set-default
Open

Fixed forest-wallet set-default failing when the keystore has no default entry.#7087
sudo-shashank wants to merge 3 commits into
mainfrom
shashank/fix-wallet-set-default

Conversation

@sudo-shashank
Copy link
Copy Markdown
Contributor

@sudo-shashank sudo-shashank commented May 20, 2026

Summary of changes

Changes introduced in this pull request:

  • Fixed and unified set-default logic by adding a check for an existing default entry before removing it.

Reference issue to close (if applicable)

Closes #7018

Other information and links

Change checklist

  • I have performed a self-review of my own code,
  • I have made corresponding changes to the documentation. All new code adheres to the team's documentation standards,
  • I have added tests that prove my fix is effective or that my feature works (if possible),
  • I have made sure the CHANGELOG is up-to-date. All user-facing changes should be reflected in this document.

Outside contributions

  • I have read and agree to the CONTRIBUTING document.
  • I have read and agree to the AI Policy document. I understand that failure to comply with the guidelines will lead to rejection of the pull request.

Summary by CodeRabbit

  • Bug Fixes

    • forest-wallet set-default command now handles cases where the keystore lacks a default entry, resolving issue #7018.
  • Refactor

    • Improved consistency and maintainability of wallet default key management code across wallet operations and RPC handlers.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main fix: making forest-wallet set-default work when no default entry exists.
Linked Issues check ✅ Passed The changes directly address issue #7018 by refactoring the set-default logic to handle cases where no existing default entry exists.
Out of Scope Changes check ✅ Passed All changes are scoped to fixing the set-default functionality and include a changelog update, with no unrelated modifications present.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shashank/fix-wallet-set-default
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch shashank/fix-wallet-set-default

Comment @coderabbitai help to get the list of available commands and usage tips.

@sudo-shashank sudo-shashank marked this pull request as ready for review May 20, 2026 22:47
@sudo-shashank sudo-shashank requested a review from a team as a code owner May 20, 2026 22:47
@sudo-shashank sudo-shashank requested review from LesnyRumcajs and hanabi1224 and removed request for a team May 20, 2026 22:47
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

❌ Patch coverage is 45.45455% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.23%. Comparing base (3b7dcd7) to head (0f0089d).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/key_management/wallet.rs 55.55% 1 Missing and 3 partials ⚠️
src/rpc/methods/wallet.rs 0.00% 1 Missing ⚠️
src/wallet/subcommands/wallet_cmd.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
src/rpc/methods/wallet.rs 35.46% <0.00%> (+0.80%) ⬆️
src/wallet/subcommands/wallet_cmd.rs 26.68% <0.00%> (+0.19%) ⬆️
src/key_management/wallet.rs 90.00% <55.55%> (+0.08%) ⬆️

... and 9 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3b7dcd7...0f0089d. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

}

/// Set the default key to the key identified by `addr`.
pub fn set_default(addr: &Address, keystore: &mut KeyStore) -> Result<(), Error> {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why does this need to be a free function?

Copy link
Copy Markdown
Contributor Author

@sudo-shashank sudo-shashank May 21, 2026

Choose a reason for hiding this comment

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

matches other methods in this module like get_default, list_addrs, remove_key etc

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

forest-wallet set-default fails when the keystore has no default entry

2 participants