AddressImpl.sol 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // SPDX-License-Identifier: MIT
  2. pragma solidity ^0.8.0;
  3. import "../utils/Address.sol";
  4. contract AddressImpl {
  5. string public sharedAnswer;
  6. event CallReturnValue(string data);
  7. function isContract(address account) external view returns (bool) {
  8. return Address.isContract(account);
  9. }
  10. function sendValue(address payable receiver, uint256 amount) external {
  11. Address.sendValue(receiver, amount);
  12. }
  13. function functionCall(address target, bytes calldata data) external {
  14. bytes memory returnData = Address.functionCall(target, data);
  15. emit CallReturnValue(abi.decode(returnData, (string)));
  16. }
  17. function functionCallWithValue(
  18. address target,
  19. bytes calldata data,
  20. uint256 value
  21. ) external payable {
  22. bytes memory returnData = Address.functionCallWithValue(target, data, value);
  23. emit CallReturnValue(abi.decode(returnData, (string)));
  24. }
  25. function functionStaticCall(address target, bytes calldata data) external {
  26. bytes memory returnData = Address.functionStaticCall(target, data);
  27. emit CallReturnValue(abi.decode(returnData, (string)));
  28. }
  29. function functionDelegateCall(address target, bytes calldata data) external {
  30. bytes memory returnData = Address.functionDelegateCall(target, data);
  31. emit CallReturnValue(abi.decode(returnData, (string)));
  32. }
  33. // sendValue's tests require the contract to hold Ether
  34. receive() external payable {}
  35. }