Skip to content

refactor: move validation structs and add account field#589

Open
Battambang wants to merge 4 commits intomainfrom
refactor/validation-structs-account-field
Open

refactor: move validation structs and add account field#589
Battambang wants to merge 4 commits intomainfrom
refactor/validation-structs-account-field

Conversation

@Battambang
Copy link
Copy Markdown
Contributor

@Battambang Battambang commented Mar 12, 2026

Explanation

This PR contributes to supporting the Bitcoin dApp connectivity.
It's refactoring the current code to prepare the integration of the resolve account address Keyring method.

It is part from the initial PR #564 feat: enable account address resolution to support dApps connectivity to split the work into 3 smaller PRs:
#589 refactor: move validation structs and add account field
#590 feat: add resolveAccountAddress method to KeyringHandler for dApp connectivity routing
#591 feat: add confirmation dialog before sendTransfer and before signing a PSBT from the keyring handler

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Medium risk because it changes the validated shape of keyring request params (adds required account.address and method-specific structs), which can break callers if they haven’t been updated; logic changes are mostly limited to validation and tests.

Overview
Refactors Bitcoin keyring request validation by moving the request superstruct schemas out of KeyringRequestHandler into handlers/validation.ts and introducing method-specific keyring request structs (via BtcMethod literals) plus a shared WalletAccountStruct.

Updates request shapes so Bitcoin capability calls now validate a required params.account.address field for actions like SignPsbt, FillPsbt, ComputeFee, BroadcastPsbt, SendTransfer, GetUtxo, and SignMessage, with unit/integration tests adjusted accordingly. Also adds NetworkStruct in caip.ts and bumps the snap manifest bundle shasum.

Reviewed by Cursor Bugbot for commit 2c3d8f3. Bugbot is set up for automated code reviews on this repo. Configure here.

@Battambang Battambang requested a review from a team as a code owner March 12, 2026 22:56
@Battambang Battambang changed the title Refactor/validation structs account field Refactor validation structs and add account field Mar 12, 2026
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread packages/snap/src/handlers/validation.ts Outdated
@Battambang
Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/bitcoin-wallet-snap": "1.10.0-preview-bee05b0"
}

@Battambang
Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/bitcoin-wallet-snap": "1.10.1-preview-2c3d8f3"
}

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