-
Notifications
You must be signed in to change notification settings - Fork 547
Checkout plugin and proxy #598
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #598 +/- ##
==========================================
+ Coverage 64.08% 64.14% +0.06%
==========================================
Files 215 218 +3
Lines 6632 6708 +76
==========================================
+ Hits 4250 4303 +53
- Misses 2382 2405 +23 ☔ View full report in Codecov by Sentry. |
function _execute(UserOp memory op) internal { | ||
bool success; | ||
if (op.currency == CurrencyTransferLib.NATIVE_TOKEN) { | ||
(success, ) = op.target.call{ value: op.valueToSend }(op.data); | ||
} else { | ||
if (op.valueToSend != 0 && op.approvalRequired) { | ||
IERC20(op.currency).approve(op.target, op.valueToSend); | ||
} | ||
|
||
(success, ) = op.target.call(op.data); | ||
} | ||
|
||
require(success, "Execution failed"); | ||
} |
Check failure
Code scanning / Slither
Functions that send Ether to arbitrary destinations
function _execute(UserOp memory op) internal { | ||
bool success; | ||
if (op.currency == CurrencyTransferLib.NATIVE_TOKEN) { | ||
(success, ) = op.target.call{ value: op.valueToSend }(op.data); | ||
} else { | ||
if (op.valueToSend != 0 && op.approvalRequired) { | ||
IERC20(op.currency).approve(op.target, op.valueToSend); | ||
} | ||
|
||
(success, ) = op.target.call(op.data); | ||
} | ||
|
||
require(success, "Execution failed"); | ||
} |
Check warning
Code scanning / Slither
Unused return
function _execute(UserOp memory op) internal { | ||
bool success; | ||
if (op.currency == CurrencyTransferLib.NATIVE_TOKEN) { | ||
(success, ) = op.target.call{ value: op.valueToSend }(op.data); | ||
} else { | ||
if (op.valueToSend != 0 && op.approvalRequired) { | ||
IERC20(op.currency).approve(op.target, op.valueToSend); | ||
} | ||
|
||
(success, ) = op.target.call(op.data); | ||
} | ||
|
||
require(success, "Execution failed"); | ||
} |
Check warning
Code scanning / Slither
Low-level calls
function _installPlugin(IPRBProxyPlugin plugin) internal { | ||
// Retrieve the methods to install. | ||
bytes4[] memory methods = plugin.getMethods(); | ||
|
||
// The plugin must implement at least one method. | ||
uint256 length = methods.length; | ||
if (length == 0) { | ||
revert PRBProxyRegistry_PluginWithZeroMethods(plugin); | ||
} | ||
|
||
// Install every method in the list. | ||
address owner = msg.sender; | ||
for (uint256 i = 0; i < length; ) { | ||
// Check for collisions. | ||
bytes4 method = methods[i]; | ||
if (address(_plugins[owner][method]) != address(0)) { | ||
revert PRBProxyRegistry_PluginMethodCollision({ | ||
currentPlugin: _plugins[owner][method], | ||
newPlugin: plugin, | ||
method: method | ||
}); | ||
} | ||
_plugins[owner][method] = plugin; | ||
unchecked { | ||
i += 1; | ||
} | ||
} | ||
|
||
// Set the methods in the reverse mapping. | ||
_methods[owner][plugin] = methods; | ||
|
||
// Log the plugin installation. | ||
emit InstallPlugin(owner, _proxies[owner], plugin, methods); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function deployAndInstallPlugin( | ||
IPRBProxyPlugin plugin | ||
) external onlyNonProxyOwner(msg.sender) returns (IPRBProxy proxy) { | ||
proxy = _deploy({ owner: msg.sender, target: address(0), data: "" }); | ||
_installPlugin(plugin); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function _deploy(address owner, address target, bytes memory data) internal returns (IPRBProxy proxy) { | ||
// Use the address of the owner as the CREATE2 salt. | ||
bytes32 salt = bytes32(abi.encodePacked(owner)); | ||
|
||
// Set the owner and empty out the target and the data to prevent reentrancy. | ||
constructorParams = ConstructorParams({ owner: owner, target: target, data: data }); | ||
|
||
// Deploy the proxy with CREATE2. | ||
proxy = new PRBProxy{ salt: salt }(); | ||
delete constructorParams; | ||
|
||
// Associate the owner and the proxy. | ||
_proxies[owner] = proxy; | ||
|
||
// Log the creation of the proxy. | ||
emit DeployProxy({ operator: msg.sender, owner: owner, proxy: proxy }); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function deployAndExecuteAndInstallPlugin( | ||
address target, | ||
bytes calldata data, | ||
IPRBProxyPlugin plugin | ||
) external override onlyNonProxyOwner(msg.sender) returns (IPRBProxy proxy) { | ||
proxy = _deploy({ owner: msg.sender, target: target, data: data }); | ||
_installPlugin(plugin); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function deployAndExecuteAndInstallPlugin( | ||
address target, | ||
bytes calldata data, | ||
IPRBProxyPlugin plugin | ||
) external override onlyNonProxyOwner(msg.sender) returns (IPRBProxy proxy) { | ||
proxy = _deploy({ owner: msg.sender, target: target, data: data }); | ||
_installPlugin(plugin); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function deployAndInstallPlugin( | ||
IPRBProxyPlugin plugin | ||
) external onlyNonProxyOwner(msg.sender) returns (IPRBProxy proxy) { | ||
proxy = _deploy({ owner: msg.sender, target: address(0), data: "" }); | ||
_installPlugin(plugin); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function _installPlugin(IPRBProxyPlugin plugin) internal { | ||
// Retrieve the methods to install. | ||
bytes4[] memory methods = plugin.getMethods(); | ||
|
||
// The plugin must implement at least one method. | ||
uint256 length = methods.length; | ||
if (length == 0) { | ||
revert PRBProxyRegistry_PluginWithZeroMethods(plugin); | ||
} | ||
|
||
// Install every method in the list. | ||
address owner = msg.sender; | ||
for (uint256 i = 0; i < length; ) { | ||
// Check for collisions. | ||
bytes4 method = methods[i]; | ||
if (address(_plugins[owner][method]) != address(0)) { | ||
revert PRBProxyRegistry_PluginMethodCollision({ | ||
currentPlugin: _plugins[owner][method], | ||
newPlugin: plugin, | ||
method: method | ||
}); | ||
} | ||
_plugins[owner][method] = plugin; | ||
unchecked { | ||
i += 1; | ||
} | ||
} | ||
|
||
// Set the methods in the reverse mapping. | ||
_methods[owner][plugin] = methods; | ||
|
||
// Log the plugin installation. | ||
emit InstallPlugin(owner, _proxies[owner], plugin, methods); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
function _deploy(address owner, address target, bytes memory data) internal returns (IPRBProxy proxy) { | ||
// Use the address of the owner as the CREATE2 salt. | ||
bytes32 salt = bytes32(abi.encodePacked(owner)); | ||
|
||
// Set the owner and empty out the target and the data to prevent reentrancy. | ||
constructorParams = ConstructorParams({ owner: owner, target: target, data: data }); | ||
|
||
// Deploy the proxy with CREATE2. | ||
proxy = new PRBProxy{ salt: salt }(); | ||
delete constructorParams; | ||
|
||
// Associate the owner and the proxy. | ||
_proxies[owner] = proxy; | ||
|
||
// Log the creation of the proxy. | ||
emit DeployProxy({ operator: msg.sender, owner: owner, proxy: proxy }); | ||
} |
Check notice
Code scanning / Slither
Reentrancy vulnerabilities
@@ -0,0 +1,251 @@ | |||
// SPDX-License-Identifier: MIT | |||
pragma solidity >=0.8.18; |
Check warning
Code scanning / Slither
Different pragma directives are used
No description provided.