Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pragma solidity^0.5.0;
- import "./ResultFactory.sol";
- import "./EcVerify.sol";
- contract ApprovalCt {
- struct AuthContent {
- address to;
- uint flag;
- uint usingTime;
- }
- mapping(bytes32 => AuthContent[]) public resultToApproval;
- event Authority (address indexed _to,address indexed _from, address _acAddress);
- function approval(bytes32 _hash,uint _flag,address _to,uint _time,address factoryCtAdd) public {
- //先验证所有权
- ResultFactory factory = ResultFactory(factoryCtAdd);
- uint len = factory.getCount(_hash);
- address ctAddress = factory.hashToCtAddress(_hash,len-1);
- Result result = Result(ctAddress);
- address owner = result.getOwner()[0];
- require(msg.sender == owner);
- AuthContent memory auth = AuthContent(_to,_flag, _time);
- // 验证所有人签名 是否真实
- resultToApproval[_hash].push(auth);
- address _acAddress = address(this);
- emit Authority(_to,owner,_acAddress);
- }
- function getAuthContent(bytes32 _hash,address _to) public view returns(address,uint,uint){
- AuthContent[] memory authArray = resultToApproval[_hash];
- uint len = authArray.length;
- for(uint i=0; i< len; i++) {
- if (authArray[i].to == _to) {
- return (authArray[i].to,authArray[i].flag,authArray[i].usingTime);
- }
- }
- }
- /*function verifySig(string memory _msg, address[] memory owner) public {
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement