minor fixes

This commit is contained in:
perissology 2018-02-15 17:33:04 -08:00
parent 82945171e8
commit 46e87cffa1
4 changed files with 19 additions and 12 deletions

View File

@ -18,6 +18,8 @@ pragma solidity ^0.4.11;
*/
import "./LiquidPledging.sol";
// hack so that solcpiler will generate a contracts.Kernel object
import "@aragon/os/contracts/kernel/Kernel.sol";
/// @dev `LiquidPledgingMock` allows for mocking up
/// a `LiquidPledging` contract with the added ability

View File

@ -22,9 +22,6 @@ pragma solidity ^0.4.18;
import "@aragon/os/contracts/apps/AragonApp.sol";
import "./LiquidPledgingStorage.sol";
/// NOTICE: This contract is not using EternalStorage. This is done to save gas. The pluginWhitelist
/// should be fairly small, and would be trivial and relatively cheap to re-add all valid plugins
/// when the LiquidPledging contract is upgraded
contract LiquidPledgingPlugins is AragonApp, LiquidPledgingStorage {
bytes32 constant public PLUGIN_MANAGER_ROLE = keccak256("PLUGIN_MANAGER_ROLE");
@ -39,11 +36,11 @@ contract LiquidPledgingPlugins is AragonApp, LiquidPledgingStorage {
}
}
function removeValidPlugin(bytes32 contractHash) external auth(PLUGIN_MANAGER_ROLE) {
function removeValidPlugin(bytes32 contractHash) external authP(PLUGIN_MANAGER_ROLE, arr(contractHash)) {
pluginWhitelist[contractHash] = false;
}
function useWhitelist(bool useWhitelist) external auth(PLUGIN_MANAGER_ROLE) {
function useWhitelist(bool useWhitelist) external authP(PLUGIN_MANAGER_ROLE, _arr(useWhitelist)) {
whitelistDisabled = !useWhitelist;
}
@ -65,13 +62,19 @@ contract LiquidPledgingPlugins is AragonApp, LiquidPledgingStorage {
// allocate output byte array - this could also be done without assembly
// by using o_code = new bytes(size)
o_code := mload(0x40)
// new "memory end" including padding
mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
// store length in memory
mstore(o_code, size)
mstore(o_code, size) // store length in memory
// actually retrieve the code, this needs assembly
extcodecopy(addr, add(o_code, 0x20), 0, size)
}
return keccak256(o_code);
}
function _arr(bool a) internal pure returns (uint[] r) {
r = new uint[](1);
uint _a;
assembly {
_a := a // forced casting
}
r[0] = _a;
}
}

View File

@ -22,6 +22,11 @@ contract LiquidPledgingStorage {
/// and can own pledges and act as delegates
struct PledgeAdmin {
PledgeAdminType adminType; // Giver, Delegate or Project
// TODO: this is interesting...
// it is possible to revoke permission for this addr to be able to
// manage this pledgeAdmin. So we are storing the addr, which may or may not
// have permission to manage this PledgeAdmin. Maybe we need a custom
// ACL which provides a reverse lookup of addys granted a permission
address addr; // Account or contract address for admin
uint64 commitTime; // In seconds, used for time Givers' & Delegates' have to veto
uint64 parentProject; // Only for projects

View File

@ -118,7 +118,6 @@ contract PledgeAdmins is AragonApp, LiquidPledgingPlugins {
{
PledgeAdmin storage giver = _findAdmin(idGiver);
require(giver.adminType == PledgeAdminType.Giver); // Must be a Giver
// require(giver.addr == msg.sender); // Current addr had to send this tx
giver.addr = newAddr;
giver.name = newName;
giver.url = newUrl;
@ -189,7 +188,6 @@ contract PledgeAdmins is AragonApp, LiquidPledgingPlugins {
{
PledgeAdmin storage delegate = _findAdmin(idDelegate);
require(delegate.adminType == PledgeAdminType.Delegate);
// require(delegate.addr == msg.sender);// Current addr had to send this tx
delegate.addr = newAddr;
delegate.name = newName;
delegate.url = newUrl;
@ -223,7 +221,6 @@ contract PledgeAdmins is AragonApp, LiquidPledgingPlugins {
if (parentProject != 0) {
PledgeAdmin storage a = _findAdmin(parentProject);
// require(a.adminType == PledgeAdminType.Project);
// getProjectLevel will check that parentProject has a `Project` adminType
require(_getProjectLevel(a) < MAX_SUBPROJECT_LEVEL);
}