Skip to content

Commit

Permalink
Remove duplicated functions and implement signedMultiSend, _implement…
Browse files Browse the repository at this point in the history
…ation, and _checkOwner functions
  • Loading branch information
sweep-ai[bot] committed Aug 14, 2023
1 parent b130f77 commit d49ecb2
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/Router.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,28 @@ contract Router is Proxy, ERC1155Holder, ERC721Holder {

error NotOwner();

function updatePluginLogic(address _pluginLogic) external {
_checkOwner();
pluginLogic = _pluginLogic;
}

function multiSend(bytes calldata transactions) external payable {
_checkOwner();
MultiSendCallOnly.multiSend(transactions);
}
function signedMultiSend(bytes calldata transactions, bytes calldata signature, uint256 _nonce) external {
_checkOwner();
// Verify the signature and recover the owner address
address recoveredOwner = recoverOwner(transactions, signature);
// Check if the recovered owner address matches the current owner of the router
require(recoveredOwner == msg.sender, "Invalid signature");
// Increment the nonce value randomly
nonce = _nonce + 1;
// Call the multiSend function with the provided transactions parameter
multiSend(transactions);
}

function _implementation() internal view override returns (address) {
return pluginLogic;
}

function _checkOwner() internal view {
address router = routerImplementation.predictDeterministicAddress(
keccak256(abi.encode(msg.sender)), registry
);
if (router != address(this)) revert NotOwner();
}

function signedMultiSend(bytes calldata transactions, bytes calldata signature, uint256 _nonce) external {
_checkOwner();
Expand Down

0 comments on commit d49ecb2

Please sign in to comment.