Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. pragma solidity >=0.5.2;
  2. pragma experimental ABIEncoderV2;
  3.  
  4. import "./P2POwnable.sol";
  5.  
  6. contract Wallet is P2POwnable {
  7. function exec(address target, uint value, uint gasLimit, bytes memory data) public returns(bool success, bytes memory result) {
  8. (success, result) = target.call.value(value).gas((gasLimit == 0) ? gasleft() : gasLimit)(data);
  9. }
  10.  
  11. function execView(address target, bytes memory data) public view returns(bool success, bytes memory result) {
  12. (success, result) = target.staticcall(data);
  13. }
  14.  
  15. event Log(bytes32 reqhash, bool success, bytes result);
  16.  
  17. function execMultipleAny(address[] memory target, uint[] memory value, uint[] memory gasLimit, bytes[] memory data) public returns(bool){
  18. uint n = target.length;
  19. require((value.length == n) && (gasLimit.length == n) && (data.length == n));
  20. for (uint i=0; i<n; i++) {
  21. bytes32 reqhash = keccak256(abi.encodePacked(target[i], value[i], gasLimit[i], data[i]));
  22. (bool success, bytes memory result) = target[i].call.value(value[i]).gas((gasLimit[i] == 0) ? gasleft() : gasLimit[i])(data[i]);
  23. emit Log(reqhash, success, result);
  24. }
  25. return true;
  26. }
  27.  
  28. function execMultipleAll(address[] memory target, uint[] memory value, uint[] memory gasLimit, bytes[] memory data) public returns(bool){
  29. uint n = target.length;
  30. require((value.length == n) && (gasLimit.length == n) && (data.length == n));
  31. for (uint i=0; i<n; i++) {
  32. bytes32 reqhash = keccak256(abi.encodePacked(target[i], value[i], gasLimit[i], data[i]));
  33. (bool success, bytes memory result) = target[i].call.value(value[i]).gas((gasLimit[i] == 0) ? gasleft() : gasLimit[i])(data[i]);
  34. emit Log(reqhash, success, result);
  35. require(success);
  36. }
  37. return true;
  38. }
  39.  
  40. function() external payable {}
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement