Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. pragma solidity^0.5.0;
  2. import "./ResultFactory.sol";
  3. import "./EcVerify.sol";
  4.  
  5. contract ApprovalCt {
  6.  
  7. struct AuthContent {
  8. address to;
  9. uint flag;
  10. uint usingTime;
  11. }
  12. mapping(bytes32 => AuthContent[]) public resultToApproval;
  13.  
  14. event Authority (address indexed _to,address indexed _from, address _acAddress);
  15.  
  16. function approval(bytes32 _hash,uint _flag,address _to,uint _time,address factoryCtAdd) public {
  17. //先验证所有权
  18. ResultFactory factory = ResultFactory(factoryCtAdd);
  19. uint len = factory.getCount(_hash);
  20. address ctAddress = factory.hashToCtAddress(_hash,len-1);
  21. Result result = Result(ctAddress);
  22. address owner = result.getOwner()[0];
  23.  
  24. require(msg.sender == owner);
  25.  
  26. AuthContent memory auth = AuthContent(_to,_flag, _time);
  27. // 验证所有人签名 是否真实
  28. resultToApproval[_hash].push(auth);
  29. address _acAddress = address(this);
  30. emit Authority(_to,owner,_acAddress);
  31.  
  32. }
  33.  
  34. function getAuthContent(bytes32 _hash,address _to) public view returns(address,uint,uint){
  35. AuthContent[] memory authArray = resultToApproval[_hash];
  36. uint len = authArray.length;
  37. for(uint i=0; i< len; i++) {
  38. if (authArray[i].to == _to) {
  39. return (authArray[i].to,authArray[i].flag,authArray[i].usingTime);
  40. }
  41. }
  42. }
  43.  
  44. /*function verifySig(string memory _msg, address[] memory owner) public {
  45.  
  46. }*/
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement