-
Notifications
You must be signed in to change notification settings - Fork 242
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
[ETHEREUM-CONTRACTS] add missing batch call operations #1967
Changes from 37 commits
c163b35
947699e
84bd23e
1f31d3c
b9582cd
a1ae6ad
8152677
b78a0d3
839072c
1391b1f
23048b0
48279c1
71b0158
30aed68
9ec13fb
39dfb01
34c5bb5
804734d
5772a07
ea4d3a3
bb6fda4
08a17fd
b511690
3f4c8e3
913d39d
43176b0
0cd9fc3
08ffbc3
77dae62
5d7011b
fb2654a
4833be0
d8b9e17
287e1c2
5fceaf1
84bb8ba
4daae4b
524ae94
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 |
---|---|---|
|
@@ -882,6 +882,20 @@ contract SuperToken is | |
_downgrade(msg.sender, account, account, amount, "", ""); | ||
} | ||
|
||
function operationUpgradeTo(address account, address to, uint256 amount) | ||
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. this will require Token upgrades 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. right. Also we may later consider deprecating the variants without |
||
external virtual override | ||
onlyHost | ||
{ | ||
_upgrade(msg.sender, account, to, amount, "", ""); | ||
} | ||
|
||
function operationDowngradeTo(address account, address to, uint256 amount) | ||
external virtual override | ||
onlyHost | ||
{ | ||
_downgrade(msg.sender, account, to, amount, "", ""); | ||
} | ||
|
||
/************************************************************************** | ||
* Modifiers | ||
*************************************************************************/ | ||
|
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); | ||
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. Is there any merit to using 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.
I don't think so
No, but I added a function for withdrawing stuck native tokens. |
||
} | ||
|
||
/** | ||
* @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); | ||
} | ||
} |
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.
to be in sync with the rest, use typed signature, and call "data" "callData" to be more specific.