generated from transmissions11/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GenericUser.sol
30 lines (26 loc) · 913 Bytes
/
GenericUser.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;
contract GenericUser {
function tryCall(address target, bytes memory data, uint256 value_)
public
virtual
returns (bool success, bytes memory returnData)
{
(success, returnData) = target.call{value: value_}(data);
}
function call(address target, bytes memory data, uint256 value) public virtual returns (bytes memory returnData) {
bool success;
(success, returnData) = target.call{value: value}(data);
if (!success) {
if (returnData.length > 0) {
assembly {
let returnDataSize := mload(returnData)
revert(add(32, returnData), returnDataSize)
}
} else {
revert("REVERTED_WITHOUT_MESSAGE");
}
}
}
receive() external payable {}
}