Skip to content
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

fix!: Keyring.signTypedData accepts types for V1 #224

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

mikesposito
Copy link
Member

@mikesposito mikesposito commented Feb 21, 2025

@mikesposito mikesposito force-pushed the mikesposito/keyring-typed-message-type branch from 17b68dc to fc6bec1 Compare February 21, 2025 14:48
@mikesposito
Copy link
Member Author

@metamaskbot publish-preview

Copy link

Preview builds have been published. See these instructions (from the core monorepo) for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/keyring-api": "17.1.0-5f85942",
  "@metamask-previews/eth-hd-keyring": "10.0.1-5f85942",
  "@metamask-previews/eth-ledger-bridge-keyring": "8.0.5-5f85942",
  "@metamask-previews/eth-simple-keyring": "8.1.1-5f85942",
  "@metamask-previews/eth-trezor-keyring": "6.1.1-5f85942",
  "@metamask-previews/keyring-internal-api": "4.0.2-5f85942",
  "@metamask-previews/keyring-internal-snap-client": "4.0.0-5f85942",
  "@metamask-previews/eth-snap-keyring": "11.0.0-5f85942",
  "@metamask-previews/keyring-snap-client": "4.0.0-5f85942",
  "@metamask-previews/keyring-snap-sdk": "3.0.0-5f85942",
  "@metamask-previews/keyring-utils": "2.2.0-5f85942"
}

@mikesposito mikesposito marked this pull request as ready for review February 21, 2025 17:44
@mikesposito mikesposito requested a review from a team as a code owner February 21, 2025 17:44
@mikesposito mikesposito changed the title fix: Keyring.signTypedData accepts types for V1 fix!: Keyring.signTypedData accepts types for V1 Feb 21, 2025
async signTypedData<
Version extends SignTypedDataVersion.V3 | SignTypedDataVersion.V4,
Types extends MessageTypes,
Options extends { version?: Version },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be optional? It seems that previous Options type was mandatory?

Copy link
Member Author

Choose a reason for hiding this comment

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

I ignored what was accepted before and aligned it with other keyrings. It should not represent functional changes because of the way the method implementation works: we only care about distinguishing V3 from V4, so passing an empty version would result in V3 being used

Thoughts? The Keyring type would also accept { version: Version }, so the keyring could actually make the argument mandatory

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.

Keyring.signTypedData does not support V1
2 participants