diff --git a/contracts/Identity.sol b/contracts/Identity.sol new file mode 100644 index 0000000..3b043e9 --- /dev/null +++ b/contracts/Identity.sol @@ -0,0 +1,45 @@ +pragma solidity ^0.6.8; + + +contract identity{ + address payable owner; + uint idCount; + + constructor() public { + owner = msg.sender; + idCount = 0; + } + + mapping (address => mapping (address => uint) ) approvedIdentity ; + + mapping (address => bytes32) approverInfo; + + function registerApprover( bytes32 ipfsHash ) public returns (bool) { + approverInfo[msg.sender] = ipfsHash; + return true; + } + + function approveIdentity( address identity, uint level) public returns (bool) { + require (approverInfo[msg.sender] != 0, "Please register first"); + approvedIdentity[msg.sender][identity] = level; + return true; + } + + function getSecurityLevel( address approver, address identity) public view returns (uint) { + if (approverInfo[approver] != 0 && approvedIdentity[approver][identity] != 0) { + return approvedIdentity[approver][identity]; + } + else { + return 0; + } + } + function getApproverInfo (address approver) public view returns (bytes32) { + if (approverInfo[approver] != 0) { + return approverInfo[approver]; + } + else { + return 0; + } + } + +} diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 386c3e3..7e57b7b 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -1,9 +1,11 @@ const SimpleStorage = artifacts.require("SimpleStorage"); const EventLibrary = artifacts.require("EventLibrary"); const EventFactory = artifacts.require("EventFactory"); +const Identity = artifacts.require("Identity"); module.exports = function (deployer) { deployer.deploy(SimpleStorage); deployer.deploy(EventLibrary); deployer.deploy(EventFactory); + deployer.deploy(Identity); };