mirror of https://github.com/poanetwork/quorum.git
permissions: fine tuning of implementation code, added node status update call
This commit is contained in:
parent
a98971370c
commit
0ca8694321
|
@ -5,7 +5,7 @@ import "./PermissionsUpgradable.sol";
|
||||||
contract NodeManager {
|
contract NodeManager {
|
||||||
PermissionsUpgradable private permUpgradable;
|
PermissionsUpgradable private permUpgradable;
|
||||||
// enum and struct declaration
|
// enum and struct declaration
|
||||||
// changing node status to integer (0-NotInList, 1- PendingApproval, 2-Approved,
|
// changing node status to integer (0-NotInList, 1- PendingApproval, 2-Approved, 3-Deactivated, 4-Blacklisted)
|
||||||
// PendingDeactivation, Deactivated, PendingActivation, PendingBlacklisting, Blacklisted)
|
// PendingDeactivation, Deactivated, PendingActivation, PendingBlacklisting, Blacklisted)
|
||||||
// enum NodeStatus {NotInList, PendingApproval, Approved, PendingDeactivation, Deactivated, PendingActivation, PendingBlacklisting, Blacklisted}
|
// enum NodeStatus {NotInList, PendingApproval, Approved, PendingDeactivation, Deactivated, PendingActivation, PendingBlacklisting, Blacklisted}
|
||||||
struct NodeDetails {
|
struct NodeDetails {
|
||||||
|
@ -27,16 +27,13 @@ contract NodeManager {
|
||||||
event NodeApproved(string _enodeId);
|
event NodeApproved(string _enodeId);
|
||||||
|
|
||||||
// node permission events for node decativation
|
// node permission events for node decativation
|
||||||
event NodePendingDeactivation (string _enodeId);
|
|
||||||
event NodeDeactivated(string _enodeId);
|
event NodeDeactivated(string _enodeId);
|
||||||
|
|
||||||
// node permission events for node activation
|
// node permission events for node activation
|
||||||
event NodePendingActivation(string _enodeId);
|
|
||||||
event NodeActivated(string _enodeId);
|
event NodeActivated(string _enodeId);
|
||||||
|
|
||||||
// node permission events for node blacklist
|
// node permission events for node blacklist
|
||||||
event NodePendingBlacklist(string _enodeId);
|
event NodeBlacklisted(string _enodeId);
|
||||||
event NodeBlacklisted(string);
|
|
||||||
|
|
||||||
modifier onlyImpl
|
modifier onlyImpl
|
||||||
{
|
{
|
||||||
|
@ -88,7 +85,14 @@ contract NodeManager {
|
||||||
return nodeList[getNodeIndex(_enodeId)].status;
|
return nodeList[getNodeIndex(_enodeId)].status;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addNode(string calldata _enodeId, string calldata _orgId) external
|
function addAdminNode(string calldata _enodeId, string calldata _orgId) external
|
||||||
|
onlyImpl
|
||||||
|
enodeNotInList(_enodeId)
|
||||||
|
{
|
||||||
|
addNode(_enodeId, _orgId);
|
||||||
|
approveNode(_enodeId, _orgId);
|
||||||
|
}
|
||||||
|
function addNode(string memory _enodeId, string memory _orgId) public
|
||||||
onlyImpl
|
onlyImpl
|
||||||
enodeNotInList(_enodeId)
|
enodeNotInList(_enodeId)
|
||||||
{
|
{
|
||||||
|
@ -109,9 +113,12 @@ contract NodeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds a node to the nodeList mapping and emits node added event if successfully and node exists event of node is already present
|
// Adds a node to the nodeList mapping and emits node added event if successfully and node exists event of node is already present
|
||||||
function approveNode(string calldata _enodeId) external
|
function approveNode(string memory _enodeId, string memory _orgId) public
|
||||||
onlyImpl
|
onlyImpl
|
||||||
|
enodeInList(_enodeId)
|
||||||
{
|
{
|
||||||
|
// node should belong to the passed org
|
||||||
|
require(checkOrg(_enodeId, _orgId), "Node does not belong to the org");
|
||||||
require(getNodeStatus(_enodeId) == 1, "Node need to be in PendingApproval status");
|
require(getNodeStatus(_enodeId) == 1, "Node need to be in PendingApproval status");
|
||||||
uint nodeIndex = getNodeIndex(_enodeId);
|
uint nodeIndex = getNodeIndex(_enodeId);
|
||||||
// vote node
|
// vote node
|
||||||
|
@ -119,98 +126,43 @@ contract NodeManager {
|
||||||
emit NodeApproved(nodeList[nodeIndex].enodeId);
|
emit NodeApproved(nodeList[nodeIndex].enodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// // Propose a node for deactivation from network
|
function updateNodeStatus(string calldata _enodeId, string calldata _orgId, uint _status) external
|
||||||
// function proposeDeactivation(string calldata _enodeId) external enodeInList(_enodeId)
|
onlyImpl
|
||||||
// {
|
enodeInList(_enodeId)
|
||||||
// require(getNodeStatus(_enodeId) == NodeStatus.Approved, "Node need to be in Approved status");
|
{
|
||||||
// uint nodeIndex = getNodeIndex(_enodeId);
|
// node should belong to the org
|
||||||
// nodeList[nodeIndex].status = NodeStatus.PendingDeactivation;
|
require(checkOrg(_enodeId, _orgId), "Node does not belong to the org");
|
||||||
// emit NodePendingDeactivation(_enodeId);
|
// changing node status to integer (0-NotInList, 1- PendingApproval, 2-Approved, 3-Deactivated, 4-Blacklisted)
|
||||||
//
|
// operations that can be done 3-Deactivate Node, 4-ActivateNode, 5-Blacklist nodeList
|
||||||
// }
|
require((_status == 3 || _status == 4 || _status == 5), "invalid operation");
|
||||||
//
|
|
||||||
// //deactivates a given Enode and emits the decativation event
|
|
||||||
// function deactivateNode(string calldata _enodeId) external
|
|
||||||
// {
|
|
||||||
// require(getNodeStatus(_enodeId) == NodeStatus.PendingDeactivation, "Node need to be in PendingDeactivation status");
|
|
||||||
// uint nodeIndex = getNodeIndex(_enodeId);
|
|
||||||
// nodeList[nodeIndex].status = NodeStatus.Deactivated;
|
|
||||||
// emit NodeDeactivated(nodeList[nodeIndex].enodeId);
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // Propose node for blacklisting
|
|
||||||
// function proposeNodeActivation(string calldata _enodeId) external
|
|
||||||
// {
|
|
||||||
// require(getNodeStatus(_enodeId) == NodeStatus.Deactivated, "Node need to be in Deactivated status");
|
|
||||||
// uint nodeIndex = getNodeIndex(_enodeId);
|
|
||||||
// nodeList[nodeIndex].status = NodeStatus.PendingActivation;
|
|
||||||
// // emit event
|
|
||||||
// emit NodePendingActivation(_enodeId);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //deactivates a given Enode and emits the decativation event
|
if (_status == 3){
|
||||||
// function activateNode(string calldata _enodeId) external
|
require(getNodeStatus(_enodeId) == 2, "Op cannot be performed");
|
||||||
// {
|
nodeList[getNodeIndex(_enodeId)].status = 3;
|
||||||
// require(getNodeStatus(_enodeId) == NodeStatus.PendingActivation, "Node need to be in PendingActivation status");
|
emit NodeDeactivated(_enodeId);
|
||||||
// uint nodeIndex = getNodeIndex(_enodeId);
|
}
|
||||||
// require(voteStatus[nodeIndex][msg.sender] == false, "Node can not double vote");
|
else if (_status == 4){
|
||||||
// // vote node
|
require(getNodeStatus(_enodeId) == 3, "Op cannot be performed");
|
||||||
// updateVoteStatus(nodeIndex);
|
nodeList[getNodeIndex(_enodeId)].status = 2;
|
||||||
// // emit event
|
emit NodeActivated(_enodeId);
|
||||||
// // check if node vote reach majority
|
}
|
||||||
// if (checkEnoughVotes(nodeIndex)) {
|
else {
|
||||||
// nodeList[nodeIndex].status = NodeStatus.Approved;
|
nodeList[getNodeIndex(_enodeId)].status = 5;
|
||||||
// emit NodeActivated(nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort);
|
emit NodeBlacklisted(_enodeId);
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // Propose node for blacklisting
|
|
||||||
// function proposeNodeBlacklisting(string calldata _enodeId, string calldata _ipAddrPort, string calldata _discPort, string calldata _raftPort) external
|
|
||||||
// {
|
|
||||||
// if (checkVotingAccountExist()) {
|
|
||||||
// uint nodeIndex = getNodeIndex(_enodeId);
|
|
||||||
// // check if node is in the nodeList
|
|
||||||
// if (nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] != 0) {
|
|
||||||
// // no matter what status the node is in, vote will reset and node status change to PendingBlacklisting
|
|
||||||
// nodeList[nodeIndex].status = NodeStatus.PendingBlacklisting;
|
|
||||||
// nodeIndex = getNodeIndex(_enodeId);
|
|
||||||
// } else {
|
|
||||||
// // increment node number, add node to the list
|
|
||||||
// numberOfNodes++;
|
|
||||||
// nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] = numberOfNodes;
|
|
||||||
// nodeList.push(NodeDetails(_enodeId, _ipAddrPort, _discPort, _raftPort, NodeStatus.PendingBlacklisting));
|
|
||||||
// nodeIndex = numberOfNodes;
|
|
||||||
// }
|
|
||||||
// // add voting status, numberOfNodes is the index of current proposed node
|
|
||||||
// initNodeVoteStatus(nodeIndex);
|
|
||||||
// // emit event
|
|
||||||
// emit NodePendingBlacklist(_enodeId);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //Approve node blacklisting
|
|
||||||
// function blacklistNode(string calldata _enodeId) external
|
|
||||||
// {
|
|
||||||
// require(getNodeStatus(_enodeId) == NodeStatus.PendingBlacklisting, "Node need to be in PendingBlacklisting status");
|
|
||||||
// uint nodeIndex = getNodeIndex(_enodeId);
|
|
||||||
// require(voteStatus[nodeIndex][msg.sender] == false, "Node can not double vote");
|
|
||||||
// // vote node
|
|
||||||
// voteStatus[nodeIndex][msg.sender] = true;
|
|
||||||
// voteCount[nodeIndex]++;
|
|
||||||
// // emit event
|
|
||||||
// // check if node vote reach majority
|
|
||||||
// if (checkEnoughVotes(nodeIndex)) {
|
|
||||||
// nodeList[nodeIndex].status = NodeStatus.Blacklisted;
|
|
||||||
// emit NodeBlacklisted(nodeList[nodeIndex].enodeId, nodeList[nodeIndex].ipAddrPort, nodeList[nodeIndex].discPort, nodeList[nodeIndex].raftPort);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/* private functions */
|
/* private functions */
|
||||||
function getNodeIndex(string memory _enodeId) internal view returns (uint)
|
function getNodeIndex(string memory _enodeId) internal view
|
||||||
|
returns (uint)
|
||||||
{
|
{
|
||||||
return nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] - 1;
|
return nodeIdToIndex[keccak256(abi.encodePacked(_enodeId))] - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkOrg(string memory _enodeId, string memory _orgId) internal view
|
||||||
|
returns(bool)
|
||||||
|
{
|
||||||
|
return (keccak256(abi.encodePacked(nodeList[getNodeIndex(_enodeId)].orgId)) == keccak256(abi.encodePacked(_orgId)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,13 +93,27 @@ contract OrgManager {
|
||||||
function updateOrg(string calldata _orgId, uint _status) external
|
function updateOrg(string calldata _orgId, uint _status) external
|
||||||
onlyImpl
|
onlyImpl
|
||||||
orgExists(_orgId)
|
orgExists(_orgId)
|
||||||
|
returns (uint)
|
||||||
{
|
{
|
||||||
|
require ((_status == 3 || _status == 5), "Operation not allowed");
|
||||||
|
uint reqStatus;
|
||||||
|
uint pendingOp;
|
||||||
|
if (_status == 3) {
|
||||||
|
reqStatus = 2;
|
||||||
|
pendingOp = 2;
|
||||||
|
}
|
||||||
|
else if (_status == 5) {
|
||||||
|
reqStatus = 4;
|
||||||
|
pendingOp = 3;
|
||||||
|
}
|
||||||
|
require(checkOrgStatus(_orgId, reqStatus) == true, "Operation not allowed");
|
||||||
if (_status == 3) {
|
if (_status == 3) {
|
||||||
suspendOrg(_orgId);
|
suspendOrg(_orgId);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
revokeOrgSuspension(_orgId);
|
revokeOrgSuspension(_orgId);
|
||||||
}
|
}
|
||||||
|
return pendingOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function approveOrgStatusUpdate(string calldata _orgId, uint _status) external
|
function approveOrgStatusUpdate(string calldata _orgId, uint _status) external
|
||||||
|
|
|
@ -33,19 +33,11 @@ contract PermissionsImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the given network boot up is pending exists
|
// Checks if the given network boot up is pending exists
|
||||||
modifier networkBootUpPending()
|
modifier networkBootStatus(bool _status)
|
||||||
{
|
{
|
||||||
require(networkBoot == false, "Network boot up completed");
|
require(networkBoot == _status, "Incorrect network boot status");
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if the given network boot up is pending exists
|
|
||||||
modifier networkBootUpDone()
|
|
||||||
{
|
|
||||||
require(networkBoot == true, "Network boot not complete");
|
|
||||||
_;
|
|
||||||
}
|
|
||||||
|
|
||||||
modifier networkAdmin(address _account) {
|
modifier networkAdmin(address _account) {
|
||||||
require(isNetworkAdmin(_account) == true, "Not an network admin");
|
require(isNetworkAdmin(_account) == true, "Not an network admin");
|
||||||
_;
|
_;
|
||||||
|
@ -57,17 +49,17 @@ contract PermissionsImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier orgNotExists(string memory _orgId) {
|
modifier orgNotExists(string memory _orgId) {
|
||||||
require(org.checkOrgExists(_orgId) == false, "Org already exists");
|
require(checkOrgExists(_orgId) != true, "Org already exists");
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier orgExists(string memory _orgId) {
|
modifier orgExists(string memory _orgId) {
|
||||||
require(org.checkOrgExists(_orgId) == true, "Org does not exists");
|
require(checkOrgExists(_orgId) == true, "Org does not exists");
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
modifier orgApproved(string memory _orgId) {
|
modifier orgApproved(string memory _orgId) {
|
||||||
require(org.checkOrgStatus(_orgId, 2) == true, "Org not approved");
|
require(checkOrgApproved(_orgId) == true, "Org not approved");
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +69,7 @@ contract PermissionsImplementation {
|
||||||
|
|
||||||
function setPolicy(string calldata _nwAdminOrg, string calldata _nwAdminRole, string calldata _oAdminRole) external
|
function setPolicy(string calldata _nwAdminOrg, string calldata _nwAdminRole, string calldata _oAdminRole) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpPending()
|
networkBootStatus(false)
|
||||||
{
|
{
|
||||||
adminOrg = _nwAdminOrg;
|
adminOrg = _nwAdminOrg;
|
||||||
adminRole = _nwAdminRole;
|
adminRole = _nwAdminRole;
|
||||||
|
@ -86,7 +78,7 @@ contract PermissionsImplementation {
|
||||||
|
|
||||||
function init(address _orgManager, address _rolesManager, address _acctManager, address _voterManager, address _nodeManager) external
|
function init(address _orgManager, address _rolesManager, address _acctManager, address _voterManager, address _nodeManager) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpPending()
|
networkBootStatus(false)
|
||||||
{
|
{
|
||||||
org = OrgManager(_orgManager);
|
org = OrgManager(_orgManager);
|
||||||
roles = RoleManager(_rolesManager);
|
roles = RoleManager(_rolesManager);
|
||||||
|
@ -101,18 +93,17 @@ contract PermissionsImplementation {
|
||||||
|
|
||||||
function addAdminNodes(string calldata _enodeId) external
|
function addAdminNodes(string calldata _enodeId) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpPending()
|
networkBootStatus(false)
|
||||||
{
|
{
|
||||||
nodes.addNode(_enodeId, adminOrg);
|
nodes.addAdminNode(_enodeId, adminOrg);
|
||||||
nodes.approveNode(_enodeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAdminAccounts(address _acct) external
|
function addAdminAccounts(address _acct) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpPending()
|
networkBootStatus(false)
|
||||||
{
|
{
|
||||||
// add the account as a voter for the admin org
|
// add the account as a voter for the admin org
|
||||||
voter.addVoter(adminOrg, _acct);
|
updateVoterList(adminOrg, _acct, true);
|
||||||
// add the account as an account with full access into the admin org
|
// add the account as an account with full access into the admin org
|
||||||
accounts.addNWAdminAccount(_acct, adminOrg);
|
accounts.addNWAdminAccount(_acct, adminOrg);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +111,7 @@ contract PermissionsImplementation {
|
||||||
// update the network boot status as true
|
// update the network boot status as true
|
||||||
function updateNetworkBootStatus() external
|
function updateNetworkBootStatus() external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpPending()
|
networkBootStatus(false)
|
||||||
returns (bool)
|
returns (bool)
|
||||||
{
|
{
|
||||||
networkBoot = true;
|
networkBoot = true;
|
||||||
|
@ -137,7 +128,7 @@ contract PermissionsImplementation {
|
||||||
// function for adding a new master org
|
// function for adding a new master org
|
||||||
function addOrg(string calldata _orgId, string calldata _enodeId, address _caller) external
|
function addOrg(string calldata _orgId, string calldata _enodeId, address _caller) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpDone()
|
networkBootStatus(true)
|
||||||
orgNotExists(_orgId)
|
orgNotExists(_orgId)
|
||||||
networkAdmin(_caller)
|
networkAdmin(_caller)
|
||||||
{
|
{
|
||||||
|
@ -148,57 +139,43 @@ contract PermissionsImplementation {
|
||||||
|
|
||||||
function approveOrg(string calldata _orgId, string calldata _enodeId, address _caller) external
|
function approveOrg(string calldata _orgId, string calldata _enodeId, address _caller) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpDone()
|
|
||||||
networkAdmin(_caller)
|
networkAdmin(_caller)
|
||||||
{
|
{
|
||||||
require(org.checkOrgStatus(_orgId, 1) == true, "Nothing to approve");
|
require(checkOrgStatus(_orgId, 1) == true, "Nothing to approve");
|
||||||
if ((voter.processVote(adminOrg, _caller, 1))) {
|
if ((processVote(adminOrg, _caller, 1))) {
|
||||||
org.approveOrg(_orgId);
|
org.approveOrg(_orgId);
|
||||||
nodes.approveNode(_enodeId);
|
nodes.approveNode(_enodeId, _orgId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// function updateOrgStatus(string calldata _orgId, uint _status) external
|
function updateOrgStatus(string calldata _orgId, uint _status) external
|
||||||
// onlyProxy
|
onlyProxy
|
||||||
// networkBootUpDone()
|
orgExists(_orgId)
|
||||||
// orgExists(_orgId)
|
networkAdmin(msg.sender)
|
||||||
// networkAdmin(msg.sender)
|
{
|
||||||
// {
|
uint pendingOp;
|
||||||
// require ((_status == 3 || _status == 5), "Operation not allowed");
|
pendingOp = org.updateOrg(_orgId, _status);
|
||||||
// uint reqStatus;
|
voter.addVotingItem(adminOrg, _orgId, "", address(0), pendingOp);
|
||||||
// uint pendingOp;
|
}
|
||||||
// if (_status == 3) {
|
|
||||||
// reqStatus = 2;
|
function approveOrgStatus(string calldata _orgId, uint _status) external
|
||||||
// pendingOp = 2;
|
onlyProxy
|
||||||
// }
|
orgExists(_orgId)
|
||||||
// else if (_status == 5) {
|
networkAdmin(msg.sender)
|
||||||
// reqStatus = 4;
|
{
|
||||||
// pendingOp = 3;
|
require ((_status == 3 || _status == 5), "Operation not allowed");
|
||||||
// }
|
uint pendingOp;
|
||||||
// require(org.checkOrgStatus(_orgId, reqStatus) == true, "Operation not allowed");
|
if (_status == 3) {
|
||||||
// org.updateOrg(_orgId, _status);
|
pendingOp = 2;
|
||||||
// voter.addVotingItem(adminOrg, _orgId, "", address(0), pendingOp);
|
}
|
||||||
// }
|
else if (_status == 5) {
|
||||||
//
|
pendingOp = 3;
|
||||||
// function approveOrgStatus(string calldata _orgId, uint _status) external
|
}
|
||||||
// onlyProxy
|
require(checkOrgStatus(_orgId, _status) == true, "Operation not allowed");
|
||||||
// networkBootUpDone()
|
if ((processVote(adminOrg, msg.sender, pendingOp))) {
|
||||||
// orgExists(_orgId)
|
org.approveOrgStatusUpdate(_orgId, _status);
|
||||||
// networkAdmin(msg.sender)
|
}
|
||||||
// {
|
}
|
||||||
// require ((_status == 3 || _status == 5), "Operation not allowed");
|
|
||||||
// uint pendingOp;
|
|
||||||
// if (_status == 3) {
|
|
||||||
// pendingOp = 2;
|
|
||||||
// }
|
|
||||||
// else if (_status == 5) {
|
|
||||||
// pendingOp = 3;
|
|
||||||
// }
|
|
||||||
// require(org.checkOrgStatus(_orgId, _status) == true, "Operation not allowed");
|
|
||||||
// if ((voter.processVote(adminOrg, msg.sender, pendingOp))) {
|
|
||||||
// org.approveOrgStatusUpdate(_orgId, _status);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// returns org and master org details based on org index
|
// returns org and master org details based on org index
|
||||||
function getOrgInfo(uint _orgIndex) external view
|
function getOrgInfo(uint _orgIndex) external view
|
||||||
returns (string memory, uint)
|
returns (string memory, uint)
|
||||||
|
@ -259,12 +236,11 @@ contract PermissionsImplementation {
|
||||||
|
|
||||||
function assignOrgAdminAccount(string calldata _orgId, address _account, address _caller) external
|
function assignOrgAdminAccount(string calldata _orgId, address _account, address _caller) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpDone()
|
|
||||||
networkAdmin(_caller)
|
|
||||||
orgExists(_orgId)
|
orgExists(_orgId)
|
||||||
|
networkAdmin(_caller)
|
||||||
{
|
{
|
||||||
// check if orgAdmin already exists if yes then op cannot be performed
|
// check if orgAdmin already exists if yes then op cannot be performed
|
||||||
require(accounts.orgAdminExists(_orgId) != true, "org admin exists");
|
require(checkOrgAdminExists(_orgId) != true, "org admin exists");
|
||||||
// assign the account org admin role and propose voting
|
// assign the account org admin role and propose voting
|
||||||
accounts.assignAccountRole(_account, _orgId, orgAdminRole);
|
accounts.assignAccountRole(_account, _orgId, orgAdminRole);
|
||||||
//add voting item
|
//add voting item
|
||||||
|
@ -273,11 +249,10 @@ contract PermissionsImplementation {
|
||||||
|
|
||||||
function approveOrgAdminAccount(address _account, address _caller) external
|
function approveOrgAdminAccount(address _account, address _caller) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpDone()
|
|
||||||
networkAdmin(_caller)
|
networkAdmin(_caller)
|
||||||
{
|
{
|
||||||
require(isNetworkAdmin(_caller) == true, "can be called from network admin only");
|
require(isNetworkAdmin(_caller) == true, "can be called from network admin only");
|
||||||
if ((voter.processVote(adminOrg, _caller, 4))) {
|
if ((processVote(adminOrg, _caller, 4))) {
|
||||||
accounts.approveOrgAdminAccount(_account);
|
accounts.approveOrgAdminAccount(_account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,35 +260,34 @@ contract PermissionsImplementation {
|
||||||
|
|
||||||
function assignAccountRole(address _acct, string memory _orgId, string memory _roleId, address _caller) public
|
function assignAccountRole(address _acct, string memory _orgId, string memory _roleId, address _caller) public
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpDone()
|
|
||||||
orgApproved(_orgId)
|
|
||||||
orgAdmin(_caller, _orgId)
|
orgAdmin(_caller, _orgId)
|
||||||
|
orgApproved(_orgId)
|
||||||
{
|
{
|
||||||
// check if the account is part of another org. If yes then op cannot be done
|
// // check if the account is part of another org. If yes then op cannot be done
|
||||||
require(validateAccount(_acct, _orgId) == true, "Operation cannot be performed");
|
require(validateAccount(_acct, _orgId) == true, "Operation cannot be performed");
|
||||||
// check if role is existing for the org. if yes the op can be done
|
// // check if role is existing for the org. if yes the op can be done
|
||||||
require(roles.roleExists(_roleId, _orgId) == true, "role does not exists");
|
require(roleExists(_roleId, _orgId) == true, "role does not exists");
|
||||||
bool newRoleVoter = roles.isVoterRole(_roleId, _orgId);
|
bool newRoleVoter = isVoterRole(_roleId, _orgId);
|
||||||
// check the role of the account. if the current role is voter and new role is also voter
|
// // check the role of the account. if the current role is voter and new role is also voter
|
||||||
// voterlist change is not required. else voter list needs to be changed
|
// // voterlist change is not required. else voter list needs to be changed
|
||||||
string memory acctRole = accounts.getAccountRole(_acct);
|
string memory acctRole = accounts.getAccountRole(_acct);
|
||||||
if (keccak256(abi.encodePacked(acctRole)) == keccak256(abi.encodePacked("NONE"))) {
|
if (keccak256(abi.encodePacked(acctRole)) == keccak256(abi.encodePacked("NONE"))) {
|
||||||
//new account
|
//new account
|
||||||
if (newRoleVoter) {
|
if (newRoleVoter) {
|
||||||
// add to voter list
|
// add to voter list
|
||||||
voter.addVoter(_orgId, _acct);
|
updateVoterList(_orgId, _acct, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
bool currRoleVoter = roles.isVoterRole(acctRole, _orgId);
|
bool currRoleVoter = isVoterRole(acctRole, _orgId);
|
||||||
if (!(currRoleVoter && newRoleVoter)) {
|
if (!(currRoleVoter && newRoleVoter)) {
|
||||||
if (newRoleVoter) {
|
if (newRoleVoter) {
|
||||||
// add to voter list
|
// add to voter list
|
||||||
voter.addVoter(_orgId, _acct);
|
updateVoterList(_orgId, _acct, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// delete from voter list
|
// delete from voter list
|
||||||
voter.deleteVoter(_orgId, _acct);
|
updateVoterList(_orgId, _acct, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,7 +296,6 @@ contract PermissionsImplementation {
|
||||||
|
|
||||||
function addNode(string calldata _orgId, string calldata _enodeId, address _caller) external
|
function addNode(string calldata _orgId, string calldata _enodeId, address _caller) external
|
||||||
onlyProxy
|
onlyProxy
|
||||||
networkBootUpDone()
|
|
||||||
orgApproved(_orgId)
|
orgApproved(_orgId)
|
||||||
orgAdmin(_caller, _orgId)
|
orgAdmin(_caller, _orgId)
|
||||||
{
|
{
|
||||||
|
@ -355,10 +328,68 @@ contract PermissionsImplementation {
|
||||||
return (accounts.valAcctAccessChange(_account, _orgId));
|
return (accounts.valAcctAccessChange(_account, _orgId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkOrgExists(string memory _orgId) internal view
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
return org.checkOrgExists(_orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkOrgApproved(string memory _orgId) internal view
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
return org.checkOrgStatus(_orgId, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkOrgStatus(string memory _orgId, uint _status) internal view
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
return org.checkOrgStatus(_orgId, _status);
|
||||||
|
}
|
||||||
|
function checkOrgAdminExists(string memory _orgId) internal view
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
return (accounts.orgAdminExists(_orgId));
|
||||||
|
}
|
||||||
|
|
||||||
|
function roleExists(string memory _roleId, string memory _orgId) internal view
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
return (roles.roleExists(_roleId, _orgId));
|
||||||
|
}
|
||||||
|
function isVoterRole(string memory _roleId, string memory _orgId) internal view
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
return roles.isVoterRole(_roleId, _orgId);
|
||||||
|
}
|
||||||
|
|
||||||
|
function processVote(string memory _orgId, address _caller, uint _pendingOp) internal
|
||||||
|
returns (bool)
|
||||||
|
{
|
||||||
|
return voter.processVote(_orgId, _caller, _pendingOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateVoterList(string memory _orgId, address _account, bool _add) internal
|
||||||
|
{
|
||||||
|
if (_add) {
|
||||||
|
voter.addVoter(_orgId, _account);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
voter.deleteVoter(_orgId, _account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getAccountDetails(address _acct) external view
|
function getAccountDetails(address _acct) external view
|
||||||
returns (address, string memory, string memory, uint, bool)
|
returns (address, string memory, string memory, uint, bool)
|
||||||
{
|
{
|
||||||
return accounts.getAccountDetails(_acct);
|
return accounts.getAccountDetails(_acct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateNodeStatus(string calldata _orgId, string calldata _enodeId, uint _status, address _caller) external
|
||||||
|
onlyProxy
|
||||||
|
orgExists(_orgId)
|
||||||
|
orgAdmin(_caller, _orgId)
|
||||||
|
{
|
||||||
|
nodes.updateNodeStatus(_enodeId, _orgId, _status);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -75,15 +75,15 @@ contract PermissionsInterface {
|
||||||
permImplementation.approveOrg(_orgId, _enodeId, msg.sender);
|
permImplementation.approveOrg(_orgId, _enodeId, msg.sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
// function updateOrgStatus(string calldata _orgId, uint _status) external
|
function updateOrgStatus(string calldata _orgId, uint _status) external
|
||||||
// {
|
{
|
||||||
// permImplementation.updateOrgStatus(_orgId, _status);
|
permImplementation.updateOrgStatus(_orgId, _status);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// function approveOrgStatus(string calldata _orgId, uint _status) external
|
function approveOrgStatus(string calldata _orgId, uint _status) external
|
||||||
// {
|
{
|
||||||
// permImplementation.approveOrgStatus(_orgId, _status);
|
permImplementation.approveOrgStatus(_orgId, _status);
|
||||||
// }
|
}
|
||||||
// returns org and master org details based on org index
|
// returns org and master org details based on org index
|
||||||
function getOrgInfo(uint _orgIndex) external view returns (string memory, uint)
|
function getOrgInfo(uint _orgIndex) external view returns (string memory, uint)
|
||||||
{
|
{
|
||||||
|
@ -153,6 +153,11 @@ contract PermissionsInterface {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateNodeStatus(string calldata _orgId, string calldata _enodeId, uint _status) external
|
||||||
|
{
|
||||||
|
permImplementation.updateNodeStatus(_orgId, _enodeId, _status, msg.sender);
|
||||||
|
}
|
||||||
|
|
||||||
function getNodeStatus(string memory _enodeId) public view returns (uint)
|
function getNodeStatus(string memory _enodeId) public view returns (uint)
|
||||||
{
|
{
|
||||||
return permImplementation.getNodeStatus(_enodeId);
|
return permImplementation.getNodeStatus(_enodeId);
|
||||||
|
|
Loading…
Reference in New Issue