UNPKG

lpp-dac

Version:

LiquidPledging plugin contract for dacs to issue a custom MiniMe Token for donations.

156 lines 168 kB
{ "language": "Solidity", "sources": { "./contracts/LPPDacFactory.sol": { "keccak256": "0x3e02c8312ee642362c46305fa733939c840a567093821e1bf4c9add2dcd37c93", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/contracts/LPPDacFactory.sol" ], "content": "pragma solidity ^0.4.18;\n\nimport \"./LPPDac.sol\";\nimport \"minimetoken/contracts/MiniMeToken.sol\";\nimport \"@aragon/os/contracts/factory/AppProxyFactory.sol\";\nimport \"@aragon/os/contracts/kernel/Kernel.sol\";\nimport \"@aragon/os/contracts/acl/ACL.sol\";\nimport \"giveth-liquidpledging/contracts/LiquidPledging.sol\";\nimport \"giveth-liquidpledging/contracts/LPConstants.sol\";\n\n\ncontract LPPDacFactory is LPConstants, VaultRecoverable, AppProxyFactory {\n Kernel public kernel;\n MiniMeTokenFactory public tokenFactory;\n\n bytes32 constant public DAC_APP_ID = keccak256(\"lpp-dac\");\n bytes32 constant public DAC_APP = keccak256(APP_BASES_NAMESPACE, DAC_APP_ID);\n bytes32 constant public LP_APP_INSTANCE = keccak256(APP_ADDR_NAMESPACE, LP_APP_ID);\n\n event DeployDac(address dac);\n\n function LPPDacFactory(address _kernel, address _tokenFactory) public \n {\n // note: this contract will need CREATE_PERMISSIONS_ROLE on the ACL\n // and the PLUGIN_MANAGER_ROLE on liquidPledging,\n // the DAC_APP and LP_APP_INSTANCE need to be registered with the kernel\n\n require(_kernel != 0x0);\n require(_tokenFactory != 0x0);\n kernel = Kernel(_kernel);\n tokenFactory = MiniMeTokenFactory(_tokenFactory);\n }\n\n function newDac(\n string name,\n string url,\n uint64 commitTime,\n string tokenName,\n string tokenSymbol\n ) public\n { \n // TODO: could make MiniMeToken an AragonApp to save gas by deploying a proxy\n MiniMeToken token = new MiniMeToken(tokenFactory, 0x0, 0, tokenName, 18, tokenSymbol, false);\n newDac(name, url, commitTime, token);\n }\n\n /**\n * @param token The token this dac will mint. This contract must be the TokenController\n */\n function newDac(\n string name,\n string url,\n uint64 commitTime,\n MiniMeToken token\n ) public\n {\n address dacBase = kernel.getApp(DAC_APP);\n require(dacBase != 0);\n address liquidPledging = kernel.getApp(LP_APP_INSTANCE);\n require(liquidPledging != 0);\n\n LPPDac dac = LPPDac(newAppProxy(kernel, DAC_APP_ID));\n\n LiquidPledging(liquidPledging).addValidPluginInstance(address(dac));\n\n dac.initialize(liquidPledging, token, name, url, commitTime);\n token.changeController(address(dac));\n\n ACL acl = ACL(kernel.acl());\n bytes32 adminRole = dac.ADMIN_ROLE();\n\n // this permission is managed by msg.sender\n acl.createPermission(msg.sender, address(dac), adminRole, msg.sender);\n\n DeployDac(address(dac));\n }\n\n function getRecoveryVault() public view returns (address) {\n return kernel.getRecoveryVault();\n }\n}\n" }, "@aragon/os/contracts/acl/IACL.sol": { "keccak256": "0xa120fc32d8d2c5096d605b0fe012d5b1e4a62118952a25a18bac5210f4fceede", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/acl/IACL.sol" ], "content": "pragma solidity ^0.4.18;\n\n\ninterface IACL {\n function initialize(address permissionsCreator) public;\n function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);\n}\n" }, "@aragon/os/contracts/common/IVaultRecoverable.sol": { "keccak256": "0xf6ed3f4043aee4526c9563c83f74d701141dd81a988f1be463ba6a18e09ba2c3", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/common/IVaultRecoverable.sol" ], "content": "pragma solidity ^0.4.18;\n\n\ninterface IVaultRecoverable {\n function transferToVault(address token) external;\n\n function allowRecoverability(address token) public view returns (bool);\n function getRecoveryVault() public view returns (address);\n}\n" }, "@aragon/os/contracts/kernel/IKernel.sol": { "keccak256": "0x1f0c5def4ecec01abcbb07eea3312e0a4683d81a81c2475d66f06c5c3b8585cd", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/kernel/IKernel.sol" ], "content": "pragma solidity ^0.4.18;\n\nimport \"../acl/IACL.sol\";\nimport \"../common/IVaultRecoverable.sol\";\n\n\n// This should be an interface, but interfaces can't inherit yet :(\ncontract IKernel is IVaultRecoverable {\n event SetApp(bytes32 indexed namespace, bytes32 indexed name, bytes32 indexed id, address app);\n\n function acl() public view returns (IACL);\n function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool);\n\n function setApp(bytes32 namespace, bytes32 name, address app) public returns (bytes32 id);\n function getApp(bytes32 id) public view returns (address);\n}\n" }, "@aragon/os/contracts/apps/AppStorage.sol": { "keccak256": "0x8b9205a3fdf9d94fb1461d2c2d32335803122aa75d3fa8cf0b982796fd040c25", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/apps/AppStorage.sol" ], "content": "pragma solidity ^0.4.18;\n\nimport \"../kernel/IKernel.sol\";\n\n\ncontract AppStorage {\n IKernel public kernel;\n bytes32 public appId;\n address internal pinnedCode; // used by Proxy Pinned\n uint256 internal initializationBlock; // used by Initializable\n uint256[95] private storageOffset; // forces App storage to start at after 100 slots\n uint256 private offset;\n}\n" }, "@aragon/os/contracts/common/Initializable.sol": { "keccak256": "0x1265fd5de8acf30e4b444f52cfdf91dcebb222fe05bdfc081f2fc0ea953ab5e4", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/common/Initializable.sol" ], "content": "pragma solidity ^0.4.18;\n\nimport \"../apps/AppStorage.sol\";\n\n\ncontract Initializable is AppStorage {\n modifier onlyInit {\n require(initializationBlock == 0);\n _;\n }\n\n modifier isInitialized {\n require(initializationBlock > 0);\n _;\n }\n\n /**\n * @return Block number in which the contract was initialized\n */\n function getInitializationBlock() public view returns (uint256) {\n return initializationBlock;\n }\n\n /**\n * @dev Function to be called by top level contract after initialization has finished.\n */\n function initialized() internal onlyInit {\n initializationBlock = getBlockNumber();\n }\n\n /**\n * @dev Returns the current block number.\n * Using a function rather than `block.number` allows us to easily mock the block number in\n * tests.\n */\n function getBlockNumber() internal view returns (uint256) {\n return block.number;\n }\n}\n" }, "@aragon/os/contracts/common/EtherTokenConstant.sol": { "keccak256": "0x160b651ec349ce381646d8ba24b873a61ab4bf0d60315b9644a175283a574b94", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/common/EtherTokenConstant.sol" ], "content": "pragma solidity ^0.4.18;\n\n\n// aragonOS and aragon-apps rely on address(0) to denote native ETH, in\n// contracts where both tokens and ETH are accepted\ncontract EtherTokenConstant {\n address constant public ETH = address(0);\n}\n" }, "@aragon/os/contracts/common/IsContract.sol": { "keccak256": "0xee6df8a68ea442a2c0414ee70d95eb3e197425ce372a28bfda01888b0d9446f1", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/common/IsContract.sol" ], "content": "pragma solidity ^0.4.18;\n\n\ncontract IsContract {\n function isContract(address _target) internal view returns (bool) {\n if (_target == address(0)) {\n return false;\n }\n\n uint256 size;\n assembly { size := extcodesize(_target) }\n return size > 0;\n }\n}\n" }, "@aragon/os/contracts/lib/zeppelin/token/ERC20Basic.sol": { "keccak256": "0x3ad7429b6f0a6330e8e89646aef39de99fa1fd8221e6a9dd55e3a9104908d585", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/lib/zeppelin/token/ERC20Basic.sol" ], "content": "pragma solidity ^0.4.11;\n\n\n/**\n * @title ERC20Basic\n * @dev Simpler version of ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/179\n */\ncontract ERC20Basic {\n function totalSupply() public view returns (uint256);\n function balanceOf(address who) public constant returns (uint256);\n function transfer(address to, uint256 value) public returns (bool);\n event Transfer(address indexed from, address indexed to, uint256 value);\n}\n" }, "@aragon/os/contracts/lib/zeppelin/token/ERC20.sol": { "keccak256": "0x48674c3983e4e9ba8f771d28e349833164934960a952966c17ae05f05fa84379", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/lib/zeppelin/token/ERC20.sol" ], "content": "pragma solidity ^0.4.11;\n\n\nimport './ERC20Basic.sol';\n\n\n/**\n * @title ERC20 interface\n * @dev see https://github.com/ethereum/EIPs/issues/20\n */\ncontract ERC20 is ERC20Basic {\n function allowance(address owner, address spender) public constant returns (uint256);\n function transferFrom(address from, address to, uint256 value) public returns (bool);\n function approve(address spender, uint256 value) public returns (bool);\n event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n" }, "@aragon/os/contracts/common/VaultRecoverable.sol": { "keccak256": "0x1b71cbea32aee6e65912e3447eb8001bdad127d421e0c4464bb8294f945d9cf1", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/common/VaultRecoverable.sol" ], "content": "pragma solidity ^0.4.18;\n\nimport \"./EtherTokenConstant.sol\";\nimport \"./IsContract.sol\";\nimport \"./IVaultRecoverable.sol\";\nimport \"../lib/zeppelin/token/ERC20.sol\";\n\n\ncontract VaultRecoverable is IVaultRecoverable, EtherTokenConstant, IsContract {\n /**\n * @notice Send funds to recovery Vault. This contract should never receive funds,\n * but in case it does, this function allows one to recover them.\n * @param _token Token balance to be sent to recovery vault.\n */\n function transferToVault(address _token) external {\n require(allowRecoverability(_token));\n address vault = getRecoveryVault();\n require(isContract(vault));\n\n if (_token == ETH) {\n vault.transfer(this.balance);\n } else {\n uint256 amount = ERC20(_token).balanceOf(this);\n ERC20(_token).transfer(vault, amount);\n }\n }\n\n /**\n * @dev By default deriving from AragonApp makes it recoverable\n * @param token Token address that would be recovered\n * @return bool whether the app allows the recovery\n */\n function allowRecoverability(address token) public view returns (bool) {\n return true;\n }\n}\n" }, "@aragon/os/contracts/evmscript/ScriptHelpers.sol": { "keccak256": "0x5bf6b2ceab21c1f8b31b6e797ae12974a655e46e142aeb12b3560ed912a4dd01", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/evmscript/ScriptHelpers.sol" ], "content": "pragma solidity ^0.4.18;\n\n\nlibrary ScriptHelpers {\n // To test with JS and compare with actual encoder. Maintaining for reference.\n // t = function() { return IEVMScriptExecutor.at('0x4bcdd59d6c77774ee7317fc1095f69ec84421e49').contract.execScript.getData(...[].slice.call(arguments)).slice(10).match(/.{1,64}/g) }\n // run = function() { return ScriptHelpers.new().then(sh => { sh.abiEncode.call(...[].slice.call(arguments)).then(a => console.log(a.slice(2).match(/.{1,64}/g)) ) }) }\n // This is truly not beautiful but lets no daydream to the day solidity gets reflection features\n\n function abiEncode(bytes _a, bytes _b, address[] _c) public pure returns (bytes d) {\n return encode(_a, _b, _c);\n }\n\n function encode(bytes memory _a, bytes memory _b, address[] memory _c) internal pure returns (bytes memory d) {\n // A is positioned after the 3 position words\n uint256 aPosition = 0x60;\n uint256 bPosition = aPosition + 32 * abiLength(_a);\n uint256 cPosition = bPosition + 32 * abiLength(_b);\n uint256 length = cPosition + 32 * abiLength(_c);\n\n d = new bytes(length);\n assembly {\n // Store positions\n mstore(add(d, 0x20), aPosition)\n mstore(add(d, 0x40), bPosition)\n mstore(add(d, 0x60), cPosition)\n }\n\n // Copy memory to correct position\n copy(d, getPtr(_a), aPosition, _a.length);\n copy(d, getPtr(_b), bPosition, _b.length);\n copy(d, getPtr(_c), cPosition, _c.length * 32); // 1 word per address\n }\n\n function abiLength(bytes memory _a) internal pure returns (uint256) {\n // 1 for length +\n // memory words + 1 if not divisible for 32 to offset word\n return 1 + (_a.length / 32) + (_a.length % 32 > 0 ? 1 : 0);\n }\n\n function abiLength(address[] _a) internal pure returns (uint256) {\n // 1 for length + 1 per item\n return 1 + _a.length;\n }\n\n function copy(bytes _d, uint256 _src, uint256 _pos, uint256 _length) internal pure {\n uint dest;\n assembly {\n dest := add(add(_d, 0x20), _pos)\n }\n memcpy(dest, _src, _length + 32);\n }\n\n function getPtr(bytes memory _x) internal pure returns (uint256 ptr) {\n assembly {\n ptr := _x\n }\n }\n\n function getPtr(address[] memory _x) internal pure returns (uint256 ptr) {\n assembly {\n ptr := _x\n }\n }\n\n function getSpecId(bytes _script) internal pure returns (uint32) {\n return uint32At(_script, 0);\n }\n\n function uint256At(bytes _data, uint256 _location) internal pure returns (uint256 result) {\n assembly {\n result := mload(add(_data, add(0x20, _location)))\n }\n }\n\n function addressAt(bytes _data, uint256 _location) internal pure returns (address result) {\n uint256 word = uint256At(_data, _location);\n\n assembly {\n result := div(and(word, 0xffffffffffffffffffffffffffffffffffffffff000000000000000000000000),\n 0x1000000000000000000000000)\n }\n }\n\n function uint32At(bytes _data, uint256 _location) internal pure returns (uint32 result) {\n uint256 word = uint256At(_data, _location);\n\n assembly {\n result := div(and(word, 0xffffffff00000000000000000000000000000000000000000000000000000000),\n 0x100000000000000000000000000000000000000000000000000000000)\n }\n }\n\n function locationOf(bytes _data, uint256 _location) internal pure returns (uint256 result) {\n assembly {\n result := add(_data, add(0x20, _location))\n }\n }\n\n function toBytes(bytes4 _sig) internal pure returns (bytes) {\n bytes memory payload = new bytes(4);\n assembly { mstore(add(payload, 0x20), _sig) }\n return payload;\n }\n\n function memcpy(uint _dest, uint _src, uint _len) internal pure {\n uint256 src = _src;\n uint256 dest = _dest;\n uint256 len = _len;\n\n // Copy word-length chunks while possible\n for (; len >= 32; len -= 32) {\n assembly {\n mstore(dest, mload(src))\n }\n dest += 32;\n src += 32;\n }\n\n // Copy remaining bytes\n uint mask = 256 ** (32 - len) - 1;\n assembly {\n let srcpart := and(mload(src), not(mask))\n let destpart := and(mload(dest), mask)\n mstore(dest, or(destpart, srcpart))\n }\n }\n}\n" }, "@aragon/os/contracts/evmscript/IEVMScriptExecutor.sol": { "keccak256": "0x6a4beed810085f11cda9d50c3547ac4cc2100d9dc18ab4982ff11dd483410012", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/evmscript/IEVMScriptExecutor.sol" ], "content": "pragma solidity ^0.4.18;\n\n\ninterface IEVMScriptExecutor {\n function execScript(bytes script, bytes input, address[] blacklist) external returns (bytes);\n}\n" }, "@aragon/os/contracts/evmscript/IEVMScriptRegistry.sol": { "keccak256": "0x460ff768028031e444267cad9d848b6e98182c3721d16013afd5949444701e84", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/evmscript/IEVMScriptRegistry.sol" ], "content": "pragma solidity ^0.4.18;\n\n\ncontract EVMScriptRegistryConstants {\n /* Hardcoded constants to save gas\n // repeated definitions from KernelStorage, to avoid out of gas issues\n bytes32 constant public APP_ADDR_NAMESPACE = keccak256(\"app\");\n\n bytes32 constant public EVMSCRIPT_REGISTRY_APP_ID = apmNamehash(\"evmreg\");\n bytes32 constant public EVMSCRIPT_REGISTRY_APP = keccak256(APP_ADDR_NAMESPACE, EVMSCRIPT_REGISTRY_APP_ID);\n */\n bytes32 constant public APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;\n bytes32 constant public EVMSCRIPT_REGISTRY_APP_ID = 0xddbcfd564f642ab5627cf68b9b7d374fb4f8a36e941a75d89c87998cef03bd61;\n bytes32 constant public EVMSCRIPT_REGISTRY_APP = 0x34f01c17e9be6ddbf2c61f37b5b1fb9f1a090a975006581ad19bda1c4d382871;\n}\n\n\ninterface IEVMScriptRegistry {\n function addScriptExecutor(address executor) external returns (uint id);\n function disableScriptExecutor(uint256 executorId) external;\n\n function getScriptExecutor(bytes script) public view returns (address);\n}\n" }, "@aragon/os/contracts/evmscript/EVMScriptRunner.sol": { "keccak256": "0x85d0a5051c5e867b0b15b756789911871ae746f36462cb774557682f90e7fa78", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/evmscript/EVMScriptRunner.sol" ], "content": "pragma solidity ^0.4.18;\n\nimport \"./ScriptHelpers.sol\";\nimport \"./IEVMScriptExecutor.sol\";\nimport \"./IEVMScriptRegistry.sol\";\n\nimport \"../apps/AppStorage.sol\";\n\n\ncontract EVMScriptRunner is AppStorage, EVMScriptRegistryConstants {\n using ScriptHelpers for bytes;\n\n function runScript(bytes _script, bytes _input, address[] _blacklist) protectState internal returns (bytes output) {\n // TODO: Too much data flying around, maybe extracting spec id here is cheaper\n address executorAddr = getExecutor(_script);\n require(executorAddr != address(0));\n\n bytes memory calldataArgs = _script.encode(_input, _blacklist);\n bytes4 sig = IEVMScriptExecutor(0).execScript.selector;\n\n require(executorAddr.delegatecall(sig, calldataArgs));\n\n bytes memory ret = returnedDataDecoded();\n\n require(ret.length > 0);\n\n return ret;\n }\n\n function getExecutor(bytes _script) public view returns (IEVMScriptExecutor) {\n return IEVMScriptExecutor(getExecutorRegistry().getScriptExecutor(_script));\n }\n\n // TODO: Internal\n function getExecutorRegistry() internal view returns (IEVMScriptRegistry) {\n address registryAddr = kernel.getApp(EVMSCRIPT_REGISTRY_APP);\n return IEVMScriptRegistry(registryAddr);\n }\n\n /**\n * @dev copies and returns last's call data. Needs to ABI decode first\n */\n function returnedDataDecoded() internal pure returns (bytes ret) {\n assembly {\n let size := returndatasize\n switch size\n case 0 {}\n default {\n ret := mload(0x40) // free mem ptr get\n mstore(0x40, add(ret, add(size, 0x20))) // free mem ptr set\n returndatacopy(ret, 0x20, sub(size, 0x20)) // copy return data\n }\n }\n return ret;\n }\n\n modifier protectState {\n address preKernel = kernel;\n bytes32 preAppId = appId;\n _; // exec\n require(kernel == preKernel);\n require(appId == preAppId);\n }\n}\n" }, "@aragon/os/contracts/acl/ACLSyntaxSugar.sol": { "keccak256": "0xb60f567383dd66e25eaf0925320fdff8d5c57d4f1f74a7a53a9573b61876340e", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/acl/ACLSyntaxSugar.sol" ], "content": "pragma solidity ^0.4.18;\n\n\ncontract ACLSyntaxSugar {\n function arr() internal pure returns (uint256[] r) {}\n\n function arr(bytes32 _a) internal pure returns (uint256[] r) {\n return arr(uint256(_a));\n }\n\n function arr(bytes32 _a, bytes32 _b) internal pure returns (uint256[] r) {\n return arr(uint256(_a), uint256(_b));\n }\n\n function arr(address _a) internal pure returns (uint256[] r) {\n return arr(uint256(_a));\n }\n\n function arr(address _a, address _b) internal pure returns (uint256[] r) {\n return arr(uint256(_a), uint256(_b));\n }\n\n function arr(address _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {\n return arr(uint256(_a), _b, _c);\n }\n\n function arr(address _a, uint256 _b) internal pure returns (uint256[] r) {\n return arr(uint256(_a), uint256(_b));\n }\n\n function arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {\n return arr(uint256(_a), uint256(_b), _c, _d, _e);\n }\n\n function arr(address _a, address _b, address _c) internal pure returns (uint256[] r) {\n return arr(uint256(_a), uint256(_b), uint256(_c));\n }\n\n function arr(address _a, address _b, uint256 _c) internal pure returns (uint256[] r) {\n return arr(uint256(_a), uint256(_b), uint256(_c));\n }\n\n function arr(uint256 _a) internal pure returns (uint256[] r) {\n r = new uint256[](1);\n r[0] = _a;\n }\n\n function arr(uint256 _a, uint256 _b) internal pure returns (uint256[] r) {\n r = new uint256[](2);\n r[0] = _a;\n r[1] = _b;\n }\n\n function arr(uint256 _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) {\n r = new uint256[](3);\n r[0] = _a;\n r[1] = _b;\n r[2] = _c;\n }\n\n function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) {\n r = new uint256[](4);\n r[0] = _a;\n r[1] = _b;\n r[2] = _c;\n r[3] = _d;\n }\n\n function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) {\n r = new uint256[](5);\n r[0] = _a;\n r[1] = _b;\n r[2] = _c;\n r[3] = _d;\n r[4] = _e;\n }\n}\n\n\ncontract ACLHelpers {\n function decodeParamOp(uint256 _x) internal pure returns (uint8 b) {\n return uint8(_x >> (8 * 30));\n }\n\n function decodeParamId(uint256 _x) internal pure returns (uint8 b) {\n return uint8(_x >> (8 * 31));\n }\n\n function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) {\n a = uint32(_x);\n b = uint32(_x >> (8 * 4));\n c = uint32(_x >> (8 * 8));\n }\n}\n" }, "@aragon/os/contracts/apps/AragonApp.sol": { "keccak256": "0x04bd38b82d31aff08b67def2e1637482fdb91f1f44f4ec497f4e7416c5f83dfb", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/@aragon/os/contracts/apps/AragonApp.sol" ], "content": "pragma solidity ^0.4.18;\n\nimport \"./AppStorage.sol\";\nimport \"../common/Initializable.sol\";\nimport \"../common/VaultRecoverable.sol\";\nimport \"../evmscript/EVMScriptRunner.sol\";\nimport \"../acl/ACLSyntaxSugar.sol\";\n\n\n// ACLSyntaxSugar and EVMScriptRunner are not directly used by this contract, but are included so\n// that they are automatically usable by subclassing contracts\ncontract AragonApp is AppStorage, Initializable, ACLSyntaxSugar, VaultRecoverable, EVMScriptRunner {\n modifier auth(bytes32 _role) {\n require(canPerform(msg.sender, _role, new uint256[](0)));\n _;\n }\n\n modifier authP(bytes32 _role, uint256[] params) {\n require(canPerform(msg.sender, _role, params));\n _;\n }\n\n function canPerform(address _sender, bytes32 _role, uint256[] params) public view returns (bool) {\n bytes memory how; // no need to init memory as it is never used\n if (params.length > 0) {\n uint256 byteLength = params.length * 32;\n assembly {\n how := params // forced casting\n mstore(how, byteLength)\n }\n }\n return address(kernel) == 0 || kernel.hasPermission(_sender, address(this), _role, how);\n }\n\n function getRecoveryVault() public view returns (address) {\n // Funds recovery via a vault is only available when used with a kernel\n require(address(kernel) != 0);\n return kernel.getRecoveryVault();\n }\n}\n" }, "giveth-liquidpledging/contracts/ILiquidPledgingPlugin.sol": { "keccak256": "0x9e877682faa1ff0859484b96b996658d2716cb38d836d6a03857465f0927b340", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/giveth-liquidpledging/contracts/ILiquidPledgingPlugin.sol" ], "content": "pragma solidity ^0.4.0;\n\n/*\n Copyright 2017, Jordi Baylina\n Contributors: Adrià Massanet <adria@codecontext.io>, RJ Ewing, Griff\n Green, Arthur Lunn\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n*/\n\n\n/// @dev `ILiquidPledgingPlugin` is the basic interface for any\n/// liquid pledging plugin\ncontract ILiquidPledgingPlugin {\n\n /// @notice Plugins are used (much like web hooks) to initiate an action\n /// upon any donation, delegation, or transfer; this is an optional feature\n /// and allows for extreme customization of the contract. This function\n /// implements any action that should be initiated before a transfer.\n /// @param pledgeManager The admin or current manager of the pledge\n /// @param pledgeFrom This is the Id from which value will be transfered.\n /// @param pledgeTo This is the Id that value will be transfered to. \n /// @param context The situation that is triggering the plugin:\n /// 0 -> Plugin for the owner transferring pledge to another party\n /// 1 -> Plugin for the first delegate transferring pledge to another party\n /// 2 -> Plugin for the second delegate transferring pledge to another party\n /// ...\n /// 255 -> Plugin for the intendedProject transferring pledge to another party\n ///\n /// 256 -> Plugin for the owner receiving pledge to another party\n /// 257 -> Plugin for the first delegate receiving pledge to another party\n /// 258 -> Plugin for the second delegate receiving pledge to another party\n /// ...\n /// 511 -> Plugin for the intendedProject receiving pledge to another party\n /// @param amount The amount of value that will be transfered.\n function beforeTransfer(\n uint64 pledgeManager,\n uint64 pledgeFrom,\n uint64 pledgeTo,\n uint64 context,\n address token,\n uint amount ) public returns (uint maxAllowed);\n\n /// @notice Plugins are used (much like web hooks) to initiate an action\n /// upon any donation, delegation, or transfer; this is an optional feature\n /// and allows for extreme customization of the contract. This function\n /// implements any action that should be initiated after a transfer.\n /// @param pledgeManager The admin or current manager of the pledge\n /// @param pledgeFrom This is the Id from which value will be transfered.\n /// @param pledgeTo This is the Id that value will be transfered to. \n /// @param context The situation that is triggering the plugin:\n /// 0 -> Plugin for the owner transferring pledge to another party\n /// 1 -> Plugin for the first delegate transferring pledge to another party\n /// 2 -> Plugin for the second delegate transferring pledge to another party\n /// ...\n /// 255 -> Plugin for the intendedProject transferring pledge to another party\n ///\n /// 256 -> Plugin for the owner receiving pledge to another party\n /// 257 -> Plugin for the first delegate receiving pledge to another party\n /// 258 -> Plugin for the second delegate receiving pledge to another party\n /// ...\n /// 511 -> Plugin for the intendedProject receiving pledge to another party\n /// @param amount The amount of value that will be transfered.\n function afterTransfer(\n uint64 pledgeManager,\n uint64 pledgeFrom,\n uint64 pledgeTo,\n uint64 context,\n address token,\n uint amount\n ) public;\n}\n" }, "giveth-liquidpledging/contracts/LiquidPledgingStorage.sol": { "keccak256": "0xd12c083fa5b12d4a6c51312498e3de2dd54b214d7580b1f363d0f9c099248a40", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/giveth-liquidpledging/contracts/LiquidPledgingStorage.sol" ], "content": "pragma solidity ^0.4.18;\n\nimport \"./ILiquidPledgingPlugin.sol\";\n\n/// @dev This is an interface for `LPVault` which serves as a secure storage for\n/// the ETH that backs the Pledges, only after `LiquidPledging` authorizes\n/// payments can Pledges be converted for ETH\ninterface ILPVault {\n function authorizePayment(bytes32 _ref, address _dest, address _token, uint _amount) public;\n}\n\n/// This contract contains all state variables used in LiquidPledging contracts\n/// This is done to have everything in 1 location, b/c state variable layout\n/// is MUST have be the same when performing an upgrade.\ncontract LiquidPledgingStorage {\n enum PledgeAdminType { Giver, Delegate, Project }\n enum PledgeState { Pledged, Paying, Paid }\n\n /// @dev This struct defines the details of a `PledgeAdmin` which are \n /// commonly referenced by their index in the `admins` array\n /// and can own pledges and act as delegates\n struct PledgeAdmin { \n PledgeAdminType adminType; // Giver, Delegate or Project\n address addr; // Account or contract address for admin\n uint64 commitTime; // In seconds, used for time Givers' & Delegates' have to veto\n uint64 parentProject; // Only for projects\n bool canceled; //Always false except for canceled projects\n\n /// @dev if the plugin is 0x0 then nothing happens, if its an address\n // than that smart contract is called when appropriate\n ILiquidPledgingPlugin plugin; \n string name;\n string url; // Can be IPFS hash\n }\n\n struct Pledge {\n uint amount;\n uint64[] delegationChain; // List of delegates in order of authority\n uint64 owner; // PledgeAdmin\n uint64 intendedProject; // Used when delegates are sending to projects\n uint64 commitTime; // When the intendedProject will become the owner\n uint64 oldPledge; // Points to the id that this Pledge was derived from\n address token;\n PledgeState pledgeState; // Pledged, Paying, Paid\n }\n\n PledgeAdmin[] admins; //The list of pledgeAdmins 0 means there is no admin\n Pledge[] pledges;\n /// @dev this mapping allows you to search for a specific pledge's \n /// index number by the hash of that pledge\n mapping (bytes32 => uint64) hPledge2idx;\n\n // this whitelist is for non-proxied plugins\n mapping (bytes32 => bool) pluginContractWhitelist;\n // this whitelist is for proxied plugins\n mapping (address => bool) pluginInstanceWhitelist;\n bool public whitelistDisabled = false;\n\n ILPVault public vault;\n\n // reserve 50 slots for future upgrades.\n uint[50] private storageOffset;\n}" }, "giveth-liquidpledging/contracts/LiquidPledgingACLHelpers.sol": { "keccak256": "0xb675a7a788bf656d4c3c78f3b4cf6645afb432939d1a4c38d70e01d068b0ce62", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/giveth-liquidpledging/contracts/LiquidPledgingACLHelpers.sol" ], "content": "pragma solidity ^0.4.18;\n\ncontract LiquidPledgingACLHelpers {\n function arr(uint64 a, uint64 b, address c, uint d, address e) internal pure returns(uint[] r) {\n r = new uint[](4);\n r[0] = uint(a);\n r[1] = uint(b);\n r[2] = uint(c);\n r[3] = d;\n r[4] = uint(e);\n }\n\n function arr(bool a) internal pure returns (uint[] r) {\n r = new uint[](1);\n uint _a;\n assembly {\n _a := a // forced casting\n }\n r[0] = _a;\n }\n}" }, "giveth-liquidpledging/contracts/LiquidPledgingPlugins.sol": { "keccak256": "0x35b93ff46b0ae7fd9797ac2360d9b5868c7eb75a3753e8804cdb59627cfe8763", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/giveth-liquidpledging/contracts/LiquidPledgingPlugins.sol" ], "content": "pragma solidity ^0.4.18;\n\n/*\n Copyright 2017, Jordi Baylina, RJ Ewing\n Contributors: Adrià Massanet <adria@codecontext.io>, Griff Green,\n Arthur Lunn\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n*/\n\nimport \"@aragon/os/contracts/apps/AragonApp.sol\";\nimport \"./LiquidPledgingStorage.sol\";\nimport \"./LiquidPledgingACLHelpers.sol\";\n\ncontract LiquidPledgingPlugins is AragonApp, LiquidPledgingStorage, LiquidPledgingACLHelpers {\n\n bytes32 constant public PLUGIN_MANAGER_ROLE = keccak256(\"PLUGIN_MANAGER_ROLE\");\n\n /**\n * @dev adds an instance of a plugin to the whitelist\n */\n function addValidPluginInstance(address addr) auth(PLUGIN_MANAGER_ROLE) external {\n pluginInstanceWhitelist[addr] = true;\n }\n\n /**\n * @dev add a contract to the plugin whitelist.\n * @notice Proxy contracts should never be added using this method. Each individual\n * proxy instance should be added by calling `addValidPluginInstance`\n */\n function addValidPluginContract(bytes32 contractHash) auth(PLUGIN_MANAGER_ROLE) public {\n pluginContractWhitelist[contractHash] = true;\n }\n\n function addValidPluginContracts(bytes32[] contractHashes) external auth(PLUGIN_MANAGER_ROLE) {\n for (uint8 i = 0; i < contractHashes.length; i++) {\n addValidPluginContract(contractHashes[i]);\n }\n }\n\n /**\n * @dev removes a contract from the plugin whitelist\n */\n function removeValidPluginContract(bytes32 contractHash) external authP(PLUGIN_MANAGER_ROLE, arr(contractHash)) {\n pluginContractWhitelist[contractHash] = false;\n }\n\n /**\n * @dev removes an instance of a plugin to the whitelist\n */\n function removeValidPluginInstance(address addr) external authP(PLUGIN_MANAGER_ROLE, arr(addr)) {\n pluginInstanceWhitelist[addr] = false;\n }\n\n /**\n * @dev enable/disable the plugin whitelist.\n * @notice you better know what you're doing if you are going to disable it\n */\n function useWhitelist(bool useWhitelist) external auth(PLUGIN_MANAGER_ROLE) {\n whitelistDisabled = !useWhitelist;\n }\n\n /**\n * check if the contract at the provided address is in the plugin whitelist\n */\n function isValidPlugin(address addr) public view returns(bool) {\n if (whitelistDisabled || addr == 0x0) {\n return true;\n }\n\n // first check pluginInstances\n if (pluginInstanceWhitelist[addr]) {\n return true;\n }\n\n // if the addr isn't a valid instance, check the contract code\n bytes32 contractHash = getCodeHash(addr);\n\n return pluginContractWhitelist[contractHash];\n }\n\n /**\n * @return the hash of the code for the given address\n */\n function getCodeHash(address addr) public view returns(bytes32) {\n bytes memory o_code;\n assembly {\n // retrieve the size of the code, this needs assembly\n let size := extcodesize(addr)\n // allocate output byte array - this could also be done without assembly\n // by using o_code = new bytes(size)\n o_code := mload(0x40)\n mstore(o_code, size) // store length in memory\n // actually retrieve the code, this needs assembly\n extcodecopy(addr, add(o_code, 0x20), 0, size)\n }\n return keccak256(o_code);\n }\n}" }, "giveth-liquidpledging/contracts/PledgeAdmins.sol": { "keccak256": "0x06bc6171a12d31aaa05dce4217e107555f8289182046a0bd8da615c38faae3f5", "urls": [ "file:///Users/rjewing/code/giveth/lpp-dac/node_modules/giveth-liquidpledging/contracts/PledgeAdmins.sol" ], "content": "pragma solidity ^0.4.18;\n\n/*\n Copyright 2017, Jordi Baylina, RJ Ewing\n Contributors: Adrià Massanet <adria@codecontext.io>, Griff Green,\n Arthur Lunn\n\n This program is free software: you can redistribute it and/or modify\n it under the terms of the GNU General Public License as published by\n the Free Software Foundation, either version 3 of the License, or\n (at your option) any later version.\n\n This program is distributed in the hope that it will be useful,\n but WITHOUT ANY WARRANTY; without even the implied warranty of\n MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n GNU General Public License for more details.\n\n You should have received a copy of the GNU General Public License\n along with this program. If not, see <http://www.gnu.org/licenses/>.\n*/\nimport \"./LiquidPledgingPlugins.sol\";\nimport \"@aragon/os/contracts/apps/AragonApp.sol\";\n\ncontract PledgeAdmins is AragonApp, LiquidPledgingPlugins {\n\n // Limits inserted to prevent large loops that could prevent canceling\n uint constant MAX_SUBPROJECT_LEVEL = 20;\n uint constant MAX_INTERPROJECT_LEVEL = 20;\n\n // Events\n event GiverAdded(uint64 indexed idGiver, string url);\n event GiverUpdated(uint64 indexed idGiver, string url);\n event DelegateAdded(uint64 indexed idDelegate, string url);\n event DelegateUpdated(uint64 indexed idDelegate, string url);\n event ProjectAdded(uint64 indexed idProject, string url);\n event ProjectUpdated(uint64 indexed idProject, string url);\n\n////////////////////\n// Public functions\n////////////////////\n\n /// @notice Creates a Giver Admin with the `msg.sender` as the Admin address\n /// @param name The name used to identify the Giver\n /// @param url The link to the Giver's profile often an IPFS hash\n /// @param commitTime The length of time in seconds the Giver has to\n /// veto when the Giver's delegates Pledge funds to a project\n /// @param plugin This is Giver's liquid pledge plugin allowing for\n /// extended functionality\n /// @return idGiver The id number used to reference this Admin\n function addGiver(\n string name,\n string url,\n uint64 commitTime,\n ILiquidPledgingPlugin plugin\n ) external returns (uint64 idGiver)\n {\n return addGiver(\n msg.sender,\n name,\n url,\n commitTime,\n plugin\n );\n }\n\n function addGiver(\n address addr,\n string name,\n string url,\n uint64 commitTime,\n ILiquidPledgingPlugin plugin\n ) public returns (uint64 idGiver)\n {\n require(isValidPlugin(plugin)); // Plugin check\n\n idGiver = uint64(admins.length);\n\n // Save the fields\n admins.push(\n PledgeAdmin(\n PledgeAdminType.Giver,\n addr,\n commitTime,\n 0,\n false,\n plugin,\n name,\n url)\n );\n\n GiverAdded(idGiver, url);\n }\n\n /// @notice Updates a Giver's info to change the address, name, url, or\n /// commitTime, it cannot be used to change a plugin, and it must be called\n /// by the current address of the Giver\n /// @param idGiver This is the Admin id number used to specify the Giver\n /// @param newAddr The new address that represents this Giver\n /// @param newName The new name used to identify the Giver\n /// @param newUrl The new link to the Giver's profile often an IPFS hash\n /// @param newCommitTime Sets the length of time in seconds the Giver has to\n /// veto when the Giver's delegates Pledge funds to a project\n function updateGiver(\n uint64 idGiver,\n address newAddr,\n string newName,\n string newUrl,\n uint64 newCommitTime\n ) external \n {\n PledgeAdmin storage giver = _findAdmin(idGiver);\n require(msg.sender == giver.addr);\n require(giver.adminType == PledgeAdminType.Giver); // Must be a Giver\n giver.addr = newAddr;\n giver.name = newName;\n giver.url = newUrl;\n giver.commitTime = newCommitTime;\n\n GiverUpdated(idGiver, newUrl);\n }\n\n /// @notice Creates a Delegate Admin with the `msg.sender` as the Admin addr\n /// @param name The name used to identify the Delegate\n /// @param url The link to the Delegate's profile often an IPFS hash\n /// @param commitTime Sets the length of time in seconds that this delegate\n /// can be vetoed. Whenever this delegate is in a delegate chain the time\n /// allowed to veto any event must be greater than or equal to this time.\n /// @param plugin This is Delegate's liquid pledge plugin allowing for\n /// extended functionality\n /// @return idxDelegate The id number used to reference this Delegate within\n /// the PLEDGE_ADMIN array\n function addDelegate(\n string name,\n string url,\n uint64 commitTime,\n ILiquidPledgingPlugin plugin\n ) external returns (uint64 idDelegate) \n {\n require(isValidPlugin(plugin)); // Plugin check\n\n idDelegate = uint64(admins.length);\n\n admins.push(\n PledgeAdmin(\n PledgeAdminType.Delegate,\n msg.sender,\n commitTime,\n 0,\n false,\n plugin,\n name,\n url)\n );\n\n DelegateAdded(idDelegate, url);\n }\n\n /// @notice Updates a Delegate's info to change the address, name, url, or\n /// commitTime, it cannot be used to change a plugin, and it must be called\n /// by the current address of the Delegate\n /// @param idDelegate The Admin id number used to specify the Delegate\n /// @param newAddr The new address that represents this Delegate\n /// @param newName The new name used to identify the Delegate\n /// @param newUrl The new link to the Delegate's profile often an IPFS hash\n /// @param newCommitTime Sets the length of time in seconds that this\n /// delegate can be vetoed. Whenever this delegate is in a delegate chain\n /// the time allowed to veto any event must be greater than or equal to\n /// this time.\n function updateDelegate(\n uint64 idDelegate,\n address newAddr,\n string newName,\n string newUrl,\n uint64 newCommitTime\n ) external \n {\n PledgeAdmin storage delegate = _findAdmin(idDelegate);\n require(msg.sender == delegate.addr);\n require(delegate.adminType == PledgeAdminType.Delegate);\n delegate.addr = newAddr;\n delegate.name = newName;\n delegate.url = newUrl;\n delegate.commitTime = newCommitTime;\n\n DelegateUpdated(idDelegate, newUrl);\n }\n\n /// @notice Creates a Project Admin with the `msg.sender` as the Admin addr\n /// @param name The name used to identify the Project\n /// @param url The link to the Project's profile often an IPFS hash\n /// @param projectAdmin The address for the trusted project manager\n /// @param parentProject The Admin id number for the parent project or 0 if\n /// there is no parentProject\n /// @param commitTime Sets the length of time in seconds the Project has to\n /// veto when the Project delegates to another Delegate and they pledge\n /// those funds to a project\n /// @param plugin This is Project's liquid pledge plugin allowing for\n /// extended functionality\n /// @return idProject The id number used to reference this Admin\n function addProject(\n string name,\n string url,\n address projectAdmin,\n uint64 parentProject,\n uint64 commitTime,\n ILiquidPledgingPlugin plugin\n ) external returns (uint64 idProject) \n {\n require(isValidPlugin(plugin));\n\n if (parentProject != 0) {\n PledgeAdmin storage a = _findAdmin(parentProject);\n // getProjectLevel will check that parentProject has a `Project` adminType\n require(_getProjectLevel(a) < MAX_SUBPROJECT_LEVEL);\n }\n\n idProject = uint64(admins.length);\n\n admins.push(\n PledgeAdmin(\n PledgeAdminType.Project,\n projectAdmin,\n commitTime,\n parentProject,\n false,\n plugin,\n name,\n url)\n );\n\n ProjectAdded(idProject, url);\n }\n\n /// @notice Updates a Project's info to change the address, name, url, or\n /// commitTime, it cannot be used to change a plugin or a parentProject,\n /// and it must be called by the current address of the Project\n /// @param idProject The Admin id number used to specify the Project\n /// @param newAddr The new address that represents this Project\n /// @param newName The new name used to identify the Project\n /// @param newUrl The new link to the Project's profile often an IPFS hash\n /// @param newCommitTime Sets the length of time in seconds the Project has\n /// to veto when the Project delegates to a Delegate and they pledge those\n /// funds to a project\n function updateProject(\n uint64 idProject,\n address newAddr,\n string newName,\n string newUrl,\n uint64 newCommitTime\n ) external \n {\n PledgeAdmin storage project = _findAdmin(idProject);\n\n require(msg.sender == project.addr);\n require(project.adminType == PledgeAdminType.Project);\n\n project.addr = newAddr;\n project.name = newName;\n project.url = newUrl;\n project.commitTime = newCommitTime;\n\n ProjectUpdated(idProject, newUrl);\n }\n\n/////////////////////////////\n// Public constant functions\n/////////////////////////////\n\n /// @notice A constant getter used to check how many total Admins exist\n /// @return The total number of admins (Givers, Delegates and Projects) .\n function numberOfPledgeAdmins() external view returns(uint) {\n return admins.length - 1;\n }\n\n /// @notice A constant getter to check the details of a specified Admin\n /// @return addr Account or contract address for admin\n /// @return name Name of the pledgeAdmin\n /// @return url The link to the Project's profile often an IPFS hash\n /// @return commitTime The length of time in seconds the Admin has to veto\n /// when the Admin delegates to a Delegate and that Delegate pledges those\n /// funds to a project\n /// @return parentProject The Admin id number for the parent project or 0\n /// if there is no parentProject\n /// @return canceled 0 for Delegates & Givers, true if a Project has been\n /// canceled\n /// @return plugin This is Project's liquidPledging plugin allowing for\n /// extended functionality\n function getPledgeAdmin(uint64 idAdmin) external view returns (\n PledgeAdminType adminType,\n address addr,\n string name,\n string url,\n uin