-
Notifications
You must be signed in to change notification settings - Fork 8
Document DelegateCall requirement for proposeTransactionsWithSignature to prevent signature validation errors #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ateCall Co-authored-by: aviggiano <[email protected]>
…ll requirement Co-authored-by: aviggiano <[email protected]>
|
@copilot make sure CI is passing |
Co-authored-by: aviggiano <[email protected]>
Fixed the CI failures in commit 55992c3:
The CI workflows require approval to run since changes were made by a bot. Once approved, both format and test jobs should pass. |
aviggiano
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make docs shorter
| #### Batch transactions | ||
|
|
||
| For proposing multiple transactions together, use `proposeTransactions`: | ||
|
|
||
| ```solidity | ||
| address[] memory targets = new address[](2); | ||
| bytes[] memory datas = new bytes[](2); | ||
| targets[0] = address(contract1); | ||
| datas[0] = abi.encodeCall(Contract1.someFunction, ()); | ||
| targets[1] = address(contract2); | ||
| datas[1] = abi.encodeCall(Contract2.anotherFunction, ()); | ||
| safe.proposeTransactions(targets, datas, sender, "m/44'/60'/0'/0/0"); | ||
| ``` | ||
|
|
||
| If you need to pre-compute the signature for batch transactions (e.g., when using a Ledger), you must: | ||
|
|
||
| 1. Get the target and data for the batch transaction using `getProposeTransactionsTargetAndData`: | ||
|
|
||
| ```solidity | ||
| (address to, bytes memory data) = safe.getProposeTransactionsTargetAndData(targets, datas); | ||
| ``` | ||
|
|
||
| 2. Sign the transaction with `Enum.Operation.DelegateCall` (**NOT** `Call`): | ||
|
|
||
| ```solidity | ||
| bytes memory signature = safe.sign(to, data, Enum.Operation.DelegateCall, sender, "m/44'/60'/0'/0/0"); | ||
| ``` | ||
|
|
||
| 3. Propose the transactions with the signature: | ||
|
|
||
| ```solidity | ||
| safe.proposeTransactionsWithSignature(targets, datas, sender, signature); | ||
| ``` | ||
|
|
||
| **⚠️ CRITICAL**: Batch transactions **MUST** use `Enum.Operation.DelegateCall` to preserve `msg.sender` across sub-calls. | ||
|
|
||
| **Common Mistake**: If you sign with `Enum.Operation.Call` instead of `DelegateCall`, the Safe API will reject your transaction with an error about an incorrect signer address. The signer address reported in the error will not match your actual signing address because the signature will be invalid. | ||
|
|
||
| **Correct usage**: | ||
| ```solidity | ||
| // ✓ CORRECT - Use DelegateCall for batch transactions | ||
| bytes memory signature = safe.sign(to, data, Enum.Operation.DelegateCall, sender, derivationPath); | ||
| safe.proposeTransactionsWithSignature(targets, datas, sender, signature); | ||
| ``` | ||
|
|
||
| **Incorrect usage**: | ||
| ```solidity | ||
| // ✗ WRONG - Using Call instead of DelegateCall will cause signature validation to fail | ||
| bytes memory signature = safe.sign(to, data, Enum.Operation.Call, sender, derivationPath); | ||
| safe.proposeTransactionsWithSignature(targets, datas, sender, signature); | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this documentation shorter. Instead of 115 lines, make it 30 lines @copilot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Condensed the batch transactions documentation in commit 2f8ed08. Reduced from 55 lines to 16 lines while preserving the key information about the DelegateCall requirement.
Co-authored-by: aviggiano <[email protected]>
Documentation shortened in commit 2f8ed08. |
Plan: Improve Documentation for proposeTransactionsWithSignature
Summary
This PR addresses the issue where users were getting confusing "incorrect signer" errors when using
proposeTransactionsWithSignature()with ledger wallets. The root cause was users signing batch transactions withEnum.Operation.Callinstead of the requiredEnum.Operation.DelegateCall.Changes Made
Impact
Users will now have clear, concise guidance on the critical requirement to use DelegateCall for batch transactions, reducing confusion and preventing the "incorrect signer" error.
Original prompt
proposeTransactionsWithSignature()#22✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.