-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ETHEREUM-CONTRACTS] add missing batch call operations (#1967)
* added batch call operations for upgradeTo and downgradeTo * added test case for connecting a pool via batch call * added OPERATION_TYPE_SIMPLE_FORWARD_CALL * added OPERATION_TYPE_ERC2771_FORWARD_CALL * forward native tokens with the first generic external call * fix contract size * appease linter * more comments, fixed value forwarding via 2771 * more verbose documentation * fix hotfuzz init * add dmzfwd to deploy script * adjust mock constructor * disable code to stay inside contract size limit * this is insanity * fix test * fix deployment test * disable only part of the replacePlaceholderCtx test * revert unrelated change * try failing test only * fixed the flakiness source and undid the undo * updated CHANGELOG * allow to withdraw native tokens stuck in DMZForwarder * made host.forwardBatchCall payable too * rename to GeneralDistributionAgreementV1.prop.t.sol * update foundry * use assembly destructor to have different error code * uncomment out test code * update foundry version * [ETHEREUM-CONTRACTS]: typo fixes * [ETHEREUM-CONTRACTS] rename prop.sol to prop.t.sol * fix build warning * ignore mocks from hardhat build * use assembly selfdestruct for now * fix build warning * update CHANGELOG --------- Co-authored-by: Miao, ZhiCheng <[email protected]>
- Loading branch information
Showing
17 changed files
with
725 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
50 changes: 50 additions & 0 deletions
50
packages/ethereum-contracts/contracts/utils/DMZForwarder.sol
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// SPDX-License-Identifier: AGPLv3 | ||
pragma solidity 0.8.23; | ||
|
||
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
|
||
/** | ||
* @title DMZForwarder | ||
* @dev The purpose of this contract is to make arbitrary contract calls batchable | ||
* alongside Superfluid specific batch operations. | ||
* We route the calls through this dedicated contract in order to not have msg.sender set | ||
* to the host contract, for security reasons. | ||
* Forwarded calls can optionally use ERC-2771 to preserve the original msg.sender. | ||
* If native tokens (msg.value) are provided, they are forwarded as well. | ||
*/ | ||
contract DMZForwarder is Ownable { | ||
/** | ||
* @dev Forwards a call for which msg.sender doesn't matter | ||
* @param target The target contract to call | ||
* @param data The call data | ||
*/ | ||
function forwardCall(address target, bytes memory data) | ||
external payable | ||
returns(bool success, bytes memory returnData) | ||
{ | ||
// solhint-disable-next-line avoid-low-level-calls | ||
(success, returnData) = target.call{value: msg.value}(data); | ||
} | ||
|
||
/** | ||
* @dev Forwards a call passing along the original msg.sender encoded as specified in ERC-2771. | ||
* @param target The target contract to call | ||
* @param msgSender The original msg.sender passed along by the trusted contract owner | ||
* @param data The call data | ||
*/ | ||
function forward2771Call(address target, address msgSender, bytes memory data) | ||
external payable onlyOwner | ||
returns(bool success, bytes memory returnData) | ||
{ | ||
// solhint-disable-next-line avoid-low-level-calls | ||
(success, returnData) = target.call{value: msg.value}(abi.encodePacked(data, msgSender)); | ||
} | ||
|
||
/** | ||
* @dev Allows to withdraw native tokens (ETH) which got stuck in this contract. | ||
* This could happen if a call fails, but the caller doesn't revert the tx. | ||
*/ | ||
function withdrawLostNativeTokens(address payable receiver) external onlyOwner { | ||
receiver.transfer(address(this).balance); | ||
} | ||
} |
Oops, something went wrong.