Skip to content

Commit

Permalink
Roles have been added (#320)
Browse files Browse the repository at this point in the history
* Roles have been added

* methods added to mulisig wrapper

* fixes

* rolesScope functions moved to multiplexer

* setRole method was added to multiplexer

* checking privilage logic moved to RolesScope

* setRole and setUserRole were changed to setFullRole and setUserRoles

* setAdminUsers in Multisig constructors and fixes

* fixes

* Improve multisig rules

* Fix linter errors

* Update RolesPrivilagesStore wrapper

* Add logs

* Fixes

* Fix linter errors

* Fixes

Co-authored-by: Andrii Rozinko <a.rozinko@gmail.com>
  • Loading branch information
feedkeek and AndrewAR2 authored Jul 21, 2022
1 parent 2697ce5 commit dd1c711
Show file tree
Hide file tree
Showing 15 changed files with 405 additions and 142 deletions.
8 changes: 5 additions & 3 deletions contracts/Boilerplate/Catalogue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import "../Storage/RewardsEventEmitter.sol";
import "../Storage/PoolsStore.sol";
import "../Storage/PoolEventsEmitter.sol";
import "../Storage/NodeAddressesStore.sol";

import "../Storage/RolesPrivilagesStore.sol";

contract Catalogue {
KycWhitelist public kycWhitelist;
Expand Down Expand Up @@ -82,7 +82,6 @@ contract Catalogue {
}
}


contract StorageCatalogue {
ApolloDepositStore public apolloDepositStore;
AtlasStakeStore public atlasStakeStore;
Expand All @@ -99,6 +98,7 @@ contract StorageCatalogue {
PoolsStore public poolsStore;
PoolEventsEmitter public poolEventsEmitter;
NodeAddressesStore public nodeAddressesStore;
RolesPrivilagesStore public rolesPrivilagesStore;

constructor(
ApolloDepositStore _apolloDepositStore,
Expand All @@ -115,7 +115,8 @@ contract StorageCatalogue {
RewardsEventEmitter _rewardsEventEmitter,
PoolsStore _poolsStore,
PoolEventsEmitter _poolEventsEmitter,
NodeAddressesStore _nodeAddressesStore
NodeAddressesStore _nodeAddressesStore,
RolesPrivilagesStore _rolesPrivilagesStore
) public {
apolloDepositStore = _apolloDepositStore;
atlasStakeStore = _atlasStakeStore;
Expand All @@ -132,5 +133,6 @@ contract StorageCatalogue {
poolsStore = _poolsStore;
poolEventsEmitter = _poolEventsEmitter;
nodeAddressesStore = _nodeAddressesStore;
rolesPrivilagesStore = _rolesPrivilagesStore;
}
}
48 changes: 39 additions & 9 deletions contracts/Boilerplate/Multiplexer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "../Front/Roles.sol";
import "../Configuration/Fees.sol";
import "../Middleware/ValidatorProxy.sol";
import "../Pool/PoolsNodesManager.sol";

import "../Storage/RolesPrivilagesStore.sol";

contract Multiplexer is ConstructorOwnable {
Head public head;
Expand All @@ -25,6 +25,7 @@ contract Multiplexer is ConstructorOwnable {
ValidatorProxy public validatorProxy;
Roles public roles;
PoolsNodesManager public poolsNodesManager;
RolesPrivilagesStore public rolesPrivilagesStore;

constructor(
address _owner,
Expand All @@ -33,16 +34,16 @@ contract Multiplexer is ConstructorOwnable {
Fees _fees,
ValidatorProxy _validatorProxy,
Roles _roles,
PoolsNodesManager _poolsNodesManager
)
public ConstructorOwnable(_owner)
{
PoolsNodesManager _poolsNodesManager,
RolesPrivilagesStore _rolesPrivilagesStore
) public ConstructorOwnable(_owner) {
head = _head;
kycWhitelist = _kycWhitelist;
fees = _fees;
validatorProxy = _validatorProxy;
roles = _roles;
poolsNodesManager = _poolsNodesManager;
rolesPrivilagesStore = _rolesPrivilagesStore;
}

function transferContractsOwnership(address newOwner) public onlyOwner {
Expand All @@ -57,23 +58,36 @@ contract Multiplexer is ConstructorOwnable {
head.setContext(context);
}

function addToWhitelist(address candidate, Consts.NodeType role, uint deposit) public onlyOwner {
function addToWhitelist(
address candidate,
Consts.NodeType role,
uint256 deposit
)
public
onlyOwner
{
kycWhitelist.add(candidate, role, deposit);
}

function removeFromWhitelist(address candidate) public onlyOwner {
kycWhitelist.remove(candidate);
}

function setBaseUploadFee(uint fee) public onlyOwner {
function setBaseUploadFee(uint256 fee) public onlyOwner {
fees.setBaseUploadFee(fee);
}

function transferOwnershipForValidatorSet(address newOwner) public onlyOwner {
function transferOwnershipForValidatorSet(address newOwner)
public
onlyOwner
{
validatorProxy.transferOwnershipForValidatorSet(newOwner);
}

function transferOwnershipForBlockRewards(address newOwner) public onlyOwner {
function transferOwnershipForBlockRewards(address newOwner)
public
onlyOwner
{
validatorProxy.transferOwnershipForBlockRewards(newOwner);
}

Expand Down Expand Up @@ -114,4 +128,20 @@ contract Multiplexer is ConstructorOwnable {
function removePool(address _pool) public onlyOwner {
poolsNodesManager.removePool(_pool);
}

// add array of roles to user
function setUserRoles(address user, bytes32[] roleHexes) public onlyOwner {
rolesPrivilagesStore.setRoles(user, roleHexes);
}

function setRole(
string roleName,
bytes4[] trueSelectors,
bytes4[] falseSelectors
)
public
onlyOwner
{
rolesPrivilagesStore.setRole(roleName, trueSelectors, falseSelectors);
}
}
Loading

0 comments on commit dd1c711

Please sign in to comment.