Make signer param optional in toMetaMaskSmartAccount#178
Open
jeffsmale90 wants to merge 2 commits intomainfrom
Open
Make signer param optional in toMetaMaskSmartAccount#178jeffsmale90 wants to merge 2 commits intomainfrom
signer param optional in toMetaMaskSmartAccount#178jeffsmale90 wants to merge 2 commits intomainfrom
Conversation
- 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 Agent can help with this pull request. Just |
signer param optional in toMetaMaskSmartAccount
jeffsmale90
commented
Mar 3, 2026
Collaborator
Author
jeffsmale90
left a comment
There was a problem hiding this comment.
One concern - otherwise this looks really good.
Also resolve a little bit of formatting
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.
📝 Description
This PR implements the changes described in issue #163, making the
signerparameter optional in thetoMetaMaskSmartAccountfunction. 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 thesignerproperty optional inToMetaMaskSmartAccountParameters.packages/smart-accounts-kit/src/signer.ts: OverloadedresolveSignerto accept an optionalsignerand returnnullif no signer is provided.packages/smart-accounts-kit/src/toMetaMaskSmartAccount.ts:signerexistence before performingsignDelegationandsignUserOperation.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:getAddress,encodeCalls) work correctly.signUserOperation,signDelegation) throw appropriate errors when no signer is present.🚀 Why?
Explain the motivation behind these changes:
MetaMaskSmartAccountinstances for operations that do not require a signer (e.g., fetching address, encoding calls), reducing boilerplate and improving flexibility.🧪 How to Test?
Describe how to test these changes:
toMetaMaskSmartAccountcan be called without providing asignerparameter.getAddress()andencodeCalls()work correctly on such accounts.signUserOperation()andsignDelegation()throw the expected error when called on an account created without a signer.List any breaking changes:
📋 Checklist
Check off completed items:
🔗 Related Issues
Link to related issues:
Closes #163
📚 Additional Notes
None.
Slack Thread