-
Notifications
You must be signed in to change notification settings - Fork 573
Drop interfaces token structure #173
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
Conversation
function verifyCallResult( | ||
bool success, | ||
bytes memory returndata, | ||
string memory errorMessage | ||
) internal pure returns (bytes memory) { | ||
if (success) { | ||
return returndata; | ||
} else { | ||
// Look for revert reason and bubble it up if present | ||
if (returndata.length > 0) { | ||
// The easiest way to bubble the revert reason is using memory via assembly | ||
|
||
assembly { | ||
let returndata_size := mload(returndata) | ||
revert(add(32, returndata), returndata_size) | ||
} | ||
} else { | ||
revert(errorMessage); | ||
} | ||
} | ||
} |
Check warning
Code scanning / Slither
Assembly usage
// SPDX-License-Identifier: MIT | ||
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Multicall.sol) | ||
|
||
pragma solidity ^0.8.0; |
Check warning
Code scanning / Slither
Different pragma directives are used
function functionCallWithValue( | ||
address target, | ||
bytes memory data, | ||
uint256 value, | ||
string memory errorMessage | ||
) internal returns (bytes memory) { | ||
require(address(this).balance >= value, "Address: insufficient balance for call"); | ||
require(isContract(target), "Address: call to non-contract"); | ||
|
||
(bool success, bytes memory returndata) = target.call{ value: value }(data); | ||
return verifyCallResult(success, returndata, errorMessage); | ||
} |
Check warning
Code scanning / Slither
Low-level calls
function functionDelegateCall( | ||
address target, | ||
bytes memory data, | ||
string memory errorMessage | ||
) internal returns (bytes memory) { | ||
require(isContract(target), "Address: delegate call to non-contract"); | ||
|
||
(bool success, bytes memory returndata) = target.delegatecall(data); | ||
return verifyCallResult(success, returndata, errorMessage); | ||
} |
Check warning
Code scanning / Slither
Low-level calls
function sendValue(address payable recipient, uint256 amount) internal { | ||
require(address(this).balance >= amount, "Address: insufficient balance"); | ||
|
||
(bool success, ) = recipient.call{ value: amount }(""); | ||
require(success, "Address: unable to send value, recipient may have reverted"); | ||
} |
Check warning
Code scanning / Slither
Low-level calls
function functionStaticCall( | ||
address target, | ||
bytes memory data, | ||
string memory errorMessage | ||
) internal view returns (bytes memory) { | ||
require(isContract(target), "Address: static call to non-contract"); | ||
|
||
(bool success, bytes memory returndata) = target.staticcall(data); | ||
return verifyCallResult(success, returndata, errorMessage); | ||
} |
Check warning
Code scanning / Slither
Low-level calls
No description provided.