Skip to content

Make signer param optional in toMetaMaskSmartAccount#178

Open
jeffsmale90 wants to merge 2 commits intomainfrom
cursor/smart-account-getaccount-method-c422
Open

Make signer param optional in toMetaMaskSmartAccount#178
jeffsmale90 wants to merge 2 commits intomainfrom
cursor/smart-account-getaccount-method-c422

Conversation

@jeffsmale90
Copy link
Collaborator

📝 Description

This PR implements the changes described in issue #163, making the signer parameter optional in the toMetaMaskSmartAccount function. This allows for the creation of smart account instances that can perform non-signing operations without requiring a signer to be provided.

🔄 What Changed?

List the specific changes made:

  • packages/smart-accounts-kit/src/types.ts: Made the signer property optional in ToMetaMaskSmartAccountParameters.
  • packages/smart-accounts-kit/src/signer.ts: Overloaded resolveSigner to accept an optional signer and return null if no signer is provided.
  • packages/smart-accounts-kit/src/toMetaMaskSmartAccount.ts:
    • Added checks for signer existence before performing signDelegation and signUserOperation.
    • Introduced stub signer methods (signMessage, signTypedData, getStubSignature) that throw descriptive errors when called without a provided signer.
  • packages/smart-accounts-kit/test/toMetaMaskSmartAccount.test.ts: Added 8 new test cases to cover:
    • Creating smart accounts for all implementations without a signer.
    • Verifying non-signing operations (getAddress, encodeCalls) work correctly.
    • Ensuring signing operations (signUserOperation, signDelegation) throw appropriate errors when no signer is present.

🚀 Why?

Explain the motivation behind these changes:

  • To allow users to create MetaMaskSmartAccount instances for operations that do not require a signer (e.g., fetching address, encoding calls), reducing boilerplate and improving flexibility.
  • To provide clear error messages when signing operations are attempted on a smart account created without a signer.

🧪 How to Test?

Describe how to test these changes:

  • Manual testing steps:
    1. Run the existing test suite.
    2. Verify that toMetaMaskSmartAccount can be called without providing a signer parameter.
    3. Confirm that methods like getAddress() and encodeCalls() work correctly on such accounts.
    4. Confirm that methods like signUserOperation() and signDelegation() throw the expected error when called on an account created without a signer.
  • Automated tests added/updated
  • All existing tests pass

⚠️ Breaking Changes

List any breaking changes:

  • No breaking changes
  • Breaking changes (describe below):

📋 Checklist

Check off completed items:

  • Code follows the project's coding standards
  • Self-review completed
  • Documentation updated (if needed)
  • Tests added/updated
  • Changelog updated (if needed)
  • All CI checks pass

🔗 Related Issues

Link to related issues:
Closes #163

📚 Additional Notes

None.


Slack Thread

Open in Web Open in Cursor 

- Update ToMetaMaskSmartAccountParameters type to make signer optional
- Add overloaded resolveSigner function to handle optional signer
- Update toMetaMaskSmartAccount to provide stub signer methods that throw descriptive errors when signer is not provided
- Add error messages for signDelegation and signUserOperation when called without signer
- Add comprehensive tests for optional signer functionality including:
  - Creating smart accounts without signers for all implementations
  - Testing non-signing operations (getAddress, encodeCalls) work without signer
  - Testing signing operations throw appropriate errors without signer

Fixes #163

Co-authored-by: jeffsmale90 <jeffsmale90@users.noreply.github.com>
@cursor
Copy link

cursor bot commented Mar 3, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@jeffsmale90 jeffsmale90 changed the title Smart account getAccount method Make signer param optional in toMetaMaskSmartAccount Mar 3, 2026
Copy link
Collaborator Author

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

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

One concern - otherwise this looks really good.

Also resolve a little bit of formatting
@jeffsmale90 jeffsmale90 marked this pull request as ready for review March 4, 2026 05:49
@jeffsmale90 jeffsmale90 requested a review from a team as a code owner March 4, 2026 05:49
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.

signer should be optional when calling toMetaMaskSmartAccount

2 participants