Skip to content

feat(WalletBase): add SignMessage(string) convenience overload#274

Open
mstevens843 wants to merge 1 commit intomagicblock-labs:mainfrom
mstevens843:feat/sign-message-string-overload
Open

feat(WalletBase): add SignMessage(string) convenience overload#274
mstevens843 wants to merge 1 commit intomagicblock-labs:mainfrom
mstevens843:feat/sign-message-string-overload

Conversation

@mstevens843
Copy link
Copy Markdown

@mstevens843 mstevens843 commented Apr 8, 2026

Status Type ⚠️ Core Change Issue
Ready Feature Yes #273

Problem

SignMessage() only accepts byte[]. Every caller must manually convert strings via Encoding.UTF8.GetBytes() before signing, adding unnecessary boilerplate for the
most common use case — signing human-readable messages.

Discovered while building a Unity MWA example app on Solana Seeker hardware with Seed Vault
(unity-solana-mwa-example). Documented as Point 6 in #273.

Solution

Added SignMessage(string message) overload to IWalletBase and WalletBase that handles UTF-8 encoding internally, delegating to the existing SignMessage(byte[]).

All derived wallet classes (InGameWallet, SolanaMobileWalletAdapter, SolanaWalletAdapterWebGL, PhantomDeepLink, SolanaWalletAdapter) inherit the new overload
automatically — zero changes required in implementations.

Before & After Screenshots

BEFORE:

  var payload = Encoding.UTF8.GetBytes("Hello from Unity");                                                                                                             
  var signature = await Web3.Wallet.SignMessage(payload);

AFTER:

  var signature = await Web3.Wallet.SignMessage("Hello from Unity");                                                                                                  

Other changes (e.g. bug fixes, small refactors)

None. Purely additive — no existing signatures or behavior modified.

Deploy Notes

No new scripts or dependencies. Drop-in enhancement to existing API surface.

Summary by CodeRabbit

  • New Features
    • Extended wallet signing functionality to support signing string messages directly, in addition to the existing binary data support. Users can now sign text messages without requiring pre-conversion to binary format.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 69c52e83-3381-4852-8476-653d2d28d349

📥 Commits

Reviewing files that changed from the base of the PR and between 054503e and 2d4d903.

📒 Files selected for processing (2)
  • Runtime/codebase/IWalletBase.cs
  • Runtime/codebase/WalletBase.cs

Walkthrough

Added a string overload to the SignMessage method in both IWalletBase interface and WalletBase implementation class, enabling UTF-8 string input support alongside the existing byte array parameter variant.

Changes

Cohort / File(s) Summary
SignMessage String Overload
Runtime/codebase/IWalletBase.cs, Runtime/codebase/WalletBase.cs
Added Task<byte[]> SignMessage(string message) overload to the interface and base class implementation. The base class implementation encodes the input string as UTF-8 and delegates to the existing abstract byte array method. Introduced using System.Text; import for encoding support.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a SignMessage(string) convenience overload to WalletBase.
Description check ✅ Passed The description follows the template structure with Status, Type, Core Change, Issue, Problem, Solution, Before & After examples, Other changes, and Deploy Notes sections all properly filled out.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

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.

1 participant