fix(spend-permission): use wallet-signed data for returned permission#332
Open
faisalnugroho wants to merge 1 commit into
Open
fix(spend-permission): use wallet-signed data for returned permission#332faisalnugroho wants to merge 1 commit into
faisalnugroho wants to merge 1 commit into
Conversation
When capabilities are provided, the wallet may substitute message.account via mutableData (e.g., replacing an EOA with a smart-wallet address). The returned SpendPermission object was using the original pre-substitution typedData.message for the permission field, while correctly using the post-substitution data for permissionHash. This created an internally inconsistent object where permission.account != the address in the hash. Track the actual signed message and use it consistently in the returned SpendPermission object. Fixes base#324
Collaborator
🟡 Heimdall Review Status
|
Author
|
Hi! I'd love to get this PR reviewed when you have a moment. This PR addresses use wallet-signed data for returned permission. Happy to make any adjustments based on your feedback. Let me know if there's anything I can do to help move this forward. |
Author
|
Hi! I'd love to get this PR reviewed when you have a moment. This PR addresses use wallet-signed data for returned permission. Happy to make any adjustments based on your feedback. Thank you! |
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.
Fixes #324
Problem
requestSpendPermissionusesmutableData: { fields: ['message.account'] }to allow the wallet to substitute the account address (e.g., replacing an EOA with a smart-wallet). However, the returnedSpendPermissionobject uses the original pre-substitutiontypedData.messagefor thepermissionfield, while correctly using the post-substitutionsignResult.signedData.messageforpermissionHash.This produces an internally inconsistent object:
Fix
Track the actual signed message and use it consistently:
signedMessagevariable initialized totypedData.messagewallet_signpath, updatesignedMessage = signResult.signedData.messagesignedMessagein the returnedSpendPermissionobjectThis ensures
permission.accountalways matches the account inpermissionHash, regardless of whether the wallet performed a substitution.Testing
The existing test mocks
signedDataas the same object astypedData, so no substitution occurs. A test wheresignedData.message.accountdiffers from the requestaccountwould expose the inconsistency. This fix makes such a test pass correctly.