fix: remove base64 decode on SignMessage - #171
Merged
Merged
Conversation
| message: '2zZDP1sa1BVBfLP7TeeMk3sUbaxAkUhBhDiNdrksaFo=', | ||
| signature: | ||
| 'VA1+7hefNwv2NKScH6n+Sljj15kLAge+M2wE7fzFOf+L0MMbssA1mwfJZRyyrhBORQRle10X1Dxpx+UOI4EbDQ==', | ||
| 'w2d2NipRh5bdv5SMfQnGRkj5AvZTjLRklACHObR11M5rNORxv0wmZG2o68gm1+12vVDcWptPZf3FjRTtx1qUBA==', |
Collaborator
Author
There was a problem hiding this comment.
we treat base64 string as string
SignMessage only accept utf8 string
SignMessage only accept utf8 stringSignMessage
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Snap’s SEP-43 signMessage flow to treat the incoming message as UTF-8 text only (no base64 auto-detection/decoding), aligning what users see in the confirmation UI with what is signed via SEP-0053.
Changes:
- Removed base64 auto-detection/decoding for message signing and verification; messages are always encoded as UTF-8 text before signing.
- Tightened the keyring
signMessagerequest validation and handler flow to accept/display the provided UTF-8 string as-is. - Updated tests and documentation to reflect the UTF-8-only behavior and adjusted reference vectors/fixtures accordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/snap/src/utils/string.ts | Removed base64-validation helper used for message auto-detection. |
| packages/snap/src/services/wallet/Wallet.ts | Updated signMessage/verifyMessage to accept string only and always UTF-8 encode before signing/verifying. |
| packages/snap/src/services/wallet/Wallet.test.ts | Updated SEP-0053 test vectors and removed byte-based message signing cases. |
| packages/snap/src/handlers/keyring/signMessage.ts | Simplified handler to pass the message through unchanged for UI display and signing. |
| packages/snap/src/handlers/keyring/signMessage.test.ts | Updated tests to use plain UTF-8 strings and assert UI renderContext matches the signed message. |
| packages/snap/src/handlers/keyring/keyring.test.ts | Updated integration-style tests to pass UTF-8 string messages instead of base64 payloads. |
| packages/snap/src/handlers/keyring/api.ts | Updated SignMessageRequestStruct to accept only Utf8StringStruct (no base64 union). |
| packages/snap/src/handlers/keyring/api.test.ts | Expanded validation tests for various UTF-8 messages, including base64-looking strings treated as text. |
| packages/snap/docs/use-cases/keyring/signMessage.md | Updated documentation to describe UTF-8-only message handling and confirmation behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| renderContext: { | ||
| account, | ||
| message: this.#getUtf8Message(message), | ||
| message, |
Collaborator
Author
There was a problem hiding this comment.
the message is a utf string, so no need convert
| @@ -1,13 +0,0 @@ | |||
| import { string } from '@metamask/superstruct'; | |||
| import { base64 } from '@metamask/utils'; | |||
Collaborator
Author
There was a problem hiding this comment.
no longer need
Julink-eth
approved these changes
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation
This PR updates the Snap’s SEP-43 signMessage flow to treat the incoming message as UTF-8 text only (no base64 auto-detection/decoding), aligning what users see in the confirmation UI with what is signed via SEP-0053.
References
Checklist