-
Notifications
You must be signed in to change notification settings - Fork 0
feat: setup #2
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
base: main
Are you sure you want to change the base?
feat: setup #2
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "solidity.compileUsingRemoteVersion": "v0.8.34+commit.80d5c536" | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Explicit requirement for latest Solidity version |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ solc = "0.8.34" # See latest release at: https://github.com/argotorg/solidity/re | |
| [fmt] | ||
| sort_imports = true | ||
| number_underscore = "thousands" | ||
| wrap_comments = true | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this, lines can extend without wrapping. |
||
|
|
||
| [profile.ci] | ||
| deny = "warnings" # Why not always: sometimes you just want to code and see what comes out | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| { | ||
| "detectors_to_exclude": "solc-version", | ||
| "detectors_to_exclude": "solc-version,naming-convention,assembly", | ||
|
igorroncevic marked this conversation as resolved.
|
||
| "filter_paths": "/(lib|test|script)/" | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| // SPDX-License-Identifier: MIT OR Apache-2.0 | ||
| pragma solidity ^0.8.34; | ||
|
|
||
| /// @title Solver7702Delegate | ||
| /// @author CoW DAO Developers | ||
| /// @notice ERC-7702 delegation target for solver EOAs | ||
| contract Solver7702Delegate { | ||
| /// @notice Error thrown when a caller is unauthorized | ||
| error Unauthorized(address sender); | ||
|
|
||
| /// @notice Address of the first approved caller | ||
| address private immutable APPROVED_CALLER_0; | ||
|
|
||
| /// @notice Address of the second approved caller | ||
| address private immutable APPROVED_CALLER_1; | ||
|
|
||
| /// @notice Address of the third approved caller | ||
| address private immutable APPROVED_CALLER_2; | ||
|
|
||
| /// @notice Address of the fourth approved caller | ||
| address private immutable APPROVED_CALLER_3; | ||
|
|
||
| /// @notice Address of the fifth approved caller | ||
| address private immutable APPROVED_CALLER_4; | ||
|
|
||
| /// @notice Constructor to initialize the approved callers | ||
| /// @param approvedCallers The addresses of the approved callers | ||
| constructor(address[5] memory approvedCallers) { | ||
| APPROVED_CALLER_0 = approvedCallers[0]; | ||
| APPROVED_CALLER_1 = approvedCallers[1]; | ||
| APPROVED_CALLER_2 = approvedCallers[2]; | ||
| APPROVED_CALLER_3 = approvedCallers[3]; | ||
| APPROVED_CALLER_4 = approvedCallers[4]; | ||
| } | ||
|
|
||
| /// @notice Fallback function to handle calls to the delegate | ||
| fallback() external payable { | ||
| // Simply receive ETH | ||
| if (msg.data.length < 20) return; | ||
|
|
||
| // Possibly short circuit by recognizing one of the approved callers | ||
| if (msg.sender == APPROVED_CALLER_0) return _callThrough(); | ||
| if (msg.sender == APPROVED_CALLER_1) return _callThrough(); | ||
| if (msg.sender == APPROVED_CALLER_2) return _callThrough(); | ||
| if (msg.sender == APPROVED_CALLER_3) return _callThrough(); | ||
| if (msg.sender == APPROVED_CALLER_4) return _callThrough(); | ||
|
|
||
| // Revert if caller is unauthorized | ||
| revert Unauthorized(msg.sender); | ||
| } | ||
|
|
||
| function _callThrough() internal { | ||
| // For our purposes, the target address is encoded as the first 20 bytes of the input data | ||
| address target = address(bytes20(msg.data[0:20])); | ||
|
igorroncevic marked this conversation as resolved.
|
||
|
|
||
| assembly { | ||
| // Extract calldata in range (target, len(msg.data)). | ||
| // We take full control of memory in this inline assembly block because it will not return to Solidity code. | ||
| // This is why we overwrite the Solidity scratch pad at memory position 0. | ||
| calldatacopy(0x00, 20, sub(calldatasize(), 20)) | ||
|
|
||
| // Call the implementation | ||
| let result := | ||
| call( | ||
| gas(), // gas - forward all of it | ||
| target, // target to call | ||
| callvalue(), // value - forward all Ether | ||
| 0x00, // input offset - pointer to calldata | ||
| sub(calldatasize(), 20), // input size - length of calldata | ||
| 0x00, // output offset - 0 because we don't know the size yet | ||
| 0x00 // output size - 0 because we don't know the size yet | ||
| ) | ||
|
|
||
| // Copy return data into memory | ||
| returndatacopy(0x00, 0x00, returndatasize()) | ||
|
|
||
| // Handle return data, 0 = revert / 1 = success | ||
| switch result | ||
| case 0 { | ||
| revert(0x00, returndatasize()) | ||
| } | ||
| default { | ||
| return(0x00, returndatasize()) | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file was deleted.
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.
All of these are necessary:
"func-visibility": ["error", { "ignoreConstructors": true }]-> constructor doesn't require explicit visibility modifier since Solidity 0.7"no-complex-fallback": "off"-> we explicitly need our fallback to be complex"no-inline-assembly": "off"-> we explicitly need assembly for gas efficiency