Skip to content

Commit

Permalink
Merge pull request #29 from Morpher-io/feature/userblockingAdminpanel
Browse files Browse the repository at this point in the history
Feature/userblocking adminpanel
  • Loading branch information
Survion authored Mar 3, 2022
2 parents 287cf4e + c5ba0ad commit d88251f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
19 changes: 17 additions & 2 deletions contracts/MorpherUserBlocking.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,33 @@ contract MorpherUserBlocking {
mapping(address => bool) public userIsBlocked;
MorpherState state;

address public allowedToAddBlockedUsersAddress;

event ChangeUserBlocked(address _user, bool _oldIsBlocked, bool _newIsBlocked);
event ChangedAddressAllowedToAddBlockedUsersAddress(address _oldAddress, address _newAddress);

constructor(address _state) public {
constructor(address _state, address _allowedToAddBlockedUsersAddress) public {
state = MorpherState(_state);
emit ChangedAddressAllowedToAddBlockedUsersAddress(address(0), _allowedToAddBlockedUsersAddress);
allowedToAddBlockedUsersAddress = _allowedToAddBlockedUsersAddress;
}

modifier onlyAdministrator() {
require(msg.sender == state.getAdministrator(), "UserBlocking: Only Administrator can call this function");
_;
}

function setUserBlocked(address _user, bool _isBlocked) public onlyAdministrator {
modifier onlyAllowedUsers() {
require(msg.sender == state.getAdministrator() || msg.sender == allowedToAddBlockedUsersAddress, "UserBlocking: Only White-Listed Users can call this function");
_;
}

function setAllowedToAddBlockedUsersAddress(address _newAddress) public onlyAdministrator {
emit ChangedAddressAllowedToAddBlockedUsersAddress(allowedToAddBlockedUsersAddress, _newAddress);
allowedToAddBlockedUsersAddress = _newAddress;
}

function setUserBlocked(address _user, bool _isBlocked) public onlyAllowedUsers {
emit ChangeUserBlocked(_user, userIsBlocked[_user], _isBlocked);
userIsBlocked[_user] = _isBlocked;
}
Expand Down
4 changes: 3 additions & 1 deletion migrations/3_deploy_userblocking.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ const MorpherUserBlocking = artifacts.require('MorpherUserBlocking')
const MorpherState = artifacts.require('MorpherState')

module.exports = async function (deployer, network, accounts) {
let accountUserBlocking = process.env.ACCOUNT_USER_BLOCKING || accounts[0];
const morpherState = await MorpherState.deployed()
await deployer.deploy(
MorpherUserBlocking,
morpherState.address
morpherState.address,
accountUserBlocking
)
}
7 changes: 3 additions & 4 deletions truffle-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require("dotenv").config();
let HDWalletProvider = require("@truffle/hdwallet-provider");
const Web3 = require('web3');

module.exports = {
networks: {
Expand Down Expand Up @@ -32,7 +31,7 @@ module.exports = {
provider: () =>
new HDWalletProvider(
process.env.MORPHER_DEPLOYER_KEY,
new Web3.providers.WebsocketProvider("wss://ropsten.infura.io/ws/v3/" + process.env.INFURA_PROJECT_ID)
"wss://ropsten.infura.io/ws/v3/" + process.env.INFURA_PROJECT_ID
),
network_id: '3',
gasPrice: 15000000000,
Expand All @@ -41,7 +40,7 @@ module.exports = {
provider: () =>
new HDWalletProvider(
process.env.MORPHER_DEPLOYER_PK,
new Web3.providers.WebsocketProvider("wss://mainnet.infura.io/ws/v3/" + process.env.INFURA_PROJECT_ID)
"wss://mainnet.infura.io/ws/v3/" + process.env.INFURA_PROJECT_ID
),
network_id: '1',
gasPrice: 150000000000,
Expand All @@ -50,7 +49,7 @@ module.exports = {
provider: () =>
new HDWalletProvider(
process.env.MORPHER_DEPLOYER_PK,
new Web3.providers.WebsocketProvider("wss://kovan.infura.io/ws/v3/" + process.env.INFURA_PROJECT_ID)
"wss://kovan.infura.io/ws/v3/" + process.env.INFURA_PROJECT_ID
),
network_id: '*',
gasPrice: 10000000000,
Expand Down

0 comments on commit d88251f

Please sign in to comment.