From 8b8a5cd004e53df425db13740fae69550107aefb Mon Sep 17 00:00:00 2001 From: Otto G Date: Mon, 10 Feb 2020 08:01:29 +0100 Subject: [PATCH 1/2] refactor(test-helpers): remove test-helpers part one: contracts folder Even if this commit looks huge, it is actually quite simple: - It removes `contracts` folder from `@tps/test-helpers` and its content - Moves ADynamicForwarder and DynamicScriptHelpers locally to DotVoting - Change DotVoting imports - Inline IForwarder and rename to solve issues with coverage - Removing pre and post coverage hooks, unnecessary for validation after inlining the interface --- apps/dot-voting/contracts/DotVoting.sol | 2 +- .../contracts/lib}/ADynamicForwarder.sol | 18 +- .../contracts/lib}/DynamicScriptHelpers.sol | 0 apps/dot-voting/package.json | 2 - .../shared/test-helpers/contracts/acl/ACL.sol | 436 ----- .../contracts/acl/ACLSyntaxSugar.sol | 102 -- .../test-helpers/contracts/acl/IACL.sol | 14 - .../test-helpers/contracts/acl/IACLOracle.sol | 10 - .../contracts/apm/APMNamehash.sol | 16 - .../contracts/apm/APMRegistry.sol | 107 -- .../test-helpers/contracts/apm/Repo.sol | 119 -- .../contracts/apps/AppProxyBase.sol | 38 - .../contracts/apps/AppProxyPinned.sol | 49 - .../contracts/apps/AppProxyUpgradeable.sol | 33 - .../contracts/apps/AppStorage.sol | 36 - .../test-helpers/contracts/apps/AragonApp.sol | 68 - .../contracts/apps/UnsafeAragonApp.sol | 24 - .../test-helpers/contracts/apps/Voting.sol | 349 ---- .../test-helpers/contracts/apps/readme.md | 3 - .../contracts/common/Autopetrified.sol | 16 - .../contracts/common/DelegateProxy.sol | 31 - .../common/DepositableDelegateProxy.sol | 21 - .../contracts/common/DepositableStorage.sol | 19 - .../contracts/common/EtherTokenConstant.sol | 12 - .../contracts/common/IForwarder.sol | 18 - .../contracts/common/IVaultRecoverable.sol | 13 - .../contracts/common/Initializable.sol | 56 - .../contracts/common/IsContract.sol | 18 - .../contracts/common/Petrifiable.sol | 25 - .../contracts/common/TimeHelpers.sol | 48 - .../contracts/common/Uint256Helpers.sol | 11 - .../contracts/common/UnstructuredStorage.sol | 40 - .../contracts/common/VaultRecoverable.sol | 43 - .../contracts/ens/ENSConstants.sol | 14 - .../contracts/ens/ENSSubdomainRegistrar.sol | 92 -- .../contracts/evmscript/EVMScriptRegistry.sol | 92 -- .../contracts/evmscript/EVMScriptRunner.sol | 76 - .../evmscript/IEVMScriptExecutor.sol | 11 - .../evmscript/IEVMScriptRegistry.sol | 25 - .../executors/BaseEVMScriptExecutor.sol | 13 - .../evmscript/executors/CallsScript.sol | 55 - .../contracts/factory/APMRegistryFactory.sol | 126 -- .../contracts/factory/AppProxyFactory.sol | 29 - .../contracts/factory/DAOFactory.sol | 69 - .../contracts/factory/ENSFactory.sol | 33 - .../factory/EVMScriptRegistryFactory.sol | 38 - .../test-helpers/contracts/kernel/IKernel.sol | 20 - .../test-helpers/contracts/kernel/Kernel.sol | 244 --- .../contracts/kernel/KernelConstants.sol | 29 - .../contracts/kernel/KernelProxy.sol | 34 - .../contracts/kernel/KernelStorage.sol | 8 - .../contracts/lib/bounties/BountiesEvents.sol | 34 - .../lib/bounties/StandardBounties.sol | 597 ------- .../bounties/inherited/HumanStandardToken.sol | 57 - .../lib/bounties/inherited/StandardToken.sol | 56 - .../lib/bounties/inherited/Token.sol | 48 - .../contracts/lib/ens/AbstractENS.sol | 24 - .../test-helpers/contracts/lib/ens/ENS.sol | 95 -- .../contracts/lib/ens/PublicResolver.sol | 212 --- .../test-helpers/contracts/lib/math/Math.sol | 24 - .../contracts/lib/math/SafeMath.sol | 69 - .../contracts/lib/math/SafeMath64.sol | 63 - .../contracts/lib/math/SafeMath8.sol | 63 - .../contracts/lib/minime/ITokenController.sol | 27 - .../contracts/lib/minime/MiniMeToken.sol | 579 ------- .../contracts/lib/misc/ERCProxy.sol | 14 - .../contracts/lib/misc/Migrations.sol | 25 - .../contracts/lib/token/ERC20.sol | 37 - .../contracts/lib/zeppelin/math/Math.sol | 25 - .../contracts/lib/zeppelin/math/SafeMath.sol | 69 - .../lib/zeppelin/math/SafeMath64.sol | 69 - .../contracts/lib/zeppelin/math/SafeMath8.sol | 69 - .../lib/zeppelin/token/BasicToken.sol | 44 - .../contracts/lib/zeppelin/token/ERC20.sol | 16 - .../lib/zeppelin/token/ERC20Basic.sol | 14 - .../lib/zeppelin/token/StandardToken.sol | 87 - .../contracts/test/TestACLInterpreter.sol | 268 ---- .../contracts/test/TestDelegateProxy.sol | 74 - .../contracts/test/helpers/ACLHelper.sol | 59 - .../contracts/test/helpers/Assert.sol | 1405 ----------------- .../contracts/test/helpers/ThrowProxy.sol | 33 - .../test/mocks/APMNamehashWrapper.sol | 10 - .../test/mocks/APMRegistryFactoryMock.sol | 90 -- .../test/mocks/AppProxyPinnedStorageMock.sol | 41 - .../contracts/test/mocks/AppStorageMock.sol | 22 - .../contracts/test/mocks/AppStub.sol | 48 - .../test/mocks/AppStubConditionalRecovery.sol | 17 - .../test/mocks/AppStubDepositable.sol | 26 - .../test/mocks/DepositableStorageMock.sol | 14 - .../contracts/test/mocks/ERCProxyMock.sol | 17 - .../test/mocks/EVMScriptExecutorMock.sol | 15 - .../contracts/test/mocks/ExecutionTarget.sol | 21 - .../test/mocks/InitializableStorageMock.sol | 14 - .../contracts/test/mocks/KeccakConstants.sol | 57 - .../test/mocks/KernelDepositableMock.sol | 17 - .../test/mocks/KernelOverloadMock.sol | 31 - .../contracts/test/mocks/KernelSetAppMock.sol | 13 - .../contracts/test/mocks/LifecycleMock.sol | 15 - .../test/mocks/MockScriptExecutorApp.sol | 33 - .../contracts/test/mocks/SafeMath64Mock.sol | 28 - .../contracts/test/mocks/SafeMath8Mock.sol | 28 - .../contracts/test/mocks/TimeHelpersMock.sol | 30 - .../contracts/test/mocks/TokenMock.sol | 46 - .../contracts/test/mocks/Uint256Mock.sol | 12 - .../test/mocks/UnsafeAragonAppMock.sol | 19 - .../contracts/test/mocks/UnsafeRepo.sol | 13 - .../contracts/test/mocks/UpgradedKernel.sol | 14 - .../contracts/test/mocks/VaultMock.sol | 18 - 108 files changed, 16 insertions(+), 7754 deletions(-) rename apps/{shared/test-helpers/contracts/common => dot-voting/contracts/lib}/ADynamicForwarder.sol (97%) rename apps/{shared/test-helpers/contracts/evmscript => dot-voting/contracts/lib}/DynamicScriptHelpers.sol (100%) delete mode 100644 apps/shared/test-helpers/contracts/acl/ACL.sol delete mode 100644 apps/shared/test-helpers/contracts/acl/ACLSyntaxSugar.sol delete mode 100644 apps/shared/test-helpers/contracts/acl/IACL.sol delete mode 100644 apps/shared/test-helpers/contracts/acl/IACLOracle.sol delete mode 100644 apps/shared/test-helpers/contracts/apm/APMNamehash.sol delete mode 100644 apps/shared/test-helpers/contracts/apm/APMRegistry.sol delete mode 100644 apps/shared/test-helpers/contracts/apm/Repo.sol delete mode 100644 apps/shared/test-helpers/contracts/apps/AppProxyBase.sol delete mode 100644 apps/shared/test-helpers/contracts/apps/AppProxyPinned.sol delete mode 100644 apps/shared/test-helpers/contracts/apps/AppProxyUpgradeable.sol delete mode 100644 apps/shared/test-helpers/contracts/apps/AppStorage.sol delete mode 100644 apps/shared/test-helpers/contracts/apps/AragonApp.sol delete mode 100644 apps/shared/test-helpers/contracts/apps/UnsafeAragonApp.sol delete mode 100644 apps/shared/test-helpers/contracts/apps/Voting.sol delete mode 100644 apps/shared/test-helpers/contracts/apps/readme.md delete mode 100644 apps/shared/test-helpers/contracts/common/Autopetrified.sol delete mode 100644 apps/shared/test-helpers/contracts/common/DelegateProxy.sol delete mode 100644 apps/shared/test-helpers/contracts/common/DepositableDelegateProxy.sol delete mode 100644 apps/shared/test-helpers/contracts/common/DepositableStorage.sol delete mode 100644 apps/shared/test-helpers/contracts/common/EtherTokenConstant.sol delete mode 100644 apps/shared/test-helpers/contracts/common/IForwarder.sol delete mode 100644 apps/shared/test-helpers/contracts/common/IVaultRecoverable.sol delete mode 100644 apps/shared/test-helpers/contracts/common/Initializable.sol delete mode 100644 apps/shared/test-helpers/contracts/common/IsContract.sol delete mode 100644 apps/shared/test-helpers/contracts/common/Petrifiable.sol delete mode 100644 apps/shared/test-helpers/contracts/common/TimeHelpers.sol delete mode 100644 apps/shared/test-helpers/contracts/common/Uint256Helpers.sol delete mode 100644 apps/shared/test-helpers/contracts/common/UnstructuredStorage.sol delete mode 100644 apps/shared/test-helpers/contracts/common/VaultRecoverable.sol delete mode 100644 apps/shared/test-helpers/contracts/ens/ENSConstants.sol delete mode 100644 apps/shared/test-helpers/contracts/ens/ENSSubdomainRegistrar.sol delete mode 100644 apps/shared/test-helpers/contracts/evmscript/EVMScriptRegistry.sol delete mode 100644 apps/shared/test-helpers/contracts/evmscript/EVMScriptRunner.sol delete mode 100644 apps/shared/test-helpers/contracts/evmscript/IEVMScriptExecutor.sol delete mode 100644 apps/shared/test-helpers/contracts/evmscript/IEVMScriptRegistry.sol delete mode 100644 apps/shared/test-helpers/contracts/evmscript/executors/BaseEVMScriptExecutor.sol delete mode 100644 apps/shared/test-helpers/contracts/evmscript/executors/CallsScript.sol delete mode 100644 apps/shared/test-helpers/contracts/factory/APMRegistryFactory.sol delete mode 100644 apps/shared/test-helpers/contracts/factory/AppProxyFactory.sol delete mode 100644 apps/shared/test-helpers/contracts/factory/DAOFactory.sol delete mode 100644 apps/shared/test-helpers/contracts/factory/ENSFactory.sol delete mode 100644 apps/shared/test-helpers/contracts/factory/EVMScriptRegistryFactory.sol delete mode 100644 apps/shared/test-helpers/contracts/kernel/IKernel.sol delete mode 100644 apps/shared/test-helpers/contracts/kernel/Kernel.sol delete mode 100644 apps/shared/test-helpers/contracts/kernel/KernelConstants.sol delete mode 100644 apps/shared/test-helpers/contracts/kernel/KernelProxy.sol delete mode 100644 apps/shared/test-helpers/contracts/kernel/KernelStorage.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/bounties/BountiesEvents.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/bounties/StandardBounties.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/bounties/inherited/HumanStandardToken.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/bounties/inherited/StandardToken.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/bounties/inherited/Token.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/ens/AbstractENS.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/ens/ENS.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/ens/PublicResolver.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/math/Math.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/math/SafeMath.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/math/SafeMath64.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/math/SafeMath8.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/minime/ITokenController.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/minime/MiniMeToken.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/misc/ERCProxy.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/misc/Migrations.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/token/ERC20.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/zeppelin/math/Math.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath64.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath8.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/zeppelin/token/BasicToken.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/zeppelin/token/ERC20.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/zeppelin/token/ERC20Basic.sol delete mode 100644 apps/shared/test-helpers/contracts/lib/zeppelin/token/StandardToken.sol delete mode 100644 apps/shared/test-helpers/contracts/test/TestACLInterpreter.sol delete mode 100644 apps/shared/test-helpers/contracts/test/TestDelegateProxy.sol delete mode 100644 apps/shared/test-helpers/contracts/test/helpers/ACLHelper.sol delete mode 100644 apps/shared/test-helpers/contracts/test/helpers/Assert.sol delete mode 100644 apps/shared/test-helpers/contracts/test/helpers/ThrowProxy.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/APMNamehashWrapper.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/APMRegistryFactoryMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/AppProxyPinnedStorageMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/AppStorageMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/AppStub.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/AppStubConditionalRecovery.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/AppStubDepositable.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/DepositableStorageMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/ERCProxyMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/EVMScriptExecutorMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/ExecutionTarget.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/InitializableStorageMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/KeccakConstants.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/KernelDepositableMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/KernelOverloadMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/KernelSetAppMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/LifecycleMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/MockScriptExecutorApp.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/SafeMath64Mock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/SafeMath8Mock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/TimeHelpersMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/TokenMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/Uint256Mock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/UnsafeAragonAppMock.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/UnsafeRepo.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/UpgradedKernel.sol delete mode 100644 apps/shared/test-helpers/contracts/test/mocks/VaultMock.sol diff --git a/apps/dot-voting/contracts/DotVoting.sol b/apps/dot-voting/contracts/DotVoting.sol index 46d664549..782600b32 100644 --- a/apps/dot-voting/contracts/DotVoting.sol +++ b/apps/dot-voting/contracts/DotVoting.sol @@ -9,7 +9,7 @@ import "@aragon/apps-shared-minime/contracts/MiniMeToken.sol"; // TODO: Revert import path when changes get merged into aragon/os // import "@aragon/os/contracts/common/ADynamicForwarder.sol"; -import "@tps/test-helpers/contracts/common/ADynamicForwarder.sol"; +import "./lib/ADynamicForwarder.sol"; contract DotVoting is ADynamicForwarder, AragonApp { diff --git a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol b/apps/dot-voting/contracts/lib/ADynamicForwarder.sol similarity index 97% rename from apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol rename to apps/dot-voting/contracts/lib/ADynamicForwarder.sol index 3389f599a..1632f125d 100644 --- a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol +++ b/apps/dot-voting/contracts/lib/ADynamicForwarder.sol @@ -8,9 +8,21 @@ import "@aragon/os/contracts/lib/math/SafeMath.sol"; import "@aragon/os/contracts/lib/math/SafeMath64.sol"; // TODO: Use @aragon/os/contracts/ version when it gets merged -import "../evmscript/DynamicScriptHelpers.sol"; +import "./DynamicScriptHelpers.sol"; // TODO: Research why using the @aragon/os version breaks coverage -import "@aragon/os/contracts/common/IForwarder.sol"; +// import "@aragon/os/contracts/common/IForwarder.sol"; + +interface InterfacedForwarder { + function isForwarder() external pure returns (bool); + + // TODO: this should be external + // See https://github.com/ethereum/solidity/issues/4832 + function canForward(address sender, bytes evmCallScript) public view returns (bool); + + // TODO: this should be external + // See https://github.com/ethereum/solidity/issues/4832 + function forward(bytes evmCallScript) public; +} /** * @title ADynamicForwarder App @@ -21,7 +33,7 @@ import "@aragon/os/contracts/common/IForwarder.sol"; */ -contract ADynamicForwarder is IForwarder { +contract ADynamicForwarder is InterfacedForwarder { using DynamicScriptHelpers for bytes; using SafeMath for uint256; using SafeMath64 for uint64; diff --git a/apps/shared/test-helpers/contracts/evmscript/DynamicScriptHelpers.sol b/apps/dot-voting/contracts/lib/DynamicScriptHelpers.sol similarity index 100% rename from apps/shared/test-helpers/contracts/evmscript/DynamicScriptHelpers.sol rename to apps/dot-voting/contracts/lib/DynamicScriptHelpers.sol diff --git a/apps/dot-voting/package.json b/apps/dot-voting/package.json index 986c434fb..f03b2764a 100644 --- a/apps/dot-voting/package.json +++ b/apps/dot-voting/package.json @@ -13,9 +13,7 @@ "frontend": "npm run sync-assets && parcel app/index.html --port 4444", "ganache-cli:test": "sh ../../node_modules/@aragon/test-helpers/ganache-cli.sh", "lint": "solium --dir ./contracts", - "postcoverage": " sed -i 's+./IForwarder.sol+@aragon/os/contracts/common/IForwarder.sol+g' ../shared/test-helpers/contracts/common/ADynamicForwarder.sol", "precommit": "lint-staged", - "precoverage": "sed -i 's+@aragon/os/contracts/common/IForwarder.sol+./IForwarder.sol+g' ../shared/test-helpers/contracts/common/ADynamicForwarder.sol", "prepublishOnly": "truffle compile", "publish:cd": "../../shared/deployments/check-publish.sh", "publish:http": "npm run build:script && yes | aragon apm publish major --files dist --http localhost:4444 --http-served-from ./dist --propagate-content false --skip-confirmation true", diff --git a/apps/shared/test-helpers/contracts/acl/ACL.sol b/apps/shared/test-helpers/contracts/acl/ACL.sol deleted file mode 100644 index 1cea206f7..000000000 --- a/apps/shared/test-helpers/contracts/acl/ACL.sol +++ /dev/null @@ -1,436 +0,0 @@ -pragma solidity 0.4.24; - -import "../apps/AragonApp.sol"; -import "../common/TimeHelpers.sol"; -import "./ACLSyntaxSugar.sol"; -import "./IACL.sol"; -import "./IACLOracle.sol"; - - -/* solium-disable function-order */ -// Allow public initialize() to be first -contract ACL is IACL, TimeHelpers, AragonApp, ACLHelpers { - // Hardcoded constant to save gas - //bytes32 constant public CREATE_PERMISSIONS_ROLE = keccak256("CREATE_PERMISSIONS_ROLE"); - bytes32 constant public CREATE_PERMISSIONS_ROLE = 0x0b719b33c83b8e5d300c521cb8b54ae9bd933996a14bef8c2f4e0285d2d2400a; - - // Whether someone has a permission - mapping (bytes32 => bytes32) internal permissions; // permissions hash => params hash - mapping (bytes32 => Param[]) internal permissionParams; // params hash => params - - // Who is the manager of a permission - mapping (bytes32 => address) internal permissionManager; - - enum Op { NONE, EQ, NEQ, GT, LT, GTE, LTE, RET, NOT, AND, OR, XOR, IF_ELSE } // op types - - struct Param { - uint8 id; - uint8 op; - uint240 value; // even though value is an uint240 it can store addresses - // in the case of 32 byte hashes losing 2 bytes precision isn't a huge deal - // op and id take less than 1 byte each so it can be kept in 1 sstore - } - - uint8 constant BLOCK_NUMBER_PARAM_ID = 200; - uint8 constant TIMESTAMP_PARAM_ID = 201; - // 202 is unused - uint8 constant ORACLE_PARAM_ID = 203; - uint8 constant LOGIC_OP_PARAM_ID = 204; - uint8 constant PARAM_VALUE_PARAM_ID = 205; - // TODO: Add execution times param type? - - // Hardcoded constant to save gas - //bytes32 constant public EMPTY_PARAM_HASH = keccak256(uint256(0)); - bytes32 constant public EMPTY_PARAM_HASH = 0x290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563; - bytes32 constant public NO_PERMISSION = bytes32(0); - address constant public ANY_ENTITY = address(-1); - uint256 constant ORACLE_CHECK_GAS = 30000; - - modifier onlyPermissionManager(address _app, bytes32 _role) { - require(msg.sender == getPermissionManager(_app, _role)); - _; - } - - event SetPermission(address indexed entity, address indexed app, bytes32 indexed role, bool allowed); - event SetPermissionParams(address indexed entity, address indexed app, bytes32 indexed role, bytes32 paramsHash); - event ChangePermissionManager(address indexed app, bytes32 indexed role, address indexed manager); - - /** - * @dev Initialize can only be called once. It saves the block number in which it was initialized. - * @notice Initialize an ACL instance and set `_permissionsCreator` as the entity that can create other permissions - * @param _permissionsCreator Entity that will be given permission over createPermission - */ - function initialize(address _permissionsCreator) public onlyInit { - initialized(); - require(msg.sender == address(kernel())); - - _createPermission(_permissionsCreator, this, CREATE_PERMISSIONS_ROLE, _permissionsCreator); - } - - /** - * @dev Creates a permission that wasn't previously set and managed. - * If a created permission is removed it is possible to reset it with createPermission. - * This is the **ONLY** way to create permissions and set managers to permissions that don't - * have a manager. - * In terms of the ACL being initialized, this function implicitly protects all the other - * state-changing external functions, as they all require the sender to be a manager. - * @notice Create a new permission granting `_entity` the ability to perform actions requiring `_role` on `_app`, setting `_manager` as the permission's manager - * @param _entity Address of the whitelisted entity that will be able to perform the role - * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL) - * @param _role Identifier for the group of actions in app given access to perform - * @param _manager Address of the entity that will be able to grant and revoke the permission further. - */ - function createPermission(address _entity, address _app, bytes32 _role, address _manager) - external - auth(CREATE_PERMISSIONS_ROLE) - { - _createPermission(_entity, _app, _role, _manager); - } - - /** - * @dev Grants permission if allowed. This requires `msg.sender` to be the permission manager - * @notice Grant `_entity` the ability to perform actions requiring `_role` on `_app` - * @param _entity Address of the whitelisted entity that will be able to perform the role - * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL) - * @param _role Identifier for the group of actions in app given access to perform - */ - function grantPermission(address _entity, address _app, bytes32 _role) - external - { - grantPermissionP(_entity, _app, _role, new uint256[](0)); - } - - /** - * @dev Grants a permission with parameters if allowed. This requires `msg.sender` to be the permission manager - * @notice Grant `_entity` the ability to perform actions requiring `_role` on `_app` - * @param _entity Address of the whitelisted entity that will be able to perform the role - * @param _app Address of the app in which the role will be allowed (requires app to depend on kernel for ACL) - * @param _role Identifier for the group of actions in app given access to perform - * @param _params Permission parameters - */ - function grantPermissionP(address _entity, address _app, bytes32 _role, uint256[] _params) - public - onlyPermissionManager(_app, _role) - { - bytes32 paramsHash = _params.length > 0 ? _saveParams(_params) : EMPTY_PARAM_HASH; - _setPermission(_entity, _app, _role, paramsHash); - } - - /** - * @dev Revokes permission if allowed. This requires `msg.sender` to be the the permission manager - * @notice Revoke from `_entity` the ability to perform actions requiring `_role` on `_app` - * @param _entity Address of the whitelisted entity to revoke access from - * @param _app Address of the app in which the role will be revoked - * @param _role Identifier for the group of actions in app being revoked - */ - function revokePermission(address _entity, address _app, bytes32 _role) - external - onlyPermissionManager(_app, _role) - { - _setPermission(_entity, _app, _role, NO_PERMISSION); - } - - /** - * @notice Set `_newManager` as the manager of `_role` in `_app` - * @param _newManager Address for the new manager - * @param _app Address of the app in which the permission management is being transferred - * @param _role Identifier for the group of actions being transferred - */ - function setPermissionManager(address _newManager, address _app, bytes32 _role) - external - onlyPermissionManager(_app, _role) - { - _setPermissionManager(_newManager, _app, _role); - } - - /** - * @notice Remove the manager of `_role` in `_app` - * @param _app Address of the app in which the permission is being unmanaged - * @param _role Identifier for the group of actions being unmanaged - */ - function removePermissionManager(address _app, bytes32 _role) - external - onlyPermissionManager(_app, _role) - { - _setPermissionManager(address(0), _app, _role); - } - - /** - * @notice Get parameters for permission array length - * @param _entity Address of the whitelisted entity that will be able to perform the role - * @param _app Address of the app - * @param _role Identifier for a group of actions in app - * @return Length of the array - */ - function getPermissionParamsLength(address _entity, address _app, bytes32 _role) external view returns (uint) { - return permissionParams[permissions[permissionHash(_entity, _app, _role)]].length; - } - - /** - * @notice Get parameter for permission - * @param _entity Address of the whitelisted entity that will be able to perform the role - * @param _app Address of the app - * @param _role Identifier for a group of actions in app - * @param _index Index of parameter in the array - * @return Parameter (id, op, value) - */ - function getPermissionParam(address _entity, address _app, bytes32 _role, uint _index) - external - view - returns (uint8, uint8, uint240) - { - Param storage param = permissionParams[permissions[permissionHash(_entity, _app, _role)]][_index]; - return (param.id, param.op, param.value); - } - - /** - * @dev Get manager for permission - * @param _app Address of the app - * @param _role Identifier for a group of actions in app - * @return address of the manager for the permission - */ - function getPermissionManager(address _app, bytes32 _role) public view returns (address) { - return permissionManager[roleHash(_app, _role)]; - } - - /** - * @dev Function called by apps to check ACL on kernel or to check permission statu - * @param _who Sender of the original call - * @param _where Address of the app - * @param _where Identifier for a group of actions in app - * @param _how Permission parameters - * @return boolean indicating whether the ACL allows the role or not - */ - function hasPermission(address _who, address _where, bytes32 _what, bytes memory _how) public view returns (bool) { - uint256[] memory how; - uint256 intsLength = _how.length / 32; - assembly { - how := _how // forced casting - mstore(how, intsLength) - } - // _how is invalid from this point fwd - return hasPermission(_who, _where, _what, how); - } - - function hasPermission(address _who, address _where, bytes32 _what, uint256[] memory _how) public view returns (bool) { - bytes32 whoParams = permissions[permissionHash(_who, _where, _what)]; - if (whoParams != NO_PERMISSION && evalParams(whoParams, _who, _where, _what, _how)) { - return true; - } - - bytes32 anyParams = permissions[permissionHash(ANY_ENTITY, _where, _what)]; - if (anyParams != NO_PERMISSION && evalParams(anyParams, ANY_ENTITY, _where, _what, _how)) { - return true; - } - - return false; - } - - function hasPermission(address _who, address _where, bytes32 _what) public view returns (bool) { - uint256[] memory empty = new uint256[](0); - return hasPermission(_who, _where, _what, empty); - } - - function evalParams( - bytes32 _paramsHash, - address _who, - address _where, - bytes32 _what, - uint256[] _how - ) public view returns (bool) - { - if (_paramsHash == EMPTY_PARAM_HASH) { - return true; - } - - return _evalParam(_paramsHash, 0, _who, _where, _what, _how); - } - - /** - * @dev Internal createPermission for access inside the kernel (on instantiation) - */ - function _createPermission(address _entity, address _app, bytes32 _role, address _manager) internal { - // only allow permission creation (or re-creation) when there is no manager - require(getPermissionManager(_app, _role) == address(0)); - - _setPermission(_entity, _app, _role, EMPTY_PARAM_HASH); - _setPermissionManager(_manager, _app, _role); - } - - /** - * @dev Internal function called to actually save the permission - */ - function _setPermission(address _entity, address _app, bytes32 _role, bytes32 _paramsHash) internal { - permissions[permissionHash(_entity, _app, _role)] = _paramsHash; - bool entityHasPermission = _paramsHash != NO_PERMISSION; - bool permissionHasParams = entityHasPermission && _paramsHash != EMPTY_PARAM_HASH; - - emit SetPermission(_entity, _app, _role, entityHasPermission); - if (permissionHasParams) { - emit SetPermissionParams(_entity, _app, _role, _paramsHash); - } - } - - function _saveParams(uint256[] _encodedParams) internal returns (bytes32) { - bytes32 paramHash = keccak256(abi.encodePacked(_encodedParams)); - Param[] storage params = permissionParams[paramHash]; - - if (params.length == 0) { // params not saved before - for (uint256 i = 0; i < _encodedParams.length; i++) { - uint256 encodedParam = _encodedParams[i]; - Param memory param = Param(decodeParamId(encodedParam), decodeParamOp(encodedParam), uint240(encodedParam)); - params.push(param); - } - } - - return paramHash; - } - - function _evalParam( - bytes32 _paramsHash, - uint32 _paramId, - address _who, - address _where, - bytes32 _what, - uint256[] _how - ) internal view returns (bool) - { - if (_paramId >= permissionParams[_paramsHash].length) { - return false; // out of bounds - } - - Param memory param = permissionParams[_paramsHash][_paramId]; - - if (param.id == LOGIC_OP_PARAM_ID) { - return _evalLogic(param, _paramsHash, _who, _where, _what, _how); - } - - uint256 value; - uint256 comparedTo = uint256(param.value); - - // get value - if (param.id == ORACLE_PARAM_ID) { - value = checkOracle(IACLOracle(param.value), _who, _where, _what, _how) ? 1 : 0; - comparedTo = 1; - } else if (param.id == BLOCK_NUMBER_PARAM_ID) { - value = getBlockNumber(); - } else if (param.id == TIMESTAMP_PARAM_ID) { - value = getTimestamp(); - } else if (param.id == PARAM_VALUE_PARAM_ID) { - value = uint256(param.value); - } else { - if (param.id >= _how.length) { - return false; - } - value = uint256(uint240(_how[param.id])); // force lost precision - } - - if (Op(param.op) == Op.RET) { - return uint256(value) > 0; - } - - return compare(value, Op(param.op), comparedTo); - } - - function _evalLogic(Param _param, bytes32 _paramsHash, address _who, address _where, bytes32 _what, uint256[] _how) - internal - view - returns (bool) - { - if (Op(_param.op) == Op.IF_ELSE) { - uint32 conditionParam; - uint32 successParam; - uint32 failureParam; - - (conditionParam, successParam, failureParam) = decodeParamsList(uint256(_param.value)); - bool result = _evalParam(_paramsHash, conditionParam, _who, _where, _what, _how); - - return _evalParam(_paramsHash, result ? successParam : failureParam, _who, _where, _what, _how); - } - - uint32 param1; - uint32 param2; - - (param1, param2,) = decodeParamsList(uint256(_param.value)); - bool r1 = _evalParam(_paramsHash, param1, _who, _where, _what, _how); - - if (Op(_param.op) == Op.NOT) { - return !r1; - } - - if (r1 && Op(_param.op) == Op.OR) { - return true; - } - - if (!r1 && Op(_param.op) == Op.AND) { - return false; - } - - bool r2 = _evalParam(_paramsHash, param2, _who, _where, _what, _how); - - if (Op(_param.op) == Op.XOR) { - return r1 != r2; - } - - return r2; // both or and and depend on result of r2 after checks - } - - function compare(uint256 _a, Op _op, uint256 _b) internal pure returns (bool) { - if (_op == Op.EQ) return _a == _b; // solium-disable-line lbrace - if (_op == Op.NEQ) return _a != _b; // solium-disable-line lbrace - if (_op == Op.GT) return _a > _b; // solium-disable-line lbrace - if (_op == Op.LT) return _a < _b; // solium-disable-line lbrace - if (_op == Op.GTE) return _a >= _b; // solium-disable-line lbrace - if (_op == Op.LTE) return _a <= _b; // solium-disable-line lbrace - return false; - } - - function checkOracle(IACLOracle _oracleAddr, address _who, address _where, bytes32 _what, uint256[] _how) internal view returns (bool) { - bytes4 sig = _oracleAddr.canPerform.selector; - - // a raw call is required so we can return false if the call reverts, rather than reverting - bytes memory checkCalldata = abi.encodeWithSelector(sig, _who, _where, _what, _how); - uint256 oracleCheckGas = ORACLE_CHECK_GAS; - - bool ok; - assembly { - ok := staticcall(oracleCheckGas, _oracleAddr, add(checkCalldata, 0x20), mload(checkCalldata), 0, 0) - } - - if (!ok) { - return false; - } - - uint256 size; - assembly { size := returndatasize } - if (size != 32) { - return false; - } - - bool result; - assembly { - let ptr := mload(0x40) // get next free memory ptr - returndatacopy(ptr, 0, size) // copy return from above `staticcall` - result := mload(ptr) // read data at ptr and set it to result - mstore(ptr, 0) // set pointer memory to 0 so it still is the next free ptr - } - - return result; - } - - /** - * @dev Internal function that sets management - */ - function _setPermissionManager(address _newManager, address _app, bytes32 _role) internal { - permissionManager[roleHash(_app, _role)] = _newManager; - emit ChangePermissionManager(_app, _role, _newManager); - } - - function roleHash(address _where, bytes32 _what) internal pure returns (bytes32) { - return keccak256(abi.encodePacked("ROLE", _where, _what)); - } - - function permissionHash(address _who, address _where, bytes32 _what) internal pure returns (bytes32) { - return keccak256(abi.encodePacked("PERMISSION", _who, _where, _what)); - } -} diff --git a/apps/shared/test-helpers/contracts/acl/ACLSyntaxSugar.sol b/apps/shared/test-helpers/contracts/acl/ACLSyntaxSugar.sol deleted file mode 100644 index 38ca29fdc..000000000 --- a/apps/shared/test-helpers/contracts/acl/ACLSyntaxSugar.sol +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -contract ACLSyntaxSugar { - function arr() internal pure returns (uint256[]) {} - - function arr(bytes32 _a) internal pure returns (uint256[] r) { - return arr(uint256(_a)); - } - - function arr(bytes32 _a, bytes32 _b) internal pure returns (uint256[] r) { - return arr(uint256(_a), uint256(_b)); - } - - function arr(address _a) internal pure returns (uint256[] r) { - return arr(uint256(_a)); - } - - function arr(address _a, address _b) internal pure returns (uint256[] r) { - return arr(uint256(_a), uint256(_b)); - } - - function arr(address _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) { - return arr(uint256(_a), _b, _c); - } - - function arr(address _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) { - return arr(uint256(_a), _b, _c, _d); - } - - function arr(address _a, uint256 _b) internal pure returns (uint256[] r) { - return arr(uint256(_a), uint256(_b)); - } - - function arr(address _a, address _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) { - return arr(uint256(_a), uint256(_b), _c, _d, _e); - } - - function arr(address _a, address _b, address _c) internal pure returns (uint256[] r) { - return arr(uint256(_a), uint256(_b), uint256(_c)); - } - - function arr(address _a, address _b, uint256 _c) internal pure returns (uint256[] r) { - return arr(uint256(_a), uint256(_b), uint256(_c)); - } - - function arr(uint256 _a) internal pure returns (uint256[] r) { - r = new uint256[](1); - r[0] = _a; - } - - function arr(uint256 _a, uint256 _b) internal pure returns (uint256[] r) { - r = new uint256[](2); - r[0] = _a; - r[1] = _b; - } - - function arr(uint256 _a, uint256 _b, uint256 _c) internal pure returns (uint256[] r) { - r = new uint256[](3); - r[0] = _a; - r[1] = _b; - r[2] = _c; - } - - function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d) internal pure returns (uint256[] r) { - r = new uint256[](4); - r[0] = _a; - r[1] = _b; - r[2] = _c; - r[3] = _d; - } - - function arr(uint256 _a, uint256 _b, uint256 _c, uint256 _d, uint256 _e) internal pure returns (uint256[] r) { - r = new uint256[](5); - r[0] = _a; - r[1] = _b; - r[2] = _c; - r[3] = _d; - r[4] = _e; - } -} - - -contract ACLHelpers { - function decodeParamOp(uint256 _x) internal pure returns (uint8 b) { - return uint8(_x >> (8 * 30)); - } - - function decodeParamId(uint256 _x) internal pure returns (uint8 b) { - return uint8(_x >> (8 * 31)); - } - - function decodeParamsList(uint256 _x) internal pure returns (uint32 a, uint32 b, uint32 c) { - a = uint32(_x); - b = uint32(_x >> (8 * 4)); - c = uint32(_x >> (8 * 8)); - } -} diff --git a/apps/shared/test-helpers/contracts/acl/IACL.sol b/apps/shared/test-helpers/contracts/acl/IACL.sol deleted file mode 100644 index cf2825113..000000000 --- a/apps/shared/test-helpers/contracts/acl/IACL.sol +++ /dev/null @@ -1,14 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -interface IACL { - function initialize(address permissionsCreator) external; - - // TODO: this should be external - // See https://github.com/ethereum/solidity/issues/4832 - function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool); -} diff --git a/apps/shared/test-helpers/contracts/acl/IACLOracle.sol b/apps/shared/test-helpers/contracts/acl/IACLOracle.sol deleted file mode 100644 index 802537f08..000000000 --- a/apps/shared/test-helpers/contracts/acl/IACLOracle.sol +++ /dev/null @@ -1,10 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -interface IACLOracle { - function canPerform(address who, address where, bytes32 what, uint256[] how) external view returns (bool); -} diff --git a/apps/shared/test-helpers/contracts/apm/APMNamehash.sol b/apps/shared/test-helpers/contracts/apm/APMNamehash.sol deleted file mode 100644 index adb0a2f4b..000000000 --- a/apps/shared/test-helpers/contracts/apm/APMNamehash.sol +++ /dev/null @@ -1,16 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "../ens/ENSConstants.sol"; - - -contract APMNamehash is ENSConstants { - bytes32 constant public APM_NODE = keccak256(abi.encodePacked(ETH_TLD_NODE, keccak256("aragonpm"))); - - function apmNamehash(string name) internal pure returns (bytes32) { - return keccak256(abi.encodePacked(APM_NODE, keccak256(bytes(name)))); - } -} diff --git a/apps/shared/test-helpers/contracts/apm/APMRegistry.sol b/apps/shared/test-helpers/contracts/apm/APMRegistry.sol deleted file mode 100644 index 50b7619f6..000000000 --- a/apps/shared/test-helpers/contracts/apm/APMRegistry.sol +++ /dev/null @@ -1,107 +0,0 @@ -pragma solidity 0.4.24; - -import "../lib/ens/AbstractENS.sol"; -import "../ens/ENSSubdomainRegistrar.sol"; -import "../factory/AppProxyFactory.sol"; -import "../apps/AragonApp.sol"; -import "../acl/ACL.sol"; -import "./Repo.sol"; - - -contract APMRegistryConstants { - // Cant have a regular APM appId because it is used to build APM - // TODO: recheck this - string constant public APM_APP_NAME = "apm-registry"; - string constant public REPO_APP_NAME = "apm-repo"; - string constant public ENS_SUB_APP_NAME = "apm-enssub"; -} - - -contract APMRegistry is AragonApp, AppProxyFactory, APMRegistryConstants { - AbstractENS public ens; - ENSSubdomainRegistrar public registrar; - - // bytes32 constant public CREATE_REPO_ROLE = keccak256("CREATE_REPO_ROLE"); - bytes32 constant public CREATE_REPO_ROLE = 0x2a9494d64846c9fdbf0158785aa330d8bc9caf45af27fa0e8898eb4d55adcea6; - - event NewRepo(bytes32 id, string name, address repo); - - /** - * NEEDS CREATE_NAME_ROLE and POINT_ROOTNODE_ROLE permissions on registrar - * @param _registrar ENSSubdomainRegistrar instance that holds registry root node ownership - */ - function initialize(ENSSubdomainRegistrar _registrar) public onlyInit { - initialized(); - - registrar = _registrar; - ens = registrar.ens(); - - registrar.pointRootNode(this); - - // Check APM has all permissions it needss - ACL acl = ACL(kernel().acl()); - require(acl.hasPermission(this, registrar, registrar.CREATE_NAME_ROLE())); - require(acl.hasPermission(this, acl, acl.CREATE_PERMISSIONS_ROLE())); - } - - /** - * @notice Create new repo in registry with `_name` - * @param _name Repo name, must be ununsed - * @param _dev Address that will be given permission to create versions - */ - function newRepo(string _name, address _dev) public auth(CREATE_REPO_ROLE) returns (Repo) { - return _newRepo(_name, _dev); - } - - /** - * @notice Create new repo in registry with `_name` and first repo version - * @param _name Repo name - * @param _dev Address that will be given permission to create versions - * @param _initialSemanticVersion Semantic version for new repo version - * @param _contractAddress address for smart contract logic for version (if set to 0, it uses last versions' contractAddress) - * @param _contentURI External URI for fetching new version's content - */ - function newRepoWithVersion( - string _name, - address _dev, - uint16[3] _initialSemanticVersion, - address _contractAddress, - bytes _contentURI - ) public auth(CREATE_REPO_ROLE) returns (Repo) - { - Repo repo = _newRepo(_name, this); // need to have permissions to create version - repo.newVersion(_initialSemanticVersion, _contractAddress, _contentURI); - - // Give permissions to _dev - ACL acl = ACL(kernel().acl()); - acl.revokePermission(this, repo, repo.CREATE_VERSION_ROLE()); - acl.grantPermission(_dev, repo, repo.CREATE_VERSION_ROLE()); - acl.setPermissionManager(_dev, repo, repo.CREATE_VERSION_ROLE()); - return repo; - } - - function _newRepo(string _name, address _dev) internal returns (Repo) { - require(bytes(_name).length > 0); - - Repo repo = newClonedRepo(); - - ACL(kernel().acl()).createPermission(_dev, repo, repo.CREATE_VERSION_ROLE(), _dev); - - // Creates [name] subdomain in the rootNode and sets registry as resolver - // This will fail if repo name already exists - bytes32 node = registrar.createNameAndPoint(keccak256(abi.encodePacked(_name)), repo); - - emit NewRepo(node, _name, repo); - - return repo; - } - - function newClonedRepo() internal returns (Repo repo) { - repo = Repo(newAppProxy(kernel(), repoAppId())); - repo.initialize(); - } - - function repoAppId() internal view returns (bytes32) { - return keccak256(abi.encodePacked(registrar.rootNode(), keccak256(abi.encodePacked(REPO_APP_NAME)))); - } -} diff --git a/apps/shared/test-helpers/contracts/apm/Repo.sol b/apps/shared/test-helpers/contracts/apm/Repo.sol deleted file mode 100644 index a3c43da85..000000000 --- a/apps/shared/test-helpers/contracts/apm/Repo.sol +++ /dev/null @@ -1,119 +0,0 @@ -pragma solidity 0.4.24; - -import "../apps/AragonApp.sol"; - - -/* solium-disable function-order */ -// Allow public initialize() to be first -contract Repo is AragonApp { - struct Version { - uint16[3] semanticVersion; - address contractAddress; - bytes contentURI; - } - - Version[] public versions; - mapping (bytes32 => uint256) internal versionIdForSemantic; - mapping (address => uint256) internal latestVersionIdForContract; - - // bytes32 constant public CREATE_VERSION_ROLE = keccak256("CREATE_VERSION_ROLE"); - bytes32 constant public CREATE_VERSION_ROLE = 0x1f56cfecd3595a2e6cc1a7e6cb0b20df84cdbd92eff2fee554e70e4e45a9a7d8; - - event NewVersion(uint256 versionId, uint16[3] semanticVersion); - - /** - * @dev Initialize can only be called once. It saves the block number in which it was initialized. - * @notice Initializes a Repo to be usable - */ - function initialize() public onlyInit { - initialized(); - } - - /** - * @notice Create new version for repo - * @param _newSemanticVersion Semantic version for new repo version - * @param _contractAddress address for smart contract logic for version (if set to 0, it uses last versions' contractAddress) - * @param _contentURI External URI for fetching new version's content - */ - function newVersion( - uint16[3] _newSemanticVersion, - address _contractAddress, - bytes _contentURI - ) public auth(CREATE_VERSION_ROLE) - { - address contractAddress = _contractAddress; - if (versions.length > 0) { - Version storage lastVersion = versions[versions.length - 1]; - require(isValidBump(lastVersion.semanticVersion, _newSemanticVersion)); - if (contractAddress == 0) { - contractAddress = lastVersion.contractAddress; - } - // Only allows smart contract change on major version bumps - require(lastVersion.contractAddress == contractAddress || _newSemanticVersion[0] > lastVersion.semanticVersion[0]); - } else { - versions.length += 1; - uint16[3] memory zeroVersion; - require(isValidBump(zeroVersion, _newSemanticVersion)); - } - - uint versionId = versions.push(Version(_newSemanticVersion, contractAddress, _contentURI)) - 1; - versionIdForSemantic[semanticVersionHash(_newSemanticVersion)] = versionId; - latestVersionIdForContract[contractAddress] = versionId; - - emit NewVersion(versionId, _newSemanticVersion); - } - - function getLatest() public view returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) { - return getByVersionId(versions.length - 1); - } - - function getLatestForContractAddress(address _contractAddress) - public - view - returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) - { - return getByVersionId(latestVersionIdForContract[_contractAddress]); - } - - function getBySemanticVersion(uint16[3] _semanticVersion) - public - view - returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) - { - return getByVersionId(versionIdForSemantic[semanticVersionHash(_semanticVersion)]); - } - - function getByVersionId(uint _versionId) public view returns (uint16[3] semanticVersion, address contractAddress, bytes contentURI) { - require(_versionId > 0); - Version storage version = versions[_versionId]; - return (version.semanticVersion, version.contractAddress, version.contentURI); - } - - function getVersionsCount() public view returns (uint256) { - uint256 len = versions.length; - return len > 0 ? len - 1 : 0; - } - - function isValidBump(uint16[3] _oldVersion, uint16[3] _newVersion) public pure returns (bool) { - bool hasBumped; - uint i = 0; - while (i < 3) { - if (hasBumped) { - if (_newVersion[i] != 0) { - return false; - } - } else if (_newVersion[i] != _oldVersion[i]) { - if (_oldVersion[i] > _newVersion[i] || _newVersion[i] - _oldVersion[i] != 1) { - return false; - } - hasBumped = true; - } - i++; - } - return hasBumped; - } - - function semanticVersionHash(uint16[3] version) internal pure returns (bytes32) { - return keccak256(abi.encodePacked(version[0], version[1], version[2])); - } -} diff --git a/apps/shared/test-helpers/contracts/apps/AppProxyBase.sol b/apps/shared/test-helpers/contracts/apps/AppProxyBase.sol deleted file mode 100644 index 0f94cd0e2..000000000 --- a/apps/shared/test-helpers/contracts/apps/AppProxyBase.sol +++ /dev/null @@ -1,38 +0,0 @@ -pragma solidity 0.4.24; - -import "./AppStorage.sol"; -import "../common/DepositableDelegateProxy.sol"; -import "../kernel/KernelConstants.sol"; -import "../kernel/IKernel.sol"; - - -contract AppProxyBase is AppStorage, DepositableDelegateProxy, KernelNamespaceConstants { - /** - * @dev Initialize AppProxy - * @param _kernel Reference to organization kernel for the app - * @param _appId Identifier for app - * @param _initializePayload Payload for call to be made after setup to initialize - */ - constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public { - setKernel(_kernel); - setAppId(_appId); - - // Implicit check that kernel is actually a Kernel - // The EVM doesn't actually provide a way for us to make sure, but we can force a revert to - // occur if the kernel is set to 0x0 or a non-code address when we try to call a method on - // it. - address appCode = getAppBase(_appId); - - // If initialize payload is provided, it will be executed - if (_initializePayload.length > 0) { - require(isContract(appCode)); - // Cannot make delegatecall as a delegateproxy.delegatedFwd as it - // returns ending execution context and halts contract deployment - require(appCode.delegatecall(_initializePayload)); - } - } - - function getAppBase(bytes32 _appId) internal view returns (address) { - return kernel().getApp(KERNEL_APP_BASES_NAMESPACE, _appId); - } -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/apps/AppProxyPinned.sol b/apps/shared/test-helpers/contracts/apps/AppProxyPinned.sol deleted file mode 100644 index 49a09ca05..000000000 --- a/apps/shared/test-helpers/contracts/apps/AppProxyPinned.sol +++ /dev/null @@ -1,49 +0,0 @@ -pragma solidity 0.4.24; - -import "../common/UnstructuredStorage.sol"; -import "../common/IsContract.sol"; -import "./AppProxyBase.sol"; - - -contract AppProxyPinned is IsContract, AppProxyBase { - using UnstructuredStorage for bytes32; - - // keccak256("aragonOS.appStorage.pinnedCode"), used by Proxy Pinned - bytes32 internal constant PINNED_CODE_POSITION = 0xdee64df20d65e53d7f51cb6ab6d921a0a6a638a91e942e1d8d02df28e31c038e; - - /** - * @dev Initialize AppProxyPinned (makes it an un-upgradeable Aragon app) - * @param _kernel Reference to organization kernel for the app - * @param _appId Identifier for app - * @param _initializePayload Payload for call to be made after setup to initialize - */ - constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload) - AppProxyBase(_kernel, _appId, _initializePayload) - public // solium-disable-line visibility-first - { - setPinnedCode(getAppBase(_appId)); - require(isContract(pinnedCode())); - } - - /** - * @dev ERC897, the address the proxy would delegate calls to - */ - function implementation() public view returns (address) { - return pinnedCode(); - } - - /** - * @dev ERC897, whether it is a forwarding (1) or an upgradeable (2) proxy - */ - function proxyType() public pure returns (uint256 proxyTypeId) { - return FORWARDING; - } - - function setPinnedCode(address _pinnedCode) internal { - PINNED_CODE_POSITION.setStorageAddress(_pinnedCode); - } - - function pinnedCode() internal view returns (address) { - return PINNED_CODE_POSITION.getStorageAddress(); - } -} diff --git a/apps/shared/test-helpers/contracts/apps/AppProxyUpgradeable.sol b/apps/shared/test-helpers/contracts/apps/AppProxyUpgradeable.sol deleted file mode 100644 index 60d4cfa0c..000000000 --- a/apps/shared/test-helpers/contracts/apps/AppProxyUpgradeable.sol +++ /dev/null @@ -1,33 +0,0 @@ -pragma solidity 0.4.24; - -import "./AppProxyBase.sol"; - - -contract AppProxyUpgradeable is AppProxyBase { - /** - * @dev Initialize AppProxyUpgradeable (makes it an upgradeable Aragon app) - * @param _kernel Reference to organization kernel for the app - * @param _appId Identifier for app - * @param _initializePayload Payload for call to be made after setup to initialize - */ - constructor(IKernel _kernel, bytes32 _appId, bytes _initializePayload) - AppProxyBase(_kernel, _appId, _initializePayload) - public // solium-disable-line visibility-first - { - - } - - /** - * @dev ERC897, the address the proxy would delegate calls to - */ - function implementation() public view returns (address) { - return getAppBase(appId()); - } - - /** - * @dev ERC897, whether it is a forwarding (1) or an upgradeable (2) proxy - */ - function proxyType() public pure returns (uint256 proxyTypeId) { - return UPGRADEABLE; - } -} diff --git a/apps/shared/test-helpers/contracts/apps/AppStorage.sol b/apps/shared/test-helpers/contracts/apps/AppStorage.sol deleted file mode 100644 index aedb59f7a..000000000 --- a/apps/shared/test-helpers/contracts/apps/AppStorage.sol +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "../common/UnstructuredStorage.sol"; -import "../kernel/IKernel.sol"; - - -contract AppStorage { - using UnstructuredStorage for bytes32; - - // keccak256("aragonOS.appStorage.kernel") - bytes32 internal constant KERNEL_POSITION = 0x4172f0f7d2289153072b0a6ca36959e0cbe2efc3afe50fc81636caa96338137b; - // keccak256("aragonOS.appStorage.appId") - bytes32 internal constant APP_ID_POSITION = 0xd625496217aa6a3453eecb9c3489dc5a53e6c67b444329ea2b2cbc9ff547639b; - // keccak256("aragonOS.appStorage.pinnedCode"), used by Proxy Pinned - bytes32 internal constant PINNED_CODE_POSITION = 0xdee64df20d65e53d7f51cb6ab6d921a0a6a638a91e942e1d8d02df28e31c038e; - - function kernel() public view returns (IKernel) { - return IKernel(KERNEL_POSITION.getStorageAddress()); - } - - function appId() public view returns (bytes32) { - return APP_ID_POSITION.getStorageBytes32(); - } - - function setKernel(IKernel _kernel) internal { - KERNEL_POSITION.setStorageAddress(address(_kernel)); - } - - function setAppId(bytes32 _appId) internal { - APP_ID_POSITION.setStorageBytes32(_appId); - } -} diff --git a/apps/shared/test-helpers/contracts/apps/AragonApp.sol b/apps/shared/test-helpers/contracts/apps/AragonApp.sol deleted file mode 100644 index a3339a210..000000000 --- a/apps/shared/test-helpers/contracts/apps/AragonApp.sol +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "./AppStorage.sol"; -import "../common/Autopetrified.sol"; -import "../common/VaultRecoverable.sol"; -import "../evmscript/EVMScriptRunner.sol"; -import "../acl/ACLSyntaxSugar.sol"; - - -// Contracts inheriting from AragonApp are, by default, immediately petrified upon deployment so -// that they can never be initialized. -// Unless overriden, this behaviour enforces those contracts to be usable only behind an AppProxy. -// ACLSyntaxSugar and EVMScriptRunner are not directly used by this contract, but are included so -// that they are automatically usable by subclassing contracts -contract AragonApp is AppStorage, Autopetrified, VaultRecoverable, EVMScriptRunner, ACLSyntaxSugar { - modifier auth(bytes32 _role) { - require(canPerform(msg.sender, _role, new uint256[](0))); - _; - } - - modifier authP(bytes32 _role, uint256[] _params) { - require(canPerform(msg.sender, _role, _params)); - _; - } - - /** - * @dev Check whether an action can be performed by a sender for a particular role on this app - * @param _sender Sender of the call - * @param _role Role on this app - * @param _params Permission params for the role - * @return Boolean indicating whether the sender has the permissions to perform the action. - * Always returns false if the app hasn't been initialized yet. - */ - function canPerform(address _sender, bytes32 _role, uint256[] _params) public view returns (bool) { - if (!hasInitialized()) { - return false; - } - - IKernel linkedKernel = kernel(); - if (address(linkedKernel) == address(0)) { - return false; - } - - bytes memory how; // no need to init memory as it is never used - if (_params.length > 0) { - uint256 byteLength = _params.length * 32; - assembly { - how := _params // forced casting - mstore(how, byteLength) - } - } - return linkedKernel.hasPermission(_sender, address(this), _role, how); - } - - /** - * @dev Get the recovery vault for the app - * @return Recovery vault address for the app - */ - function getRecoveryVault() public view returns (address) { - // Funds recovery via a vault is only available when used with a kernel - require(address(kernel()) != address(0)); - return kernel().getRecoveryVault(); - } -} diff --git a/apps/shared/test-helpers/contracts/apps/UnsafeAragonApp.sol b/apps/shared/test-helpers/contracts/apps/UnsafeAragonApp.sol deleted file mode 100644 index 7e46b7a65..000000000 --- a/apps/shared/test-helpers/contracts/apps/UnsafeAragonApp.sol +++ /dev/null @@ -1,24 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "../common/UnstructuredStorage.sol"; -import "./AragonApp.sol"; - - -// Using UnsafeAragonApp means you'll be playing with 🔥. -// A number of safe defaults are provided with AragonApp, to help you avoid dangerous situations -// and mistakes with how your contract's developed as well as how it's deployed. -// UnsafeAragonApp turns off these safety features to give you greater control over your contract. -// In particular, it allows you to: -// - Use deployed base contracts as apps directly, without a proxy -contract UnsafeAragonApp is AragonApp { - using UnstructuredStorage for bytes32; - - constructor() public { - // Removes auto petrifying; simulates a delete at INITIALIZATION_BLOCK_POSITION - INITIALIZATION_BLOCK_POSITION.setStorageUint256(0); - } -} diff --git a/apps/shared/test-helpers/contracts/apps/Voting.sol b/apps/shared/test-helpers/contracts/apps/Voting.sol deleted file mode 100644 index b0ee97557..000000000 --- a/apps/shared/test-helpers/contracts/apps/Voting.sol +++ /dev/null @@ -1,349 +0,0 @@ -/* - * SPDX-License-Identitifer: GPL-3.0-or-later - */ - -pragma solidity 0.4.24; - -import "./AragonApp.sol"; -import "../common/IForwarder.sol"; - -import "../lib/math/SafeMath.sol"; -import "../lib/math/SafeMath64.sol"; - -import "../lib/minime/MiniMeToken.sol"; - - -contract Voting is IForwarder, AragonApp { - using SafeMath for uint256; - using SafeMath64 for uint64; - - bytes32 public constant ROLE_CREATE_VOTES = keccak256("ROLE_CREATE_VOTES"); - bytes32 public constant MODIFY_SUPPORT_ROLE = keccak256("MODIFY_SUPPORT_ROLE"); - bytes32 public constant ROLE_MODIFY_QUORUM_ROLE = keccak256("ROLE_MODIFY_QUORUM_ROLE"); - - uint256 public constant PCT_BASE = 10 ** 18; // 0% = 0; 1% = 10^16; 100% = 10^18 - - enum VoterState { Absent, Yea, Nay } - - struct Vote { - address creator; - uint64 startDate; - uint256 snapshotBlock; - uint256 supportRequiredPct; - uint256 minAcceptQuorumPct; - uint256 yea; - uint256 nay; - uint256 totalVoters; - string metadata; - bytes executionScript; - bool executed; - mapping (address => VoterState) voters; - } - - MiniMeToken public token; - uint256 public supportRequiredPct; - uint256 public minAcceptQuorumPct; - uint64 public voteTime; - - // We are mimicing an array, we use a mapping instead to make app upgrade more graceful - mapping (uint256 => Vote) internal votes; - uint256 public votesLength; - - event StartVote(uint256 indexed voteId); - event CastVote(uint256 indexed voteId, address indexed voter, bool supports, uint256 stake); - event ExecuteVote(uint256 indexed voteId); - event ChangeSupportRequired(uint256 supportRequiredPct); - event ChangeMinQuorum(uint256 minAcceptQuorumPct); - - modifier voteExists(uint256 _voteId) { - require(_voteId < votesLength); - _; - } - - /** - * @notice Initializes Voting app with `_token.symbol(): string` for governance, minimum support of `(_supportRequiredPct - _supportRequiredPct % 10^16) / 10^14`, minimum acceptance quorum of `(_minAcceptQuorumPct - _minAcceptQuorumPct % 10^16) / 10^14` and vote duations of `(_voteTime - _voteTime % 86400) / 86400` day `_voteTime >= 172800 ? 's' : ''` - * @param _token MiniMeToken Address that will be used as governance token - * @param _supportRequiredPct Percentage of yeas in casted votes for a vote to succeed (expressed as a percentage of 10^18; eg. 10^16 = 1%, 10^18 = 100%) - * @param _minAcceptQuorumPct Percentage of yeas in total possible votes for a vote to succeed (expressed as a percentage of 10^18; eg. 10^16 = 1%, 10^18 = 100%) - * @param _voteTime Seconds that a vote will be open for token holders to vote (unless enough yeas or nays have been cast to make an early decision) - */ - function initialize( - MiniMeToken _token, - uint256 _supportRequiredPct, - uint256 _minAcceptQuorumPct, - uint64 _voteTime - ) - external - onlyInit - { - initialized(); - - require(_minAcceptQuorumPct <= _supportRequiredPct); - require(_supportRequiredPct < PCT_BASE); - - token = _token; - supportRequiredPct = _supportRequiredPct; - minAcceptQuorumPct = _minAcceptQuorumPct; - voteTime = _voteTime; - } - - /** - * @notice Change required support to `(_supportRequiredPct - _supportRequiredPct % 10^16) / 10^14`% - * @param _supportRequiredPct New required support - */ - function changeSupportRequiredPct(uint256 _supportRequiredPct) - external - authP(MODIFY_SUPPORT_ROLE, arr(_supportRequiredPct, supportRequiredPct)) - { - require(minAcceptQuorumPct <= _supportRequiredPct); - require(_supportRequiredPct < PCT_BASE); - supportRequiredPct = _supportRequiredPct; - - emit ChangeSupportRequired(_supportRequiredPct); - } - - /** - * @notice Change minimum acceptance quorum to `(_minAcceptQuorumPct - _minAcceptQuorumPct % 10^16) / 10^14`% - * @param _minAcceptQuorumPct New acceptance quorum - */ - function changeMinAcceptQuorumPct(uint256 _minAcceptQuorumPct) - external - authP(ROLE_MODIFY_QUORUM_ROLE, arr(_minAcceptQuorumPct, minAcceptQuorumPct)) - { - require(_minAcceptQuorumPct <= supportRequiredPct); - minAcceptQuorumPct = _minAcceptQuorumPct; - - emit ChangeMinQuorum(_minAcceptQuorumPct); - } - - /** - * @notice Create a new vote about "`_metadata`" - * @param _executionScript EVM script to be executed on approval - * @param _metadata Vote metadata - * @return voteId Id for newly created vote - */ - function newVote(bytes _executionScript, string _metadata) external auth(ROLE_CREATE_VOTES) returns (uint256 voteId) { - return _newVote(_executionScript, _metadata, true, true); - } - - /** - * @notice Create a new vote about "`_metadata`" - * @param _executionScript EVM script to be executed on approval - * @param _metadata Vote metadata - * @param _castVote Whether to also cast newly created vote - * @param _executesIfDecided Whether to also immediately execute newly created vote if decided - * @return voteId id for newly created vote - */ - function newVote(bytes _executionScript, string _metadata, bool _castVote, bool _executesIfDecided) - external - auth(ROLE_CREATE_VOTES) - returns (uint256 voteId) - { - return _newVote(_executionScript, _metadata, _castVote, _executesIfDecided); - } - - /** - * @notice Vote `_supports ? 'yea' : 'nay'` in vote #`_voteId` - * @dev Initialization check is implicitly provided by `voteExists()` as new votes can only be - * created via `newVote(),` which requires initialization - * @param _voteId Id for vote - * @param _supports Whether voter supports the vote - * @param _executesIfDecided Whether the vote should execute its action if it becomes decided - */ - function vote(uint256 _voteId, bool _supports, bool _executesIfDecided) external voteExists(_voteId) { - require(canVote(_voteId, msg.sender)); - _vote(_voteId, _supports, msg.sender, _executesIfDecided); - } - - /** - * @notice Execute the result of dot vote #`_voteId` - * @dev Initialization check is implicitly provided by `voteExists()` as new votes can only be - * created via `newVote(),` which requires initialization - * @param _voteId Id for vote - */ - function executeVote(uint256 _voteId) external voteExists(_voteId) { - require(canExecute(_voteId)); - _executeVote(_voteId); - } - - function isForwarder() public pure returns (bool) { - return true; - } - - /** - * @notice Creates a vote to execute the desired action - * @dev IForwarder interface conformance - * @param _evmScript Start vote with script - */ - function forward(bytes _evmScript) public { - require(canForward(msg.sender, _evmScript)); - _newVote(_evmScript, "", true, true); - } - - function canForward(address _sender, bytes) public view returns (bool) { - // Note that `canPerform()` implicitly does an initialization check itself - return canPerform(_sender, ROLE_CREATE_VOTES, arr()); - } - - function canVote(uint256 _voteId, address _voter) public view voteExists(_voteId) returns (bool) { - Vote storage vote_ = votes[_voteId]; - - return _isVoteOpen(vote_) && token.balanceOfAt(_voter, vote_.snapshotBlock) > 0; - } - - function canExecute(uint256 _voteId) public view voteExists(_voteId) returns (bool) { - Vote storage vote_ = votes[_voteId]; - - if (vote_.executed) { - return false; - } - - // Voting is already decided - if (_isValuePct(vote_.yea, vote_.totalVoters, vote_.supportRequiredPct)) { - return true; - } - - uint256 totalVotes = vote_.yea.add(vote_.nay); - - // Vote ended? - if (_isVoteOpen(vote_)) { - return false; - } - // Has enough support? - if (!_isValuePct(vote_.yea, totalVotes, vote_.supportRequiredPct)) { - return false; - } - // Has min quorum? - if (!_isValuePct(vote_.yea, vote_.totalVoters, vote_.minAcceptQuorumPct)) { - return false; - } - - return true; - } - - function getVote(uint256 _voteId) - public - view - voteExists(_voteId) - returns ( - bool open, - bool executed, - address creator, - uint64 startDate, - uint256 snapshotBlock, - uint256 supportRequired, - uint256 minAcceptQuorum, - uint256 yea, - uint256 nay, - uint256 totalVoters, - bytes script - ) - { - Vote storage vote_ = votes[_voteId]; - - open = _isVoteOpen(vote_); - executed = vote_.executed; - creator = vote_.creator; - startDate = vote_.startDate; - snapshotBlock = vote_.snapshotBlock; - supportRequired = vote_.supportRequiredPct; - minAcceptQuorum = vote_.minAcceptQuorumPct; - yea = vote_.yea; - nay = vote_.nay; - totalVoters = vote_.totalVoters; - script = vote_.executionScript; - } - - function getVoteMetadata(uint256 _voteId) public view voteExists(_voteId) returns (string) { - return votes[_voteId].metadata; - } - - function getVoterState(uint256 _voteId, address _voter) public view voteExists(_voteId) returns (VoterState) { - return votes[_voteId].voters[_voter]; - } - - function _newVote(bytes _executionScript, string _metadata, bool _castVote, bool _executesIfDecided) - internal - returns (uint256 voteId) - { - voteId = votesLength++; - Vote storage vote_ = votes[voteId]; - vote_.executionScript = _executionScript; - vote_.creator = msg.sender; - vote_.startDate = getTimestamp64(); - vote_.metadata = _metadata; - vote_.snapshotBlock = getBlockNumber() - 1; // avoid double voting in this very block - vote_.totalVoters = token.totalSupplyAt(vote_.snapshotBlock); - vote_.supportRequiredPct = supportRequiredPct; - vote_.minAcceptQuorumPct = minAcceptQuorumPct; - - emit StartVote(voteId); - - if (_castVote && canVote(voteId, msg.sender)) { - _vote(voteId, true, msg.sender, _executesIfDecided); - } - } - - function _vote( - uint256 _voteId, - bool _supports, - address _voter, - bool _executesIfDecided - ) internal - { - Vote storage vote_ = votes[_voteId]; - - // This could re-enter, though we can assume the governance token is not malicious - uint256 voterStake = token.balanceOfAt(_voter, vote_.snapshotBlock); - VoterState state = vote_.voters[_voter]; - - // If voter had previously voted, decrease count - if (state == VoterState.Yea) { - vote_.yea = vote_.yea.sub(voterStake); - } else if (state == VoterState.Nay) { - vote_.nay = vote_.nay.sub(voterStake); - } - - if (_supports) { - vote_.yea = vote_.yea.add(voterStake); - } else { - vote_.nay = vote_.nay.add(voterStake); - } - - vote_.voters[_voter] = _supports ? VoterState.Yea : VoterState.Nay; - - emit CastVote(_voteId, _voter, _supports, voterStake); - - if (_executesIfDecided && canExecute(_voteId)) { - _executeVote(_voteId); - } - } - - function _executeVote(uint256 _voteId) internal { - Vote storage vote_ = votes[_voteId]; - - vote_.executed = true; - - bytes memory input = new bytes(0); // TODO: Consider input for voting scripts - runScript(vote_.executionScript, input, new address[](0)); - - emit ExecuteVote(_voteId); - } - - function _isVoteOpen(Vote storage vote_) internal view returns (bool) { - return getTimestamp64() < vote_.startDate.add(voteTime) && !vote_.executed; - } - - /** - * @dev Calculates whether `_value` is more than a percentage `_pct` of `_total` - */ - function _isValuePct(uint256 _value, uint256 _total, uint256 _pct) internal pure returns (bool) { - if (_total == 0) { - return false; - } - - uint256 computedPct = _value.mul(PCT_BASE) / _total; - - return computedPct > _pct; - } -} diff --git a/apps/shared/test-helpers/contracts/apps/readme.md b/apps/shared/test-helpers/contracts/apps/readme.md deleted file mode 100644 index 9a858af52..000000000 --- a/apps/shared/test-helpers/contracts/apps/readme.md +++ /dev/null @@ -1,3 +0,0 @@ -# Aragon apps - -Aragon default apps have been moved to their own repository: [aragon-apps](https://github.com/aragon/aragon-apps) diff --git a/apps/shared/test-helpers/contracts/common/Autopetrified.sol b/apps/shared/test-helpers/contracts/common/Autopetrified.sol deleted file mode 100644 index 1224319d5..000000000 --- a/apps/shared/test-helpers/contracts/common/Autopetrified.sol +++ /dev/null @@ -1,16 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "./Petrifiable.sol"; - - -contract Autopetrified is Petrifiable { - constructor() public { - // Immediately petrify base (non-proxy) instances of inherited contracts on deploy. - // This renders them uninitializable (and unusable without a proxy). - petrify(); - } -} diff --git a/apps/shared/test-helpers/contracts/common/DelegateProxy.sol b/apps/shared/test-helpers/contracts/common/DelegateProxy.sol deleted file mode 100644 index 729117a05..000000000 --- a/apps/shared/test-helpers/contracts/common/DelegateProxy.sol +++ /dev/null @@ -1,31 +0,0 @@ -pragma solidity 0.4.24; - -import "../common/IsContract.sol"; -import "../lib/misc/ERCProxy.sol"; - - -contract DelegateProxy is ERCProxy, IsContract { - uint256 constant public FWD_GAS_LIMIT = 10000; - - /** - * @dev Performs a delegatecall and returns whatever the delegatecall returned (entire context execution will return!) - * @param _dst Destination address to perform the delegatecall - * @param _calldata Calldata for the delegatecall - */ - function delegatedFwd(address _dst, bytes _calldata) internal { - require(isContract(_dst)); - uint256 fwdGasLimit = FWD_GAS_LIMIT; - - assembly { - let result := delegatecall(sub(gas, fwdGasLimit), _dst, add(_calldata, 0x20), mload(_calldata), 0, 0) - let size := returndatasize - let ptr := mload(0x40) - returndatacopy(ptr, 0, size) - - // revert instead of invalid() bc if the underlying call failed with invalid() it already wasted gas. - // if the call returned error data, forward it - switch result case 0 { revert(ptr, size) } - default { return(ptr, size) } - } - } -} diff --git a/apps/shared/test-helpers/contracts/common/DepositableDelegateProxy.sol b/apps/shared/test-helpers/contracts/common/DepositableDelegateProxy.sol deleted file mode 100644 index eda7ca5a7..000000000 --- a/apps/shared/test-helpers/contracts/common/DepositableDelegateProxy.sol +++ /dev/null @@ -1,21 +0,0 @@ -pragma solidity 0.4.24; - -import "./DelegateProxy.sol"; -import "./DepositableStorage.sol"; - - -contract DepositableDelegateProxy is DepositableStorage, DelegateProxy { - event ProxyDeposit(address sender, uint256 value); - - function () external payable { - // send / transfer - if (gasleft() < FWD_GAS_LIMIT) { - require(msg.value > 0 && msg.data.length == 0); - require(isDepositable()); - emit ProxyDeposit(msg.sender, msg.value); - } else { // all calls except for send or transfer - address target = implementation(); - delegatedFwd(target, msg.data); - } - } -} diff --git a/apps/shared/test-helpers/contracts/common/DepositableStorage.sol b/apps/shared/test-helpers/contracts/common/DepositableStorage.sol deleted file mode 100644 index 9b9970de3..000000000 --- a/apps/shared/test-helpers/contracts/common/DepositableStorage.sol +++ /dev/null @@ -1,19 +0,0 @@ -pragma solidity 0.4.24; - -import "./UnstructuredStorage.sol"; - - -contract DepositableStorage { - using UnstructuredStorage for bytes32; - - // keccak256("aragonOS.depositableStorage.depositable") - bytes32 internal constant DEPOSITABLE_POSITION = 0x665fd576fbbe6f247aff98f5c94a561e3f71ec2d3c988d56f12d342396c50cea; - - function isDepositable() public view returns (bool) { - return DEPOSITABLE_POSITION.getStorageBool(); - } - - function setDepositable(bool _depositable) internal { - DEPOSITABLE_POSITION.setStorageBool(_depositable); - } -} diff --git a/apps/shared/test-helpers/contracts/common/EtherTokenConstant.sol b/apps/shared/test-helpers/contracts/common/EtherTokenConstant.sol deleted file mode 100644 index 120c3a981..000000000 --- a/apps/shared/test-helpers/contracts/common/EtherTokenConstant.sol +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -// aragonOS and aragon-apps rely on address(0) to denote native ETH, in -// contracts where both tokens and ETH are accepted -contract EtherTokenConstant { - address constant public ETH = address(0); -} diff --git a/apps/shared/test-helpers/contracts/common/IForwarder.sol b/apps/shared/test-helpers/contracts/common/IForwarder.sol deleted file mode 100644 index 5876f465d..000000000 --- a/apps/shared/test-helpers/contracts/common/IForwarder.sol +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -interface IForwarder { - function isForwarder() external pure returns (bool); - - // TODO: this should be external - // See https://github.com/ethereum/solidity/issues/4832 - function canForward(address sender, bytes evmCallScript) public view returns (bool); - - // TODO: this should be external - // See https://github.com/ethereum/solidity/issues/4832 - function forward(bytes evmCallScript) public; -} diff --git a/apps/shared/test-helpers/contracts/common/IVaultRecoverable.sol b/apps/shared/test-helpers/contracts/common/IVaultRecoverable.sol deleted file mode 100644 index f747b9a0f..000000000 --- a/apps/shared/test-helpers/contracts/common/IVaultRecoverable.sol +++ /dev/null @@ -1,13 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -interface IVaultRecoverable { - function transferToVault(address token) external; - - function allowRecoverability(address token) external view returns (bool); - function getRecoveryVault() external view returns (address); -} diff --git a/apps/shared/test-helpers/contracts/common/Initializable.sol b/apps/shared/test-helpers/contracts/common/Initializable.sol deleted file mode 100644 index 6e6fad3e0..000000000 --- a/apps/shared/test-helpers/contracts/common/Initializable.sol +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "./UnstructuredStorage.sol"; -import "../common/TimeHelpers.sol"; - - -contract Initializable is TimeHelpers { - using UnstructuredStorage for bytes32; - - // keccak256("aragonOS.initializable.initializationBlock") - bytes32 internal constant INITIALIZATION_BLOCK_POSITION = 0xebb05b386a8d34882b8711d156f463690983dc47815980fb82aeeff1aa43579e; - - modifier onlyInit { - require(getInitializationBlock() == 0); - _; - } - - modifier isInitialized { - require(hasInitialized()); - _; - } - - /** - * @return Block number in which the contract was initialized - */ - function getInitializationBlock() public view returns (uint256) { - return INITIALIZATION_BLOCK_POSITION.getStorageUint256(); - } - - /** - * @return Whether the contract has been initialized by the time of the current block - */ - function hasInitialized() public view returns (bool) { - uint256 initializationBlock = getInitializationBlock(); - return initializationBlock != 0 && getBlockNumber() >= initializationBlock; - } - - /** - * @dev Function to be called by top level contract after initialization has finished. - */ - function initialized() internal onlyInit { - INITIALIZATION_BLOCK_POSITION.setStorageUint256(getBlockNumber()); - } - - /** - * @dev Function to be called by top level contract after initialization to enable the contract - * at a future block number rather than immediately. - */ - function initializedAt(uint256 _blockNumber) internal onlyInit { - INITIALIZATION_BLOCK_POSITION.setStorageUint256(_blockNumber); - } -} diff --git a/apps/shared/test-helpers/contracts/common/IsContract.sol b/apps/shared/test-helpers/contracts/common/IsContract.sol deleted file mode 100644 index 64eda8577..000000000 --- a/apps/shared/test-helpers/contracts/common/IsContract.sol +++ /dev/null @@ -1,18 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -contract IsContract { - function isContract(address _target) internal view returns (bool) { - if (_target == address(0)) { - return false; - } - - uint256 size; - assembly { size := extcodesize(_target) } - return size > 0; - } -} diff --git a/apps/shared/test-helpers/contracts/common/Petrifiable.sol b/apps/shared/test-helpers/contracts/common/Petrifiable.sol deleted file mode 100644 index 7c46f9618..000000000 --- a/apps/shared/test-helpers/contracts/common/Petrifiable.sol +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "./Initializable.sol"; - - -contract Petrifiable is Initializable { - // Use block UINT256_MAX (which should be never) as the initializable date - uint256 constant internal PETRIFIED_BLOCK = uint256(-1); - - function isPetrified() public view returns (bool) { - return getInitializationBlock() == PETRIFIED_BLOCK; - } - - /** - * @dev Function to be called by top level contract to prevent being initialized. - * Useful for freezing base contracts when they're used behind proxies. - */ - function petrify() internal onlyInit { - initializedAt(PETRIFIED_BLOCK); - } -} diff --git a/apps/shared/test-helpers/contracts/common/TimeHelpers.sol b/apps/shared/test-helpers/contracts/common/TimeHelpers.sol deleted file mode 100644 index cb9993331..000000000 --- a/apps/shared/test-helpers/contracts/common/TimeHelpers.sol +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "./Uint256Helpers.sol"; - - -contract TimeHelpers { - using Uint256Helpers for uint256; - - /** - * @dev Returns the current block number. - * Using a function rather than `block.number` allows us to easily mock the block number in - * tests. - */ - function getBlockNumber() internal view returns (uint256) { - return block.number; - } - - /** - * @dev Returns the current block number, converted to uint64. - * Using a function rather than `block.number` allows us to easily mock the block number in - * tests. - */ - function getBlockNumber64() internal view returns (uint64) { - return getBlockNumber().toUint64(); - } - - /** - * @dev Returns the current timestamp. - * Using a function rather than `block.timestamp` allows us to easily mock it in - * tests. - */ - function getTimestamp() internal view returns (uint256) { - return block.timestamp; // solium-disable-line security/no-block-members - } - - /** - * @dev Returns the current timestamp, converted to uint64. - * Using a function rather than `block.timestamp` allows us to easily mock it in - * tests. - */ - function getTimestamp64() internal view returns (uint64) { - return getTimestamp().toUint64(); - } -} diff --git a/apps/shared/test-helpers/contracts/common/Uint256Helpers.sol b/apps/shared/test-helpers/contracts/common/Uint256Helpers.sol deleted file mode 100644 index e22cc149f..000000000 --- a/apps/shared/test-helpers/contracts/common/Uint256Helpers.sol +++ /dev/null @@ -1,11 +0,0 @@ -pragma solidity ^0.4.24; - - -library Uint256Helpers { - uint256 public constant MAX_UINT64 = uint64(-1); - - function toUint64(uint256 a) internal pure returns (uint64) { - require(a <= MAX_UINT64); - return uint64(a); - } -} diff --git a/apps/shared/test-helpers/contracts/common/UnstructuredStorage.sol b/apps/shared/test-helpers/contracts/common/UnstructuredStorage.sol deleted file mode 100644 index db0a56d98..000000000 --- a/apps/shared/test-helpers/contracts/common/UnstructuredStorage.sol +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -library UnstructuredStorage { - function getStorageBool(bytes32 position) internal view returns (bool data) { - assembly { data := sload(position) } - } - - function getStorageAddress(bytes32 position) internal view returns (address data) { - assembly { data := sload(position) } - } - - function getStorageBytes32(bytes32 position) internal view returns (bytes32 data) { - assembly { data := sload(position) } - } - - function getStorageUint256(bytes32 position) internal view returns (uint256 data) { - assembly { data := sload(position) } - } - - function setStorageBool(bytes32 position, bool data) internal { - assembly { sstore(position, data) } - } - - function setStorageAddress(bytes32 position, address data) internal { - assembly { sstore(position, data) } - } - - function setStorageBytes32(bytes32 position, bytes32 data) internal { - assembly { sstore(position, data) } - } - - function setStorageUint256(bytes32 position, uint256 data) internal { - assembly { sstore(position, data) } - } -} diff --git a/apps/shared/test-helpers/contracts/common/VaultRecoverable.sol b/apps/shared/test-helpers/contracts/common/VaultRecoverable.sol deleted file mode 100644 index 5e4538d44..000000000 --- a/apps/shared/test-helpers/contracts/common/VaultRecoverable.sol +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "../lib/token/ERC20.sol"; -import "./EtherTokenConstant.sol"; -import "./IsContract.sol"; -import "./IVaultRecoverable.sol"; - - -contract VaultRecoverable is IVaultRecoverable, EtherTokenConstant, IsContract { - /** - * @notice Send funds to recovery Vault. This contract should never receive funds, - * but in case it does, this function allows one to recover them. - * @param _token Token balance to be sent to recovery vault. - */ - function transferToVault(address _token) external { - require(allowRecoverability(_token)); - address vault = getRecoveryVault(); - require(isContract(vault)); - - if (_token == ETH) { - vault.transfer(address(this).balance); - } else { - uint256 amount = ERC20(_token).balanceOf(this); - ERC20(_token).transfer(vault, amount); - } - } - - /** - * @dev By default deriving from AragonApp makes it recoverable - * @return bool whether the app allows the recovery - */ - function allowRecoverability(address /*token*/) public view returns (bool) { - return true; - } - // * @param token Token address that would be recovered // unused - - // Cast non-implemented interface to be public so we can use it internally - function getRecoveryVault() public view returns (address); -} diff --git a/apps/shared/test-helpers/contracts/ens/ENSConstants.sol b/apps/shared/test-helpers/contracts/ens/ENSConstants.sol deleted file mode 100644 index f7b843e4c..000000000 --- a/apps/shared/test-helpers/contracts/ens/ENSConstants.sol +++ /dev/null @@ -1,14 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -contract ENSConstants { - bytes32 constant public ENS_ROOT = bytes32(0); - bytes32 constant public ETH_TLD_LABEL = keccak256("eth"); - bytes32 constant public ETH_TLD_NODE = keccak256(abi.encodePacked(ENS_ROOT, ETH_TLD_LABEL)); - bytes32 constant public PUBLIC_RESOLVER_LABEL = keccak256("resolver"); - bytes32 constant public PUBLIC_RESOLVER_NODE = keccak256(abi.encodePacked(ETH_TLD_NODE, PUBLIC_RESOLVER_LABEL)); -} diff --git a/apps/shared/test-helpers/contracts/ens/ENSSubdomainRegistrar.sol b/apps/shared/test-helpers/contracts/ens/ENSSubdomainRegistrar.sol deleted file mode 100644 index 4013b3c94..000000000 --- a/apps/shared/test-helpers/contracts/ens/ENSSubdomainRegistrar.sol +++ /dev/null @@ -1,92 +0,0 @@ -pragma solidity 0.4.24; - -import "../lib/ens/AbstractENS.sol"; -import "../lib/ens/PublicResolver.sol"; -import "./ENSConstants.sol"; - -import "../apps/AragonApp.sol"; - - -/* solium-disable function-order */ -// Allow public initialize() to be first -contract ENSSubdomainRegistrar is AragonApp, ENSConstants { - // bytes32 constant public CREATE_NAME_ROLE = keccak256("CREATE_NAME_ROLE"); - // bytes32 constant public DELETE_NAME_ROLE = keccak256("DELETE_NAME_ROLE"); - // bytes32 constant public POINT_ROOTNODE_ROLE = keccak256("POINT_ROOTNODE_ROLE"); - bytes32 constant public CREATE_NAME_ROLE = 0xf86bc2abe0919ab91ef714b2bec7c148d94f61fdb069b91a6cfe9ecdee1799ba; - bytes32 constant public DELETE_NAME_ROLE = 0x03d74c8724218ad4a99859bcb2d846d39999449fd18013dd8d69096627e68622; - bytes32 constant public POINT_ROOTNODE_ROLE = 0x9ecd0e7bddb2e241c41b595a436c4ea4fd33c9fa0caa8056acf084fc3aa3bfbe; - - AbstractENS public ens; - bytes32 public rootNode; - - event NewName(bytes32 indexed node, bytes32 indexed label); - event DeleteName(bytes32 indexed node, bytes32 indexed label); - - function initialize(AbstractENS _ens, bytes32 _rootNode) public onlyInit { - initialized(); - - // We need ownership to create subnodes - require(_ens.owner(_rootNode) == address(this)); - - ens = _ens; - rootNode = _rootNode; - } - - function createName(bytes32 _label, address _owner) external auth(CREATE_NAME_ROLE) returns (bytes32 node) { - return _createName(_label, _owner); - } - - function createNameAndPoint(bytes32 _label, address _target) external auth(CREATE_NAME_ROLE) returns (bytes32 node) { - node = _createName(_label, this); - _pointToResolverAndResolve(node, _target); - } - - function deleteName(bytes32 _label) external auth(DELETE_NAME_ROLE) { - bytes32 node = getNodeForLabel(_label); - - address currentOwner = ens.owner(node); - - require(currentOwner != address(0)); // fail if deleting unset name - - if (currentOwner != address(this)) { // needs to reclaim ownership so it can set resolver - ens.setSubnodeOwner(rootNode, _label, this); - } - - ens.setResolver(node, address(0)); // remove resolver so it ends resolving - ens.setOwner(node, address(0)); - - emit DeleteName(node, _label); - } - - function pointRootNode(address _target) external auth(POINT_ROOTNODE_ROLE) { - _pointToResolverAndResolve(rootNode, _target); - } - - function _createName(bytes32 _label, address _owner) internal returns (bytes32 node) { - node = getNodeForLabel(_label); - require(ens.owner(node) == address(0)); // avoid name reset - - ens.setSubnodeOwner(rootNode, _label, _owner); - - emit NewName(node, _label); - - return node; - } - - function _pointToResolverAndResolve(bytes32 _node, address _target) internal { - address publicResolver = getAddr(PUBLIC_RESOLVER_NODE); - ens.setResolver(_node, publicResolver); - - PublicResolver(publicResolver).setAddr(_node, _target); - } - - function getAddr(bytes32 node) internal view returns (address) { - address resolver = ens.resolver(node); - return PublicResolver(resolver).addr(node); - } - - function getNodeForLabel(bytes32 _label) internal view returns (bytes32) { - return keccak256(abi.encodePacked(rootNode, _label)); - } -} diff --git a/apps/shared/test-helpers/contracts/evmscript/EVMScriptRegistry.sol b/apps/shared/test-helpers/contracts/evmscript/EVMScriptRegistry.sol deleted file mode 100644 index ea74f758d..000000000 --- a/apps/shared/test-helpers/contracts/evmscript/EVMScriptRegistry.sol +++ /dev/null @@ -1,92 +0,0 @@ -pragma solidity 0.4.24; - -import "../apps/AragonApp.sol"; -import "./ScriptHelpers.sol"; -import "./IEVMScriptExecutor.sol"; -import "./IEVMScriptRegistry.sol"; - - -/* solium-disable function-order */ -// Allow public initialize() to be first -contract EVMScriptRegistry is IEVMScriptRegistry, EVMScriptRegistryConstants, AragonApp { - using ScriptHelpers for bytes; - - // bytes32 constant public REGISTRY_ADD_EXECUTOR_ROLE = keccak256("REGISTRY_ADD_EXECUTOR_ROLE"); - bytes32 constant public REGISTRY_ADD_EXECUTOR_ROLE = 0xc4e90f38eea8c4212a009ca7b8947943ba4d4a58d19b683417f65291d1cd9ed2; - // WARN: Manager can censor all votes and the like happening in an org - // bytes32 constant public REGISTRY_MANAGER_ROLE = keccak256("REGISTRY_MANAGER_ROLE"); - bytes32 constant public REGISTRY_MANAGER_ROLE = 0xf7a450ef335e1892cb42c8ca72e7242359d7711924b75db5717410da3f614aa3; - - struct ExecutorEntry { - IEVMScriptExecutor executor; - bool enabled; - } - - ExecutorEntry[] public executors; - - event EnableExecutor(uint256 indexed executorId, address indexed executorAddress); - event DisableExecutor(uint256 indexed executorId, address indexed executorAddress); - - /** - * @notice Initialize the registry - */ - function initialize() public onlyInit { - initialized(); - // Create empty record to begin executor IDs at 1 - executors.push(ExecutorEntry(IEVMScriptExecutor(0), false)); - } - - /** - * @notice Add a new script executor with address `_executor` to the registry - * @param _executor Address of the IEVMScriptExecutor that will be added to the registry - * @return id Identifier of the executor in the registry - */ - function addScriptExecutor(IEVMScriptExecutor _executor) external auth(REGISTRY_ADD_EXECUTOR_ROLE) returns (uint256 id) { - uint256 executorId = executors.push(ExecutorEntry(_executor, true)) - 1; - emit EnableExecutor(executorId, _executor); - return executorId; - } - - /** - * @notice Disable script executor with ID `_executorId` - * @param _executorId Identifier of the executor in the registry - */ - function disableScriptExecutor(uint256 _executorId) - external - authP(REGISTRY_MANAGER_ROLE, arr(_executorId)) - { - ExecutorEntry storage executorEntry = executors[_executorId]; - require(executorEntry.enabled); - executorEntry.enabled = false; - emit DisableExecutor(_executorId, executorEntry.executor); - } - - /** - * @notice Enable script executor with ID `_executorId` - * @param _executorId Identifier of the executor in the registry - */ - function enableScriptExecutor(uint256 _executorId) - external - authP(REGISTRY_MANAGER_ROLE, arr(_executorId)) - { - ExecutorEntry storage executorEntry = executors[_executorId]; - require(!executorEntry.enabled); - executorEntry.enabled = true; - emit EnableExecutor(_executorId, executorEntry.executor); - } - - /** - * @dev Get the script executor that can execute a particular script based on its first 4 bytes - * @param _script EVMScript being inspected - */ - function getScriptExecutor(bytes _script) public view returns (IEVMScriptExecutor) { - uint256 id = _script.getSpecId(); - - if (id == 0 || id >= executors.length) { - return IEVMScriptExecutor(0); - } - - ExecutorEntry storage entry = executors[id]; - return entry.enabled ? entry.executor : IEVMScriptExecutor(0); - } -} diff --git a/apps/shared/test-helpers/contracts/evmscript/EVMScriptRunner.sol b/apps/shared/test-helpers/contracts/evmscript/EVMScriptRunner.sol deleted file mode 100644 index 5855be12c..000000000 --- a/apps/shared/test-helpers/contracts/evmscript/EVMScriptRunner.sol +++ /dev/null @@ -1,76 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "./IEVMScriptExecutor.sol"; -import "./IEVMScriptRegistry.sol"; - -import "../apps/AppStorage.sol"; -import "../kernel/KernelConstants.sol"; -import "../common/Initializable.sol"; - - -contract EVMScriptRunner is AppStorage, Initializable, EVMScriptRegistryConstants, KernelNamespaceConstants { - string private constant ERROR_EXECUTOR_UNAVAILABLE = "EVMRUN_EXECUTOR_UNAVAILABLE"; - string private constant ERROR_EXECUTION_REVERTED = "EVMRUN_EXECUTION_REVERTED"; - string private constant ERROR_PROTECTED_STATE_MODIFIED = "EVMRUN_PROTECTED_STATE_MODIFIED"; - - event ScriptResult(address indexed executor, bytes script, bytes input, bytes returnData); - - function getEVMScriptExecutor(bytes _script) public view returns (IEVMScriptExecutor) { - return IEVMScriptExecutor(getEVMScriptRegistry().getScriptExecutor(_script)); - } - - function getEVMScriptRegistry() public view returns (IEVMScriptRegistry) { - address registryAddr = kernel().getApp(KERNEL_APP_ADDR_NAMESPACE, EVMSCRIPT_REGISTRY_APP_ID); - return IEVMScriptRegistry(registryAddr); - } - - function runScript(bytes _script, bytes _input, address[] _blacklist) - internal - isInitialized - protectState - returns (bytes) - { - // TODO: Too much data flying around, maybe extracting spec id here is cheaper - IEVMScriptExecutor executor = getEVMScriptExecutor(_script); - require(address(executor) != address(0), ERROR_EXECUTOR_UNAVAILABLE); - - bytes4 sig = executor.execScript.selector; - bytes memory data = abi.encodeWithSelector(sig, _script, _input, _blacklist); - require(address(executor).delegatecall(data), ERROR_EXECUTION_REVERTED); - - bytes memory output = returnedDataDecoded(); - - emit ScriptResult(address(executor), _script, _input, output); - - return output; - } - - /** - * @dev copies and returns last's call data. Needs to ABI decode first - */ - function returnedDataDecoded() internal pure returns (bytes ret) { - assembly { - let size := returndatasize - switch size - case 0 {} - default { - ret := mload(0x40) // free mem ptr get - mstore(0x40, add(ret, add(size, 0x20))) // free mem ptr set - returndatacopy(ret, 0x20, sub(size, 0x20)) // copy return data - } - } - return ret; - } - - modifier protectState { - address preKernel = address(kernel()); - bytes32 preAppId = appId(); - _; // exec - require(address(kernel()) == preKernel, ERROR_PROTECTED_STATE_MODIFIED); - require(appId() == preAppId, ERROR_PROTECTED_STATE_MODIFIED); - } -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/evmscript/IEVMScriptExecutor.sol b/apps/shared/test-helpers/contracts/evmscript/IEVMScriptExecutor.sol deleted file mode 100644 index ffa036824..000000000 --- a/apps/shared/test-helpers/contracts/evmscript/IEVMScriptExecutor.sol +++ /dev/null @@ -1,11 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -interface IEVMScriptExecutor { - function execScript(bytes script, bytes input, address[] blacklist) external returns (bytes); - function executorType() external pure returns (bytes32); -} diff --git a/apps/shared/test-helpers/contracts/evmscript/IEVMScriptRegistry.sol b/apps/shared/test-helpers/contracts/evmscript/IEVMScriptRegistry.sol deleted file mode 100644 index 0d0f026bc..000000000 --- a/apps/shared/test-helpers/contracts/evmscript/IEVMScriptRegistry.sol +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "./IEVMScriptExecutor.sol"; - - -contract EVMScriptRegistryConstants { - /* Hardcoded constants to save gas - bytes32 constant public EVMSCRIPT_REGISTRY_APP_ID = apmNamehash("evmreg"); - */ - bytes32 constant public EVMSCRIPT_REGISTRY_APP_ID = 0xddbcfd564f642ab5627cf68b9b7d374fb4f8a36e941a75d89c87998cef03bd61; -} - - -interface IEVMScriptRegistry { - function addScriptExecutor(IEVMScriptExecutor executor) external returns (uint id); - function disableScriptExecutor(uint256 executorId) external; - - // TODO: this should be external - // See https://github.com/ethereum/solidity/issues/4832 - function getScriptExecutor(bytes script) public view returns (IEVMScriptExecutor); -} diff --git a/apps/shared/test-helpers/contracts/evmscript/executors/BaseEVMScriptExecutor.sol b/apps/shared/test-helpers/contracts/evmscript/executors/BaseEVMScriptExecutor.sol deleted file mode 100644 index 2a10dfd87..000000000 --- a/apps/shared/test-helpers/contracts/evmscript/executors/BaseEVMScriptExecutor.sol +++ /dev/null @@ -1,13 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "../../common/Autopetrified.sol"; -import "../IEVMScriptExecutor.sol"; - - -contract BaseEVMScriptExecutor is IEVMScriptExecutor, Autopetrified { - uint256 constant internal SCRIPT_START_LOCATION = 4; -} diff --git a/apps/shared/test-helpers/contracts/evmscript/executors/CallsScript.sol b/apps/shared/test-helpers/contracts/evmscript/executors/CallsScript.sol deleted file mode 100644 index e4cf528b0..000000000 --- a/apps/shared/test-helpers/contracts/evmscript/executors/CallsScript.sol +++ /dev/null @@ -1,55 +0,0 @@ -pragma solidity 0.4.24; - -// Inspired by https://github.com/reverendus/tx-manager - -import "../ScriptHelpers.sol"; -import "./BaseEVMScriptExecutor.sol"; - - -contract CallsScript is BaseEVMScriptExecutor { - using ScriptHelpers for bytes; - - // bytes32 constant internal EXECUTOR_TYPE = keccak256("CALLS_SCRIPT"); - bytes32 constant internal EXECUTOR_TYPE = 0x2dc858a00f3e417be1394b87c07158e989ec681ce8cc68a9093680ac1a870302; - - event LogScriptCall(address indexed sender, address indexed src, address indexed dst); - - /** - * @notice Executes a number of call scripts - * @param _script [ specId (uint32) ] many calls with this structure -> - * [ to (address: 20 bytes) ] [ calldataLength (uint32: 4 bytes) ] [ calldata (calldataLength bytes) ] - * @param _blacklist Addresses the script cannot call to, or will revert. - * @return always returns empty byte array - */ - function execScript(bytes _script, bytes, address[] _blacklist) external isInitialized returns (bytes) { - uint256 location = SCRIPT_START_LOCATION; // first 32 bits are spec id - while (location < _script.length) { - address contractAddress = _script.addressAt(location); - // Check address being called is not blacklist - for (uint i = 0; i < _blacklist.length; i++) { - require(contractAddress != _blacklist[i]); - } - - // logged before execution to ensure event ordering in receipt - // if failed entire execution is reverted regardless - emit LogScriptCall(msg.sender, address(this), contractAddress); - - uint256 calldataLength = uint256(_script.uint32At(location + 0x14)); - uint256 startOffset = location + 0x14 + 0x04; - uint256 calldataStart = _script.locationOf(startOffset); - - // compute end of script / next location - location = startOffset + calldataLength; - require(location <= _script.length); - - assembly { - let success := call(sub(gas, 5000), contractAddress, 0, calldataStart, calldataLength, 0, 0) - switch success case 0 { revert(0, 0) } - } - } - } - - function executorType() external pure returns (bytes32) { - return EXECUTOR_TYPE; - } -} diff --git a/apps/shared/test-helpers/contracts/factory/APMRegistryFactory.sol b/apps/shared/test-helpers/contracts/factory/APMRegistryFactory.sol deleted file mode 100644 index e6738382c..000000000 --- a/apps/shared/test-helpers/contracts/factory/APMRegistryFactory.sol +++ /dev/null @@ -1,126 +0,0 @@ -pragma solidity 0.4.24; - - -import "../apm/APMRegistry.sol"; -import "../apm/Repo.sol"; -import "../ens/ENSSubdomainRegistrar.sol"; - -import "./DAOFactory.sol"; -import "./ENSFactory.sol"; -import "./AppProxyFactory.sol"; - - -contract APMRegistryFactory is APMRegistryConstants { - DAOFactory public daoFactory; - APMRegistry public registryBase; - Repo public repoBase; - ENSSubdomainRegistrar public ensSubdomainRegistrarBase; - ENS public ens; - - event DeployAPM(bytes32 indexed node, address apm); - - // Needs either one ENS or ENSFactory - constructor( - DAOFactory _daoFactory, - APMRegistry _registryBase, - Repo _repoBase, - ENSSubdomainRegistrar _ensSubBase, - ENS _ens, - ENSFactory _ensFactory - ) public // DAO initialized without evmscript run support - { - daoFactory = _daoFactory; - registryBase = _registryBase; - repoBase = _repoBase; - ensSubdomainRegistrarBase = _ensSubBase; - - // Either the ENS address provided is used, if any. - // Or we use the ENSFactory to generate a test instance of ENS - // If not the ENS address nor factory address are provided, this will revert - ens = _ens != address(0) ? _ens : _ensFactory.newENS(this); - } - - function newAPM(bytes32 _tld, bytes32 _label, address _root) public returns (APMRegistry) { - bytes32 node = keccak256(abi.encodePacked(_tld, _label)); - - // Assume it is the test ENS - if (ens.owner(node) != address(this)) { - // If we weren't in test ens and factory doesn't have ownership, will fail - require(ens.owner(_tld) == address(this)); - ens.setSubnodeOwner(_tld, _label, this); - } - - Kernel dao = daoFactory.newDAO(this); - ACL acl = ACL(dao.acl()); - - acl.createPermission(this, dao, dao.APP_MANAGER_ROLE(), this); - - // Deploy app proxies - bytes memory noInit = new bytes(0); - ENSSubdomainRegistrar ensSub = ENSSubdomainRegistrar( - dao.newAppInstance( - keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(ENS_SUB_APP_NAME)))), - ensSubdomainRegistrarBase, - noInit, - false - ) - ); - APMRegistry apm = APMRegistry( - dao.newAppInstance( - keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(APM_APP_NAME)))), - registryBase, - noInit, - false - ) - ); - - // APMRegistry controls Repos - bytes32 repoAppId = keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(REPO_APP_NAME)))); - dao.setApp(dao.APP_BASES_NAMESPACE(), repoAppId, repoBase); - - emit DeployAPM(node, apm); - - // Grant permissions needed for APM on ENSSubdomainRegistrar - acl.createPermission(apm, ensSub, ensSub.CREATE_NAME_ROLE(), _root); - acl.createPermission(apm, ensSub, ensSub.POINT_ROOTNODE_ROLE(), _root); - - // allow apm to create permissions for Repos in Kernel - bytes32 permRole = acl.CREATE_PERMISSIONS_ROLE(); - - acl.grantPermission(apm, acl, permRole); - - // Initialize - ens.setOwner(node, ensSub); - ensSub.initialize(ens, node); - apm.initialize(ensSub); - - uint16[3] memory firstVersion; - firstVersion[0] = 1; - - acl.createPermission(this, apm, apm.CREATE_REPO_ROLE(), this); - - apm.newRepoWithVersion(APM_APP_NAME, _root, firstVersion, registryBase, b("ipfs:apm")); - apm.newRepoWithVersion(ENS_SUB_APP_NAME, _root, firstVersion, ensSubdomainRegistrarBase, b("ipfs:enssub")); - apm.newRepoWithVersion(REPO_APP_NAME, _root, firstVersion, repoBase, b("ipfs:repo")); - - configureAPMPermissions(acl, apm, _root); - - // Permission transition to _root - acl.setPermissionManager(_root, dao, dao.APP_MANAGER_ROLE()); - acl.revokePermission(this, acl, permRole); - acl.grantPermission(_root, acl, permRole); - acl.setPermissionManager(_root, acl, permRole); - - return apm; - } - - function b(string memory x) internal pure returns (bytes memory y) { - y = bytes(x); - } - - // Factory can be subclassed and permissions changed - function configureAPMPermissions(ACL _acl, APMRegistry _apm, address _root) internal { - _acl.grantPermission(_root, _apm, _apm.CREATE_REPO_ROLE()); - _acl.setPermissionManager(_root, _apm, _apm.CREATE_REPO_ROLE()); - } -} diff --git a/apps/shared/test-helpers/contracts/factory/AppProxyFactory.sol b/apps/shared/test-helpers/contracts/factory/AppProxyFactory.sol deleted file mode 100644 index f68c9d11f..000000000 --- a/apps/shared/test-helpers/contracts/factory/AppProxyFactory.sol +++ /dev/null @@ -1,29 +0,0 @@ -pragma solidity 0.4.24; - -import "../apps/AppProxyUpgradeable.sol"; -import "../apps/AppProxyPinned.sol"; - - -contract AppProxyFactory { - event NewAppProxy(address proxy, bool isUpgradeable, bytes32 appId); - - function newAppProxy(IKernel _kernel, bytes32 _appId) public returns (AppProxyUpgradeable) { - return newAppProxy(_kernel, _appId, new bytes(0)); - } - - function newAppProxy(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public returns (AppProxyUpgradeable) { - AppProxyUpgradeable proxy = new AppProxyUpgradeable(_kernel, _appId, _initializePayload); - emit NewAppProxy(address(proxy), true, _appId); - return proxy; - } - - function newAppProxyPinned(IKernel _kernel, bytes32 _appId) public returns (AppProxyPinned) { - return newAppProxyPinned(_kernel, _appId, new bytes(0)); - } - - function newAppProxyPinned(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public returns (AppProxyPinned) { - AppProxyPinned proxy = new AppProxyPinned(_kernel, _appId, _initializePayload); - emit NewAppProxy(address(proxy), false, _appId); - return proxy; - } -} diff --git a/apps/shared/test-helpers/contracts/factory/DAOFactory.sol b/apps/shared/test-helpers/contracts/factory/DAOFactory.sol deleted file mode 100644 index a5f357d5a..000000000 --- a/apps/shared/test-helpers/contracts/factory/DAOFactory.sol +++ /dev/null @@ -1,69 +0,0 @@ -pragma solidity 0.4.24; - -import "../kernel/IKernel.sol"; -import "../kernel/Kernel.sol"; -import "../kernel/KernelProxy.sol"; - -import "../acl/IACL.sol"; -import "../acl/ACL.sol"; - -import "./EVMScriptRegistryFactory.sol"; - - -contract DAOFactory { - IKernel public baseKernel; - IACL public baseACL; - EVMScriptRegistryFactory public regFactory; - - event DeployDAO(address dao); - event DeployEVMScriptRegistry(address reg); - - constructor(IKernel _baseKernel, IACL _baseACL, EVMScriptRegistryFactory _regFactory) public { - // No need to init as it cannot be killed by devops199 - if (address(_regFactory) != address(0)) { - regFactory = _regFactory; - } - - baseKernel = _baseKernel; - baseACL = _baseACL; - } - - /** - * @param _root Address that will be granted control to setup DAO permissions - */ - function newDAO(address _root) public returns (Kernel) { - Kernel dao = Kernel(new KernelProxy(baseKernel)); - - if (address(regFactory) == address(0)) { - dao.initialize(baseACL, _root); - } else { - dao.initialize(baseACL, this); - - ACL acl = ACL(dao.acl()); - bytes32 permRole = acl.CREATE_PERMISSIONS_ROLE(); - bytes32 appManagerRole = dao.APP_MANAGER_ROLE(); - - acl.grantPermission(regFactory, acl, permRole); - - acl.createPermission(regFactory, dao, appManagerRole, this); - - EVMScriptRegistry reg = regFactory.newEVMScriptRegistry(dao); - emit DeployEVMScriptRegistry(address(reg)); - - // Clean up permissions - // First, completely reset the APP_MANAGER_ROLE - acl.revokePermission(regFactory, dao, appManagerRole); - acl.removePermissionManager(dao, appManagerRole); - - // Then, make root the only holder and manager of CREATE_PERMISSIONS_ROLE - acl.revokePermission(regFactory, acl, permRole); - acl.revokePermission(this, acl, permRole); - acl.grantPermission(_root, acl, permRole); - acl.setPermissionManager(_root, acl, permRole); - } - - emit DeployDAO(address(dao)); - - return dao; - } -} diff --git a/apps/shared/test-helpers/contracts/factory/ENSFactory.sol b/apps/shared/test-helpers/contracts/factory/ENSFactory.sol deleted file mode 100644 index 9768f20ea..000000000 --- a/apps/shared/test-helpers/contracts/factory/ENSFactory.sol +++ /dev/null @@ -1,33 +0,0 @@ -pragma solidity 0.4.24; - -import "../lib/ens/ENS.sol"; -import "../lib/ens/PublicResolver.sol"; -import "../ens/ENSConstants.sol"; - - -// Note that this contract is NOT meant to be used in production. -// Its only purpose is to easily create ENS instances for testing APM. -contract ENSFactory is ENSConstants { - event DeployENS(address ens); - - // This is an incredibly trustfull ENS deployment, only use for testing - function newENS(address _owner) public returns (ENS) { - ENS ens = new ENS(); - - // Setup .eth TLD - ens.setSubnodeOwner(ENS_ROOT, ETH_TLD_LABEL, this); - - // Setup public resolver - PublicResolver resolver = new PublicResolver(ens); - ens.setSubnodeOwner(ETH_TLD_NODE, PUBLIC_RESOLVER_LABEL, this); - ens.setResolver(PUBLIC_RESOLVER_NODE, resolver); - resolver.setAddr(PUBLIC_RESOLVER_NODE, resolver); - - ens.setOwner(ETH_TLD_NODE, _owner); - ens.setOwner(ENS_ROOT, _owner); - - emit DeployENS(ens); - - return ens; - } -} diff --git a/apps/shared/test-helpers/contracts/factory/EVMScriptRegistryFactory.sol b/apps/shared/test-helpers/contracts/factory/EVMScriptRegistryFactory.sol deleted file mode 100644 index 329dd738c..000000000 --- a/apps/shared/test-helpers/contracts/factory/EVMScriptRegistryFactory.sol +++ /dev/null @@ -1,38 +0,0 @@ -pragma solidity 0.4.24; - -import "../evmscript/IEVMScriptExecutor.sol"; -import "../evmscript/EVMScriptRegistry.sol"; - -import "../evmscript/executors/CallsScript.sol"; - -import "./AppProxyFactory.sol"; -import "../kernel/Kernel.sol"; -import "../acl/ACL.sol"; - - -contract EVMScriptRegistryFactory is AppProxyFactory, EVMScriptRegistryConstants { - EVMScriptRegistry public baseReg; - IEVMScriptExecutor public baseCallScript; - - constructor() public { - baseReg = new EVMScriptRegistry(); - baseCallScript = IEVMScriptExecutor(new CallsScript()); - } - - function newEVMScriptRegistry(Kernel _dao) public returns (EVMScriptRegistry reg) { - bytes memory initPayload = abi.encodeWithSelector(reg.initialize.selector); - reg = EVMScriptRegistry(_dao.newPinnedAppInstance(EVMSCRIPT_REGISTRY_APP_ID, baseReg, initPayload, true)); - - ACL acl = ACL(_dao.acl()); - - acl.createPermission(this, reg, reg.REGISTRY_ADD_EXECUTOR_ROLE(), this); - - reg.addScriptExecutor(baseCallScript); // spec 1 = CallsScript - - // Clean up the permissions - acl.revokePermission(this, reg, reg.REGISTRY_ADD_EXECUTOR_ROLE()); - acl.removePermissionManager(reg, reg.REGISTRY_ADD_EXECUTOR_ROLE()); - - return reg; - } -} diff --git a/apps/shared/test-helpers/contracts/kernel/IKernel.sol b/apps/shared/test-helpers/contracts/kernel/IKernel.sol deleted file mode 100644 index 0775cec14..000000000 --- a/apps/shared/test-helpers/contracts/kernel/IKernel.sol +++ /dev/null @@ -1,20 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - -import "../acl/IACL.sol"; -import "../common/IVaultRecoverable.sol"; - - -// This should be an interface, but interfaces can't inherit yet :( -contract IKernel is IVaultRecoverable { - event SetApp(bytes32 indexed namespace, bytes32 indexed appId, address app); - - function acl() public view returns (IACL); - function hasPermission(address who, address where, bytes32 what, bytes how) public view returns (bool); - - function setApp(bytes32 namespace, bytes32 appId, address app) public; - function getApp(bytes32 namespace, bytes32 appId) public view returns (address); -} diff --git a/apps/shared/test-helpers/contracts/kernel/Kernel.sol b/apps/shared/test-helpers/contracts/kernel/Kernel.sol deleted file mode 100644 index fa7acf3c3..000000000 --- a/apps/shared/test-helpers/contracts/kernel/Kernel.sol +++ /dev/null @@ -1,244 +0,0 @@ -pragma solidity 0.4.24; - -import "./IKernel.sol"; -import "./KernelConstants.sol"; -import "./KernelStorage.sol"; -import "../acl/IACL.sol"; -import "../acl/ACLSyntaxSugar.sol"; -import "../lib/misc/ERCProxy.sol"; -import "../common/IsContract.sol"; -import "../common/Petrifiable.sol"; -import "../common/VaultRecoverable.sol"; -import "../factory/AppProxyFactory.sol"; - - -// solium-disable-next-line max-len -contract Kernel is IKernel, KernelStorage, KernelAppIds, KernelNamespaceConstants, Petrifiable, IsContract, VaultRecoverable, AppProxyFactory, ACLSyntaxSugar { - /* Hardcoded constants to save gas - bytes32 public constant APP_MANAGER_ROLE = keccak256("APP_MANAGER_ROLE"); - */ - bytes32 public constant APP_MANAGER_ROLE = 0xb6d92708f3d4817afc106147d969e229ced5c46e65e0a5002a0d391287762bd0; - - string private constant ERROR_APP_NOT_CONTRACT = "KERNEL_APP_NOT_CONTRACT"; - string private constant ERROR_INVALID_APP_CHANGE = "KERNEL_INVALID_APP_CHANGE"; - string private constant ERROR_AUTH_FAILED = "KERNEL_AUTH_FAILED"; - - /** - * @dev Constructor that allows the deployer to choose if the base instance should be petrified immediately. - * @param _shouldPetrify Immediately petrify this instance so that it can never be initialized - */ - constructor(bool _shouldPetrify) public { - if (_shouldPetrify) { - petrify(); - } - } - - /** - * @dev Initialize can only be called once. It saves the block number in which it was initialized. - * @notice Initializes a kernel instance along with its ACL and sets `_permissionsCreator` as the entity that can create other permissions - * @param _baseAcl Address of base ACL app - * @param _permissionsCreator Entity that will be given permission over createPermission - */ - function initialize(IACL _baseAcl, address _permissionsCreator) public onlyInit { - initialized(); - - // Set ACL base - _setApp(KERNEL_APP_BASES_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, _baseAcl); - - // Create ACL instance and attach it as the default ACL app - IACL acl = IACL(newAppProxy(this, KERNEL_DEFAULT_ACL_APP_ID)); - acl.initialize(_permissionsCreator); - _setApp(KERNEL_APP_ADDR_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID, acl); - - recoveryVaultAppId = KERNEL_DEFAULT_VAULT_APP_ID; - } - - /** - * @dev Create a new instance of an app linked to this kernel - * @notice Create a new upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase` - * @param _appId Identifier for app - * @param _appBase Address of the app's base implementation - * @return AppProxy instance - */ - function newAppInstance(bytes32 _appId, address _appBase) - public - auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId)) - returns (ERCProxy appProxy) - { - return newAppInstance(_appId, _appBase, new bytes(0), false); - } - - /** - * @dev Create a new instance of an app linked to this kernel and set its base - * implementation if it was not already set - * @notice Create a new upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase`. `_setDefault ? 'Also sets it as the default app instance.':''` - * @param _appId Identifier for app - * @param _appBase Address of the app's base implementation - * @param _initializePayload Payload for call made by the proxy during its construction to initialize - * @param _setDefault Whether the app proxy app is the default one. - * Useful when the Kernel needs to know of an instance of a particular app, - * like Vault for escape hatch mechanism. - * @return AppProxy instance - */ - function newAppInstance(bytes32 _appId, address _appBase, bytes _initializePayload, bool _setDefault) - public - auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId)) - returns (ERCProxy appProxy) - { - _setAppIfNew(KERNEL_APP_BASES_NAMESPACE, _appId, _appBase); - appProxy = newAppProxy(this, _appId, _initializePayload); - // By calling setApp directly and not the internal functions, we make sure the params are checked - // and it will only succeed if sender has permissions to set something to the namespace. - if (_setDefault) { - setApp(KERNEL_APP_ADDR_NAMESPACE, _appId, appProxy); - } - } - - /** - * @dev Create a new pinned instance of an app linked to this kernel - * @notice Create a new non-upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase`. - * @param _appId Identifier for app - * @param _appBase Address of the app's base implementation - * @return AppProxy instance - */ - function newPinnedAppInstance(bytes32 _appId, address _appBase) - public - auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId)) - returns (ERCProxy appProxy) - { - return newPinnedAppInstance(_appId, _appBase, new bytes(0), false); - } - - /** - * @dev Create a new pinned instance of an app linked to this kernel and set - * its base implementation if it was not already set - * @notice Create a new non-upgradeable instance of `_appId` app linked to the Kernel, setting its code to `_appBase`. `_setDefault ? 'Also sets it as the default app instance.':''` - * @param _appId Identifier for app - * @param _appBase Address of the app's base implementation - * @param _initializePayload Payload for call made by the proxy during its construction to initialize - * @param _setDefault Whether the app proxy app is the default one. - * Useful when the Kernel needs to know of an instance of a particular app, - * like Vault for escape hatch mechanism. - * @return AppProxy instance - */ - function newPinnedAppInstance(bytes32 _appId, address _appBase, bytes _initializePayload, bool _setDefault) - public - auth(APP_MANAGER_ROLE, arr(KERNEL_APP_BASES_NAMESPACE, _appId)) - returns (ERCProxy appProxy) - { - _setAppIfNew(KERNEL_APP_BASES_NAMESPACE, _appId, _appBase); - appProxy = newAppProxyPinned(this, _appId, _initializePayload); - // By calling setApp directly and not the internal functions, we make sure the params are checked - // and it will only succeed if sender has permissions to set something to the namespace. - if (_setDefault) { - setApp(KERNEL_APP_ADDR_NAMESPACE, _appId, appProxy); - } - } - - /** - * @dev Set the resolving address of an app instance or base implementation - * @notice Set the resolving address of `_appId` in namespace `_namespace` to `_app` - * @param _namespace App namespace to use - * @param _appId Identifier for app - * @param _app Address of the app instance or base implementation - * @return ID of app - */ - function setApp(bytes32 _namespace, bytes32 _appId, address _app) - public - auth(APP_MANAGER_ROLE, arr(_namespace, _appId)) - { - _setApp(_namespace, _appId, _app); - } - - /** - * @dev Set the default vault id for the escape hatch mechanism - * @param _recoveryVaultAppId Identifier of the recovery vault app - */ - function setRecoveryVaultAppId(bytes32 _recoveryVaultAppId) - public - auth(APP_MANAGER_ROLE, arr(KERNEL_APP_ADDR_NAMESPACE, _recoveryVaultAppId)) - { - recoveryVaultAppId = _recoveryVaultAppId; - } - - // External access to default app id and namespace constants to mimic default getters for constants - /* solium-disable function-order, mixedcase */ - function CORE_NAMESPACE() external pure returns (bytes32) { return KERNEL_CORE_NAMESPACE; } - function APP_BASES_NAMESPACE() external pure returns (bytes32) { return KERNEL_APP_BASES_NAMESPACE; } - function APP_ADDR_NAMESPACE() external pure returns (bytes32) { return KERNEL_APP_ADDR_NAMESPACE; } - function KERNEL_APP_ID() external pure returns (bytes32) { return KERNEL_CORE_APP_ID; } - function DEFAULT_ACL_APP_ID() external pure returns (bytes32) { return KERNEL_DEFAULT_ACL_APP_ID; } - /* solium-enable function-order, mixedcase */ - - /** - * @dev Get the address of an app instance or base implementation - * @param _namespace App namespace to use - * @param _appId Identifier for app - * @return Address of the app - */ - function getApp(bytes32 _namespace, bytes32 _appId) public view returns (address) { - return apps[_namespace][_appId]; - } - - /** - * @dev Get the address of the recovery Vault instance (to recover funds) - * @return Address of the Vault - */ - function getRecoveryVault() public view returns (address) { - return apps[KERNEL_APP_ADDR_NAMESPACE][recoveryVaultAppId]; - } - - /** - * @dev Get the installed ACL app - * @return ACL app - */ - function acl() public view returns (IACL) { - return IACL(getApp(KERNEL_APP_ADDR_NAMESPACE, KERNEL_DEFAULT_ACL_APP_ID)); - } - - /** - * @dev Function called by apps to check ACL on kernel or to check permission status - * @param _who Sender of the original call - * @param _where Address of the app - * @param _what Identifier for a group of actions in app - * @param _how Extra data for ACL auth - * @return Boolean indicating whether the ACL allows the role or not. - * Always returns false if the kernel hasn't been initialized yet. - */ - function hasPermission(address _who, address _where, bytes32 _what, bytes _how) public view returns (bool) { - IACL defaultAcl = acl(); - return address(defaultAcl) != address(0) && // Poor man's initialization check (saves gas) - defaultAcl.hasPermission(_who, _where, _what, _how); - } - - function _setApp(bytes32 _namespace, bytes32 _appId, address _app) internal { - require(isContract(_app), ERROR_APP_NOT_CONTRACT); - apps[_namespace][_appId] = _app; - emit SetApp(_namespace, _appId, _app); - } - - function _setAppIfNew(bytes32 _namespace, bytes32 _appId, address _app) internal { - address app = getApp(_namespace, _appId); - if (app != address(0)) { - // The only way to set an app is if it passes the isContract check, so no need to check it again - require(app == _app, ERROR_INVALID_APP_CHANGE); - } else { - _setApp(_namespace, _appId, _app); - } - } - - modifier auth(bytes32 _role, uint256[] memory params) { - // Force cast the uint256[] into a bytes array, by overwriting its length - // Note that the bytes array doesn't need to be initialized as we immediately overwrite it - // with params and a new length, and params becomes invalid from this point forward - bytes memory how; - uint256 byteLength = params.length * 32; - assembly { - how := params - mstore(how, byteLength) - } - - require(hasPermission(msg.sender, address(this), _role, how), ERROR_AUTH_FAILED); - _; - } -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/kernel/KernelConstants.sol b/apps/shared/test-helpers/contracts/kernel/KernelConstants.sol deleted file mode 100644 index 730a254f7..000000000 --- a/apps/shared/test-helpers/contracts/kernel/KernelConstants.sol +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -contract KernelAppIds { - /* Hardcoded constants to save gas - bytes32 internal constant KERNEL_CORE_APP_ID = apmNamehash("kernel"); - bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = apmNamehash("acl"); - bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = apmNamehash("vault"); - */ - bytes32 internal constant KERNEL_CORE_APP_ID = 0x3b4bf6bf3ad5000ecf0f989d5befde585c6860fea3e574a4fab4c49d1c177d9c; - bytes32 internal constant KERNEL_DEFAULT_ACL_APP_ID = 0xe3262375f45a6e2026b7e7b18c2b807434f2508fe1a2a3dfb493c7df8f4aad6a; - bytes32 internal constant KERNEL_DEFAULT_VAULT_APP_ID = 0x7e852e0fcfce6551c13800f1e7476f982525c2b5277ba14b24339c68416336d1; -} - - -contract KernelNamespaceConstants { - /* Hardcoded constants to save gas - bytes32 internal constant KERNEL_CORE_NAMESPACE = keccak256("core"); - bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = keccak256("base"); - bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = keccak256("app"); - */ - bytes32 internal constant KERNEL_CORE_NAMESPACE = 0xc681a85306374a5ab27f0bbc385296a54bcd314a1948b6cf61c4ea1bc44bb9f8; - bytes32 internal constant KERNEL_APP_BASES_NAMESPACE = 0xf1f3eb40f5bc1ad1344716ced8b8a0431d840b5783aea1fd01786bc26f35ac0f; - bytes32 internal constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb; -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/kernel/KernelProxy.sol b/apps/shared/test-helpers/contracts/kernel/KernelProxy.sol deleted file mode 100644 index 1aaa40895..000000000 --- a/apps/shared/test-helpers/contracts/kernel/KernelProxy.sol +++ /dev/null @@ -1,34 +0,0 @@ -pragma solidity 0.4.24; - -import "./IKernel.sol"; -import "./KernelConstants.sol"; -import "./KernelStorage.sol"; -import "../common/DepositableDelegateProxy.sol"; -import "../common/IsContract.sol"; - - -contract KernelProxy is KernelStorage, KernelAppIds, KernelNamespaceConstants, IsContract, DepositableDelegateProxy { - /** - * @dev KernelProxy is a proxy contract to a kernel implementation. The implementation - * can update the reference, which effectively upgrades the contract - * @param _kernelImpl Address of the contract used as implementation for kernel - */ - constructor(IKernel _kernelImpl) public { - require(isContract(address(_kernelImpl))); - apps[KERNEL_CORE_NAMESPACE][KERNEL_CORE_APP_ID] = _kernelImpl; - } - - /** - * @dev ERC897, whether it is a forwarding (1) or an upgradeable (2) proxy - */ - function proxyType() public pure returns (uint256 proxyTypeId) { - return UPGRADEABLE; - } - - /** - * @dev ERC897, the address the proxy would delegate calls to - */ - function implementation() public view returns (address) { - return apps[KERNEL_CORE_NAMESPACE][KERNEL_CORE_APP_ID]; - } -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/kernel/KernelStorage.sol b/apps/shared/test-helpers/contracts/kernel/KernelStorage.sol deleted file mode 100644 index 7602780aa..000000000 --- a/apps/shared/test-helpers/contracts/kernel/KernelStorage.sol +++ /dev/null @@ -1,8 +0,0 @@ -pragma solidity 0.4.24; - - -contract KernelStorage { - // namespace => app id => address - mapping (bytes32 => mapping (bytes32 => address)) public apps; - bytes32 public recoveryVaultAppId; -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/lib/bounties/BountiesEvents.sol b/apps/shared/test-helpers/contracts/lib/bounties/BountiesEvents.sol deleted file mode 100644 index b30f844aa..000000000 --- a/apps/shared/test-helpers/contracts/lib/bounties/BountiesEvents.sol +++ /dev/null @@ -1,34 +0,0 @@ -// solium-disable -pragma solidity ^0.4.24; - -interface BountiesEvents { - - /* - * Functions - */ - - function fulfillBounty( - address _sender, - uint _bountyId, - address[] _fulfillers, - string _data - ) external; - /* - * Events - */ - - event BountyIssued(uint _bountyId, address _creator, address [] _issuers, address [] _approvers, string _data, uint _deadline, address _token, uint _tokenVersion); - event ContributionAdded(uint _bountyId, uint _contributionId, address _contributor, uint _amount); - event ContributionRefunded(uint _bountyId, uint _contributionId); - event ContributionsRefunded(uint _bountyId, address _issuer, uint [] _contributionIds); - event BountyDrained(uint _bountyId, address _issuer, uint [] _amounts); - event ActionPerformed(uint _bountyId, address _fulfiller, string _data); - event BountyFulfilled(uint _bountyId, uint _fulfillmentId, address [] _fulfillers, string _data, address _submitter); - event FulfillmentUpdated(uint _bountyId, uint _fulfillmentId, address [] _fulfillers, string _data); - event FulfillmentAccepted(uint _bountyId, uint _fulfillmentId, address _approver, uint[] _tokenAmounts); - event BountyChanged(uint _bountyId, address _changer, address [] _issuers, address [] _approvers, string _data, uint _deadline); - event BountyIssuersUpdated(uint _bountyId, address _changer, address [] _issuers); - event BountyApproversUpdated(uint _bountyId, address _changer, address [] _approvers); - event BountyDataChanged(uint _bountyId, address _changer, string _data); - event BountyDeadlineChanged(uint _bountyId, address _changer, uint _deadline); -} diff --git a/apps/shared/test-helpers/contracts/lib/bounties/StandardBounties.sol b/apps/shared/test-helpers/contracts/lib/bounties/StandardBounties.sol deleted file mode 100644 index 9fbf8f186..000000000 --- a/apps/shared/test-helpers/contracts/lib/bounties/StandardBounties.sol +++ /dev/null @@ -1,597 +0,0 @@ -pragma solidity ^0.4.18; -/* solium-disable */ -import "./inherited/HumanStandardToken.sol"; - -/// @title StandardBounties -/// @dev Used to pay out individuals or groups for task fulfillment through -/// stepwise work submission, acceptance, and payment -/// @author Mark Beylin , Gonçalo Sá -contract StandardBounties { - - /* - * Events - */ - event BountyIssued(uint bountyId); - event BountyActivated(uint bountyId, address issuer); - event BountyFulfilled(uint bountyId, address indexed fulfiller, uint256 indexed _fulfillmentId); - event FulfillmentUpdated(uint _bountyId, uint _fulfillmentId); - event FulfillmentAccepted(uint bountyId, address indexed fulfiller, uint256 indexed _fulfillmentId); - event BountyKilled(uint bountyId, address indexed issuer); - event ContributionAdded(uint bountyId, address indexed contributor, uint256 value); - event DeadlineExtended(uint bountyId, uint newDeadline); - event BountyChanged(uint bountyId); - event IssuerTransferred(uint _bountyId, address indexed _newIssuer); - event PayoutIncreased(uint _bountyId, uint _newFulfillmentAmount); - - - /* - * Storage - */ - - address public owner; - - Bounty[] public bounties; - - mapping(uint=>Fulfillment[]) fulfillments; - mapping(uint=>uint) numAccepted; - mapping(uint=>HumanStandardToken) tokenContracts; - - /* - * Enums - */ - - enum BountyStages { - Draft, - Active, - Dead - } - - /* - * Structs - */ - - struct Bounty { - address issuer; - uint deadline; - string data; - uint fulfillmentAmount; - address arbiter; - bool paysTokens; - BountyStages bountyStage; - uint balance; - } - - struct Fulfillment { - bool accepted; - address fulfiller; - string data; - } - - /* - * Modifiers - */ - - modifier validateNotTooManyBounties(){ - require((bounties.length + 1) > bounties.length); - _; - } - - modifier validateNotTooManyFulfillments(uint _bountyId){ - require((fulfillments[_bountyId].length + 1) > fulfillments[_bountyId].length); - _; - } - - modifier validateBountyArrayIndex(uint _bountyId){ - require(_bountyId < bounties.length); - _; - } - - modifier onlyIssuer(uint _bountyId) { - require(msg.sender == bounties[_bountyId].issuer); - _; - } - - modifier onlyFulfiller(uint _bountyId, uint _fulfillmentId) { - require(msg.sender == fulfillments[_bountyId][_fulfillmentId].fulfiller); - _; - } - - modifier amountIsNotZero(uint _amount) { - require(_amount != 0); - _; - } - - modifier transferredAmountEqualsValue(uint _bountyId, uint _amount) { - if (bounties[_bountyId].paysTokens){ - require(msg.value == 0); - uint oldBalance = tokenContracts[_bountyId].balanceOf(this); - if (_amount != 0){ - require(tokenContracts[_bountyId].transferFrom(msg.sender, this, _amount)); - } - require((tokenContracts[_bountyId].balanceOf(this) - oldBalance) == _amount); - - } else { - require((_amount * 1 wei) == msg.value); - } - _; - } - - modifier isBeforeDeadline(uint _bountyId) { - require(now < bounties[_bountyId].deadline); - _; - } - - modifier validateDeadline(uint _newDeadline) { - require(_newDeadline > now); - _; - } - - modifier isAtStage(uint _bountyId, BountyStages _desiredStage) { - require(bounties[_bountyId].bountyStage == _desiredStage); - _; - } - - modifier validateFulfillmentArrayIndex(uint _bountyId, uint _index) { - require(_index < fulfillments[_bountyId].length); - _; - } - - modifier notYetAccepted(uint _bountyId, uint _fulfillmentId){ - require(fulfillments[_bountyId][_fulfillmentId].accepted == false); - _; - } - - /* - * Public functions - */ - - - /// @dev StandardBounties(): instantiates - /// @param _owner the issuer of the standardbounties contract, who has the - /// ability to remove bounties - function StandardBounties(address _owner) - public - { - owner = _owner; - } - - /// @dev issueBounty(): instantiates a new draft bounty - /// @param _issuer the address of the intended issuer of the bounty - /// @param _deadline the unix timestamp after which fulfillments will no longer be accepted - /// @param _data the requirements of the bounty - /// @param _fulfillmentAmount the amount of wei to be paid out for each successful fulfillment - /// @param _arbiter the address of the arbiter who can mediate claims - /// @param _paysTokens whether the bounty pays in tokens or in ETH - /// @param _tokenContract the address of the contract if _paysTokens is true - function issueBounty( - address _issuer, - uint _deadline, - string _data, - uint256 _fulfillmentAmount, - address _arbiter, - bool _paysTokens, - address _tokenContract - ) - public - validateDeadline(_deadline) - amountIsNotZero(_fulfillmentAmount) - validateNotTooManyBounties - returns (uint) - { - bounties.push(Bounty(_issuer, _deadline, _data, _fulfillmentAmount, _arbiter, _paysTokens, BountyStages.Draft, 0)); - if (_paysTokens){ - tokenContracts[bounties.length - 1] = HumanStandardToken(_tokenContract); - } - BountyIssued(bounties.length - 1); - return (bounties.length - 1); - } - - /// @dev issueAndActivateBounty(): instantiates a new draft bounty - /// @param _issuer the address of the intended issuer of the bounty - /// @param _deadline the unix timestamp after which fulfillments will no longer be accepted - /// @param _data the requirements of the bounty - /// @param _fulfillmentAmount the amount of wei to be paid out for each successful fulfillment - /// @param _arbiter the address of the arbiter who can mediate claims - /// @param _paysTokens whether the bounty pays in tokens or in ETH - /// @param _tokenContract the address of the contract if _paysTokens is true - /// @param _value the total number of tokens being deposited upon activation - function issueAndActivateBounty( - address _issuer, - uint _deadline, - string _data, - uint256 _fulfillmentAmount, - address _arbiter, - bool _paysTokens, - address _tokenContract, - uint256 _value - ) - public - payable - validateDeadline(_deadline) - amountIsNotZero(_fulfillmentAmount) - validateNotTooManyBounties - returns (uint) - { - require (_value >= _fulfillmentAmount); - if (_paysTokens){ - require(msg.value == 0); - tokenContracts[bounties.length] = HumanStandardToken(_tokenContract); - require(tokenContracts[bounties.length].transferFrom(msg.sender, this, _value)); - } else { - require((_value * 1 wei) == msg.value); - } - bounties.push(Bounty(_issuer, - _deadline, - _data, - _fulfillmentAmount, - _arbiter, - _paysTokens, - BountyStages.Active, - _value)); - BountyIssued(bounties.length - 1); - ContributionAdded(bounties.length - 1, msg.sender, _value); - BountyActivated(bounties.length - 1, msg.sender); - return (bounties.length - 1); - } - - modifier isNotDead(uint _bountyId) { - require(bounties[_bountyId].bountyStage != BountyStages.Dead); - _; - } - - /// @dev contribute(): a function allowing anyone to contribute tokens to a - /// bounty, as long as it is still before its deadline. Shouldn't keep - /// them by accident (hence 'value'). - /// @param _bountyId the index of the bounty - /// @param _value the amount being contributed in ether to prevent accidental deposits - /// @notice Please note you funds will be at the mercy of the issuer - /// and can be drained at any moment. Be careful! - function contribute (uint _bountyId, uint _value) - payable - public - validateBountyArrayIndex(_bountyId) - isBeforeDeadline(_bountyId) - isNotDead(_bountyId) - amountIsNotZero(_value) - transferredAmountEqualsValue(_bountyId, _value) - { - bounties[_bountyId].balance += _value; - - ContributionAdded(_bountyId, msg.sender, _value); - } - - /// @notice Send funds to activate the bug bounty - /// @dev activateBounty(): activate a bounty so it may pay out - /// @param _bountyId the index of the bounty - /// @param _value the amount being contributed in ether to prevent - /// accidental deposits - function activateBounty(uint _bountyId, uint _value) - payable - public - validateBountyArrayIndex(_bountyId) - isBeforeDeadline(_bountyId) - onlyIssuer(_bountyId) - transferredAmountEqualsValue(_bountyId, _value) - { - bounties[_bountyId].balance += _value; - require (bounties[_bountyId].balance >= bounties[_bountyId].fulfillmentAmount); - transitionToState(_bountyId, BountyStages.Active); - - ContributionAdded(_bountyId, msg.sender, _value); - BountyActivated(_bountyId, msg.sender); - } - - modifier notIssuerOrArbiter(uint _bountyId) { - require(tx.origin != bounties[_bountyId].issuer && tx.origin != bounties[_bountyId].arbiter); - _; - } - - /// @dev fulfillBounty(): submit a fulfillment for the given bounty - /// @param _bountyId the index of the bounty - /// @param _data the data artifacts representing the fulfillment of the bounty - function fulfillBounty(uint _bountyId, string _data) - public - validateBountyArrayIndex(_bountyId) - validateNotTooManyFulfillments(_bountyId) - isAtStage(_bountyId, BountyStages.Active) - isBeforeDeadline(_bountyId) - notIssuerOrArbiter(_bountyId) - { - fulfillments[_bountyId].push(Fulfillment(false, tx.origin, _data)); - - BountyFulfilled(_bountyId, tx.origin, (fulfillments[_bountyId].length - 1)); - } - - /// @dev updateFulfillment(): Submit updated data for a given fulfillment - /// @param _bountyId the index of the bounty - /// @param _fulfillmentId the index of the fulfillment - /// @param _data the new data being submitted - function updateFulfillment(uint _bountyId, uint _fulfillmentId, string _data) - public - validateBountyArrayIndex(_bountyId) - validateFulfillmentArrayIndex(_bountyId, _fulfillmentId) - onlyFulfiller(_bountyId, _fulfillmentId) - notYetAccepted(_bountyId, _fulfillmentId) - { - fulfillments[_bountyId][_fulfillmentId].data = _data; - FulfillmentUpdated(_bountyId, _fulfillmentId); - } - - modifier onlyIssuerOrArbiter(uint _bountyId) { - require(msg.sender == bounties[_bountyId].issuer || - (msg.sender == bounties[_bountyId].arbiter && bounties[_bountyId].arbiter != address(0))); - _; - } - - modifier fulfillmentNotYetAccepted(uint _bountyId, uint _fulfillmentId) { - require(fulfillments[_bountyId][_fulfillmentId].accepted == false); - _; - } - - modifier enoughFundsToPay(uint _bountyId) { - require(bounties[_bountyId].balance >= bounties[_bountyId].fulfillmentAmount); - _; - } - - /// @dev acceptFulfillment(): accept a given fulfillment - /// @param _bountyId the index of the bounty - /// @param _fulfillmentId the index of the fulfillment being accepted - function acceptFulfillment(uint _bountyId, uint _fulfillmentId) - public - validateBountyArrayIndex(_bountyId) - validateFulfillmentArrayIndex(_bountyId, _fulfillmentId) - onlyIssuerOrArbiter(_bountyId) - isAtStage(_bountyId, BountyStages.Active) - fulfillmentNotYetAccepted(_bountyId, _fulfillmentId) - enoughFundsToPay(_bountyId) - { - fulfillments[_bountyId][_fulfillmentId].accepted = true; - numAccepted[_bountyId]++; - bounties[_bountyId].balance -= bounties[_bountyId].fulfillmentAmount; - if (bounties[_bountyId].paysTokens){ - require(tokenContracts[_bountyId].transfer(fulfillments[_bountyId][_fulfillmentId].fulfiller, bounties[_bountyId].fulfillmentAmount)); - } else { - fulfillments[_bountyId][_fulfillmentId].fulfiller.transfer(bounties[_bountyId].fulfillmentAmount); - } - FulfillmentAccepted(_bountyId, msg.sender, _fulfillmentId); - } - - /// @dev killBounty(): drains the contract of it's remaining - /// funds, and moves the bounty into stage 3 (dead) since it was - /// either killed in draft stage, or never accepted any fulfillments - /// @param _bountyId the index of the bounty - function killBounty(uint _bountyId) - public - validateBountyArrayIndex(_bountyId) - onlyIssuer(_bountyId) - { - transitionToState(_bountyId, BountyStages.Dead); - uint oldBalance = bounties[_bountyId].balance; - bounties[_bountyId].balance = 0; - if (oldBalance > 0){ - if (bounties[_bountyId].paysTokens){ - require(tokenContracts[_bountyId].transfer(bounties[_bountyId].issuer, oldBalance)); - } else { - bounties[_bountyId].issuer.transfer(oldBalance); - } - } - BountyKilled(_bountyId, msg.sender); - } - - modifier newDeadlineIsValid(uint _bountyId, uint _newDeadline) { - require(_newDeadline > bounties[_bountyId].deadline); - _; - } - - /// @dev extendDeadline(): allows the issuer to add more time to the - /// bounty, allowing it to continue accepting fulfillments - /// @param _bountyId the index of the bounty - /// @param _newDeadline the new deadline in timestamp format - function extendDeadline(uint _bountyId, uint _newDeadline) - public - validateBountyArrayIndex(_bountyId) - onlyIssuer(_bountyId) - newDeadlineIsValid(_bountyId, _newDeadline) - { - bounties[_bountyId].deadline = _newDeadline; - - DeadlineExtended(_bountyId, _newDeadline); - } - - /// @dev transferIssuer(): allows the issuer to transfer ownership of the - /// bounty to some new address - /// @param _bountyId the index of the bounty - /// @param _newIssuer the address of the new issuer - function transferIssuer(uint _bountyId, address _newIssuer) - public - validateBountyArrayIndex(_bountyId) - onlyIssuer(_bountyId) - { - bounties[_bountyId].issuer = _newIssuer; - IssuerTransferred(_bountyId, _newIssuer); - } - - - /// @dev changeBountyDeadline(): allows the issuer to change a bounty's deadline - /// @param _bountyId the index of the bounty - /// @param _newDeadline the new deadline for the bounty - function changeBountyDeadline(uint _bountyId, uint _newDeadline) - public - validateBountyArrayIndex(_bountyId) - onlyIssuer(_bountyId) - validateDeadline(_newDeadline) - isAtStage(_bountyId, BountyStages.Draft) - { - bounties[_bountyId].deadline = _newDeadline; - BountyChanged(_bountyId); - } - - /// @dev changeData(): allows the issuer to change a bounty's data - /// @param _bountyId the index of the bounty - /// @param _newData the new requirements of the bounty - function changeBountyData(uint _bountyId, string _newData) - public - validateBountyArrayIndex(_bountyId) - onlyIssuer(_bountyId) - isAtStage(_bountyId, BountyStages.Draft) - { - bounties[_bountyId].data = _newData; - BountyChanged(_bountyId); - } - - /// @dev changeBountyfulfillmentAmount(): allows the issuer to change a bounty's fulfillment amount - /// @param _bountyId the index of the bounty - /// @param _newFulfillmentAmount the new fulfillment amount - function changeBountyFulfillmentAmount(uint _bountyId, uint _newFulfillmentAmount) - public - validateBountyArrayIndex(_bountyId) - onlyIssuer(_bountyId) - isAtStage(_bountyId, BountyStages.Draft) - { - bounties[_bountyId].fulfillmentAmount = _newFulfillmentAmount; - BountyChanged(_bountyId); - } - - /// @dev changeBountyArbiter(): allows the issuer to change a bounty's arbiter - /// @param _bountyId the index of the bounty - /// @param _newArbiter the new address of the arbiter - function changeBountyArbiter(uint _bountyId, address _newArbiter) - public - validateBountyArrayIndex(_bountyId) - onlyIssuer(_bountyId) - isAtStage(_bountyId, BountyStages.Draft) - { - bounties[_bountyId].arbiter = _newArbiter; - BountyChanged(_bountyId); - } - - modifier newFulfillmentAmountIsIncrease(uint _bountyId, uint _newFulfillmentAmount) { - require(bounties[_bountyId].fulfillmentAmount < _newFulfillmentAmount); - _; - } - - /// @dev increasePayout(): allows the issuer to increase a given fulfillment - /// amount in the active stage - /// @param _bountyId the index of the bounty - /// @param _newFulfillmentAmount the new fulfillment amount - /// @param _value the value of the additional deposit being added - function increasePayout(uint _bountyId, uint _newFulfillmentAmount, uint _value) - public - payable - validateBountyArrayIndex(_bountyId) - onlyIssuer(_bountyId) - newFulfillmentAmountIsIncrease(_bountyId, _newFulfillmentAmount) - transferredAmountEqualsValue(_bountyId, _value) - { - bounties[_bountyId].balance += _value; - require(bounties[_bountyId].balance >= _newFulfillmentAmount); - bounties[_bountyId].fulfillmentAmount = _newFulfillmentAmount; - PayoutIncreased(_bountyId, _newFulfillmentAmount); - } - - /// @dev getFulfillment(): Returns the fulfillment at a given index - /// @param _bountyId the index of the bounty - /// @param _fulfillmentId the index of the fulfillment to return - /// @return Returns a tuple for the fulfillment - function getFulfillment(uint _bountyId, uint _fulfillmentId) - public - constant - validateBountyArrayIndex(_bountyId) - validateFulfillmentArrayIndex(_bountyId, _fulfillmentId) - returns (bool, address, string) - { - return (fulfillments[_bountyId][_fulfillmentId].accepted, - fulfillments[_bountyId][_fulfillmentId].fulfiller, - fulfillments[_bountyId][_fulfillmentId].data); - } - - /// @dev getBounty(): Returns the details of the bounty - /// @param _bountyId the index of the bounty - /// @return Returns a tuple for the bounty - function getBounty(uint _bountyId) - public - constant - validateBountyArrayIndex(_bountyId) - returns (address, uint, uint, bool, uint, uint) - { - return (bounties[_bountyId].issuer, - bounties[_bountyId].deadline, - bounties[_bountyId].fulfillmentAmount, - bounties[_bountyId].paysTokens, - uint(bounties[_bountyId].bountyStage), - bounties[_bountyId].balance); - } - - /// @dev getBountyArbiter(): Returns the arbiter of the bounty - /// @param _bountyId the index of the bounty - /// @return Returns an address for the arbiter of the bounty - function getBountyArbiter(uint _bountyId) - public - constant - validateBountyArrayIndex(_bountyId) - returns (address) - { - return (bounties[_bountyId].arbiter); - } - - /// @dev getBountyData(): Returns the data of the bounty - /// @param _bountyId the index of the bounty - /// @return Returns a string for the bounty data - function getBountyData(uint _bountyId) - public - constant - validateBountyArrayIndex(_bountyId) - returns (string) - { - return (bounties[_bountyId].data); - } - - /// @dev getBountyToken(): Returns the token contract of the bounty - /// @param _bountyId the index of the bounty - /// @return Returns an address for the token that the bounty uses - function getBountyToken(uint _bountyId) - public - constant - validateBountyArrayIndex(_bountyId) - returns (address) - { - return (tokenContracts[_bountyId]); - } - - /// @dev getNumBounties() returns the number of bounties in the registry - /// @return Returns the number of bounties - function getNumBounties() - public - constant - returns (uint) - { - return bounties.length; - } - - /// @dev getNumFulfillments() returns the number of fulfillments for a given milestone - /// @param _bountyId the index of the bounty - /// @return Returns the number of fulfillments - function getNumFulfillments(uint _bountyId) - public - constant - validateBountyArrayIndex(_bountyId) - returns (uint) - { - return fulfillments[_bountyId].length; - } - - /* - * Internal functions - */ - - /// @dev transitionToState(): transitions the contract to the - /// state passed in the parameter `_newStage` given the - /// conditions stated in the body of the function - /// @param _bountyId the index of the bounty - /// @param _newStage the new stage to transition to - function transitionToState(uint _bountyId, BountyStages _newStage) - internal - { - bounties[_bountyId].bountyStage = _newStage; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/bounties/inherited/HumanStandardToken.sol b/apps/shared/test-helpers/contracts/lib/bounties/inherited/HumanStandardToken.sol deleted file mode 100644 index 446426d7d..000000000 --- a/apps/shared/test-helpers/contracts/lib/bounties/inherited/HumanStandardToken.sol +++ /dev/null @@ -1,57 +0,0 @@ -/* -This Token Contract implements the standard token functionality (https://github.com/ethereum/EIPs/issues/20) as well as the following OPTIONAL extras intended for use by humans. - -In other words. This is intended for deployment in something like a Token Factory or Mist wallet, and then used by humans. -Imagine coins, currencies, shares, voting weight, etc. -Machine-based, rapid creation of many tokens would not necessarily need these extra features or will be minted in other manners. - -1) Initial Finite Supply (upon creation one specifies how much is minted). -2) In the absence of a token registry: Optional Decimal, Symbol & Name. -3) Optional approveAndCall() functionality to notify a contract if an approval() has occurred. - -.*/ - -import "./StandardToken.sol"; - -pragma solidity ^0.4.8; - -contract HumanStandardToken is StandardToken { - - /* Public variables of the token */ - - /* - NOTE: - The following variables are OPTIONAL vanities. One does not have to include them. - They allow one to customise the token contract & in no way influences the core functionality. - Some wallets/interfaces might not even bother to look at this information. - */ - string public name; //fancy name: eg Simon Bucks - uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether. - string public symbol; //An identifier: eg SBX - string public version = 'H0.1'; //human 0.1 standard. Just an arbitrary versioning scheme. - - function HumanStandardToken( - uint256 _initialAmount, - string _tokenName, - uint8 _decimalUnits, - string _tokenSymbol - ) { - balances[msg.sender] = _initialAmount; // Give the creator all initial tokens - totalSupply = _initialAmount; // Update total supply - name = _tokenName; // Set the name for display purposes - decimals = _decimalUnits; // Amount of decimals for display purposes - symbol = _tokenSymbol; // Set the symbol for display purposes - } - - /* Approves and then calls the receiving contract */ - function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns (bool success) { - allowed[msg.sender][_spender] = _value; - Approval(msg.sender, _spender, _value); - - //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. - //receiveApproval(address _from, uint256 _value, address _tokenContract, bytes _extraData) - //it is assumed that when does this that the call *should* succeed, otherwise one would use vanilla approve instead. - require(_spender.call(bytes4(bytes32(sha3("receiveApproval(address,uint256,address,bytes)"))), msg.sender, _value, this, _extraData)); - return true; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/bounties/inherited/StandardToken.sol b/apps/shared/test-helpers/contracts/lib/bounties/inherited/StandardToken.sol deleted file mode 100644 index 961106a87..000000000 --- a/apps/shared/test-helpers/contracts/lib/bounties/inherited/StandardToken.sol +++ /dev/null @@ -1,56 +0,0 @@ -/* -You should inherit from StandardToken or, for a token like you would want to -deploy in something like Mist, see HumanStandardToken.sol. -(This implements ONLY the standard functions and NOTHING else. -If you deploy this, you won't have anything useful.) - -Implements ERC 20 Token standard: https://github.com/ethereum/EIPs/issues/20 -.*/ -pragma solidity ^0.4.8; - -import "./Token.sol"; - -contract StandardToken is Token { - - function transfer(address _to, uint256 _value) returns (bool success) { - //Default assumes totalSupply can't be over max (2^256 - 1). - //If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap. - //Replace the if with this one instead. - //if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) { - if (balances[msg.sender] >= _value && _value > 0) { - balances[msg.sender] -= _value; - balances[_to] += _value; - Transfer(msg.sender, _to, _value); - return true; - } else { return false; } - } - - function transferFrom(address _from, address _to, uint256 _value) returns (bool success) { - //same as above. Replace this line with the following if you want to protect against wrapping uints. - //if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) { - if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) { - balances[_to] += _value; - balances[_from] -= _value; - allowed[_from][msg.sender] -= _value; - Transfer(_from, _to, _value); - return true; - } else { return false; } - } - - function balanceOf(address _owner) constant returns (uint256 balance) { - return balances[_owner]; - } - - function approve(address _spender, uint256 _value) returns (bool success) { - allowed[msg.sender][_spender] = _value; - Approval(msg.sender, _spender, _value); - return true; - } - - function allowance(address _owner, address _spender) constant returns (uint256 remaining) { - return allowed[_owner][_spender]; - } - - mapping (address => uint256) balances; - mapping (address => mapping (address => uint256)) allowed; -} diff --git a/apps/shared/test-helpers/contracts/lib/bounties/inherited/Token.sol b/apps/shared/test-helpers/contracts/lib/bounties/inherited/Token.sol deleted file mode 100644 index 93215431b..000000000 --- a/apps/shared/test-helpers/contracts/lib/bounties/inherited/Token.sol +++ /dev/null @@ -1,48 +0,0 @@ -// Abstract contract for the full ERC 20 Token standard -// https://github.com/ethereum/EIPs/issues/20 -pragma solidity ^0.4.8; - -contract Token { - /* This is a slight change to the ERC20 base standard. - function totalSupply() constant returns (uint256 supply); - is replaced with: - uint256 public totalSupply; - This automatically creates a getter function for the totalSupply. - This is moved to the base contract since public getter functions are not - currently recognised as an implementation of the matching abstract - function by the compiler. - */ - /// total amount of tokens - uint256 public totalSupply; - - /// @param _owner The address from which the balance will be retrieved - /// @return The balance - function balanceOf(address _owner) constant returns (uint256 balance); - - /// @notice send `_value` token to `_to` from `msg.sender` - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - /// @return Whether the transfer was successful or not - function transfer(address _to, uint256 _value) returns (bool success); - - /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from` - /// @param _from The address of the sender - /// @param _to The address of the recipient - /// @param _value The amount of token to be transferred - /// @return Whether the transfer was successful or not - function transferFrom(address _from, address _to, uint256 _value) returns (bool success); - - /// @notice `msg.sender` approves `_spender` to spend `_value` tokens - /// @param _spender The address of the account able to transfer the tokens - /// @param _value The amount of tokens to be approved for transfer - /// @return Whether the approval was successful or not - function approve(address _spender, uint256 _value) returns (bool success); - - /// @param _owner The address of the account owning tokens - /// @param _spender The address of the account able to transfer the tokens - /// @return Amount of remaining tokens allowed to spent - function allowance(address _owner, address _spender) constant returns (uint256 remaining); - - event Transfer(address indexed _from, address indexed _to, uint256 _value); - event Approval(address indexed _owner, address indexed _spender, uint256 _value); -} diff --git a/apps/shared/test-helpers/contracts/lib/ens/AbstractENS.sol b/apps/shared/test-helpers/contracts/lib/ens/AbstractENS.sol deleted file mode 100644 index 32e77f27d..000000000 --- a/apps/shared/test-helpers/contracts/lib/ens/AbstractENS.sol +++ /dev/null @@ -1,24 +0,0 @@ -pragma solidity ^0.4.15; - - -interface AbstractENS { - function owner(bytes32 _node) public constant returns (address); - function resolver(bytes32 _node) public constant returns (address); - function ttl(bytes32 _node) public constant returns (uint64); - function setOwner(bytes32 _node, address _owner) public; - function setSubnodeOwner(bytes32 _node, bytes32 label, address _owner) public; - function setResolver(bytes32 _node, address _resolver) public; - function setTTL(bytes32 _node, uint64 _ttl) public; - - // Logged when the owner of a node assigns a new owner to a subnode. - event NewOwner(bytes32 indexed _node, bytes32 indexed _label, address _owner); - - // Logged when the owner of a node transfers ownership to a new account. - event Transfer(bytes32 indexed _node, address _owner); - - // Logged when the resolver for a node changes. - event NewResolver(bytes32 indexed _node, address _resolver); - - // Logged when the TTL of a node changes - event NewTTL(bytes32 indexed _node, uint64 _ttl); -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/lib/ens/ENS.sol b/apps/shared/test-helpers/contracts/lib/ens/ENS.sol deleted file mode 100644 index 81dc93000..000000000 --- a/apps/shared/test-helpers/contracts/lib/ens/ENS.sol +++ /dev/null @@ -1,95 +0,0 @@ -pragma solidity ^0.4.0; - - -import './AbstractENS.sol'; - -/** - * The ENS registry contract. - */ -contract ENS is AbstractENS { - struct Record { - address owner; - address resolver; - uint64 ttl; - } - - mapping(bytes32=>Record) records; - - // Permits modifications only by the owner of the specified node. - modifier only_owner(bytes32 node) { - if (records[node].owner != msg.sender) throw; - _; - } - - /** - * Constructs a new ENS registrar. - */ - function ENS() public { - records[0].owner = msg.sender; - } - - /** - * Returns the address that owns the specified node. - */ - function owner(bytes32 node) public constant returns (address) { - return records[node].owner; - } - - /** - * Returns the address of the resolver for the specified node. - */ - function resolver(bytes32 node) public constant returns (address) { - return records[node].resolver; - } - - /** - * Returns the TTL of a node, and any records associated with it. - */ - function ttl(bytes32 node) public constant returns (uint64) { - return records[node].ttl; - } - - /** - * Transfers ownership of a node to a new address. May only be called by the current - * owner of the node. - * @param node The node to transfer ownership of. - * @param owner The address of the new owner. - */ - function setOwner(bytes32 node, address owner) only_owner(node) public { - Transfer(node, owner); - records[node].owner = owner; - } - - /** - * Transfers ownership of a subnode keccak256(node, label) to a new address. May only be - * called by the owner of the parent node. - * @param node The parent node. - * @param label The hash of the label specifying the subnode. - * @param owner The address of the new owner. - */ - function setSubnodeOwner(bytes32 node, bytes32 label, address owner) only_owner(node) public { - var subnode = keccak256(node, label); - NewOwner(node, label, owner); - records[subnode].owner = owner; - } - - /** - * Sets the resolver address for the specified node. - * @param node The node to update. - * @param resolver The address of the resolver. - */ - function setResolver(bytes32 node, address resolver) only_owner(node) public { - NewResolver(node, resolver); - records[node].resolver = resolver; - } - - /** - * Sets the TTL for the specified node. - * @param node The node to update. - * @param ttl The TTL in seconds. - */ - function setTTL(bytes32 node, uint64 ttl) only_owner(node) public { - NewTTL(node, ttl); - records[node].ttl = ttl; - } -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/lib/ens/PublicResolver.sol b/apps/shared/test-helpers/contracts/lib/ens/PublicResolver.sol deleted file mode 100644 index d67f4fa7b..000000000 --- a/apps/shared/test-helpers/contracts/lib/ens/PublicResolver.sol +++ /dev/null @@ -1,212 +0,0 @@ -pragma solidity ^0.4.0; - -import './AbstractENS.sol'; - -/** - * A simple resolver anyone can use; only allows the owner of a node to set its - * address. - */ -contract PublicResolver { - bytes4 constant INTERFACE_META_ID = 0x01ffc9a7; - bytes4 constant ADDR_INTERFACE_ID = 0x3b3b57de; - bytes4 constant CONTENT_INTERFACE_ID = 0xd8389dc5; - bytes4 constant NAME_INTERFACE_ID = 0x691f3431; - bytes4 constant ABI_INTERFACE_ID = 0x2203ab56; - bytes4 constant PUBKEY_INTERFACE_ID = 0xc8690233; - bytes4 constant TEXT_INTERFACE_ID = 0x59d1d43c; - - event AddrChanged(bytes32 indexed node, address a); - event ContentChanged(bytes32 indexed node, bytes32 hash); - event NameChanged(bytes32 indexed node, string name); - event ABIChanged(bytes32 indexed node, uint256 indexed contentType); - event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y); - event TextChanged(bytes32 indexed node, string indexed indexedKey, string key); - - struct PublicKey { - bytes32 x; - bytes32 y; - } - - struct Record { - address addr; - bytes32 content; - string name; - PublicKey pubkey; - mapping(string=>string) text; - mapping(uint256=>bytes) abis; - } - - AbstractENS ens; - mapping(bytes32=>Record) records; - - modifier only_owner(bytes32 node) { - if (ens.owner(node) != msg.sender) throw; - _; - } - - /** - * Constructor. - * @param ensAddr The ENS registrar contract. - */ - function PublicResolver(AbstractENS ensAddr) public { - ens = ensAddr; - } - - /** - * Returns true if the resolver implements the interface specified by the provided hash. - * @param interfaceID The ID of the interface to check for. - * @return True if the contract implements the requested interface. - */ - function supportsInterface(bytes4 interfaceID) public pure returns (bool) { - return interfaceID == ADDR_INTERFACE_ID || - interfaceID == CONTENT_INTERFACE_ID || - interfaceID == NAME_INTERFACE_ID || - interfaceID == ABI_INTERFACE_ID || - interfaceID == PUBKEY_INTERFACE_ID || - interfaceID == TEXT_INTERFACE_ID || - interfaceID == INTERFACE_META_ID; - } - - /** - * Returns the address associated with an ENS node. - * @param node The ENS node to query. - * @return The associated address. - */ - function addr(bytes32 node) public constant returns (address ret) { - ret = records[node].addr; - } - - /** - * Sets the address associated with an ENS node. - * May only be called by the owner of that node in the ENS registry. - * @param node The node to update. - * @param addr The address to set. - */ - function setAddr(bytes32 node, address addr) only_owner(node) public { - records[node].addr = addr; - AddrChanged(node, addr); - } - - /** - * Returns the content hash associated with an ENS node. - * Note that this resource type is not standardized, and will likely change - * in future to a resource type based on multihash. - * @param node The ENS node to query. - * @return The associated content hash. - */ - function content(bytes32 node) public constant returns (bytes32 ret) { - ret = records[node].content; - } - - /** - * Sets the content hash associated with an ENS node. - * May only be called by the owner of that node in the ENS registry. - * Note that this resource type is not standardized, and will likely change - * in future to a resource type based on multihash. - * @param node The node to update. - * @param hash The content hash to set - */ - function setContent(bytes32 node, bytes32 hash) only_owner(node) public { - records[node].content = hash; - ContentChanged(node, hash); - } - - /** - * Returns the name associated with an ENS node, for reverse records. - * Defined in EIP181. - * @param node The ENS node to query. - * @return The associated name. - */ - function name(bytes32 node) public constant returns (string ret) { - ret = records[node].name; - } - - /** - * Sets the name associated with an ENS node, for reverse records. - * May only be called by the owner of that node in the ENS registry. - * @param node The node to update. - * @param name The name to set. - */ - function setName(bytes32 node, string name) only_owner(node) public { - records[node].name = name; - NameChanged(node, name); - } - - /** - * Returns the ABI associated with an ENS node. - * Defined in EIP205. - * @param node The ENS node to query - * @param contentTypes A bitwise OR of the ABI formats accepted by the caller. - * @return contentType The content type of the return value - * @return data The ABI data - */ - function ABI(bytes32 node, uint256 contentTypes) public constant returns (uint256 contentType, bytes data) { - var record = records[node]; - for(contentType = 1; contentType <= contentTypes; contentType <<= 1) { - if ((contentType & contentTypes) != 0 && record.abis[contentType].length > 0) { - data = record.abis[contentType]; - return; - } - } - contentType = 0; - } - - /** - * Sets the ABI associated with an ENS node. - * Nodes may have one ABI of each content type. To remove an ABI, set it to - * the empty string. - * @param node The node to update. - * @param contentType The content type of the ABI - * @param data The ABI data. - */ - function setABI(bytes32 node, uint256 contentType, bytes data) only_owner(node) public { - // Content types must be powers of 2 - if (((contentType - 1) & contentType) != 0) throw; - - records[node].abis[contentType] = data; - ABIChanged(node, contentType); - } - - /** - * Returns the SECP256k1 public key associated with an ENS node. - * Defined in EIP 619. - * @param node The ENS node to query - * @return x, y the X and Y coordinates of the curve point for the public key. - */ - function pubkey(bytes32 node) public constant returns (bytes32 x, bytes32 y) { - return (records[node].pubkey.x, records[node].pubkey.y); - } - - /** - * Sets the SECP256k1 public key associated with an ENS node. - * @param node The ENS node to query - * @param x the X coordinate of the curve point for the public key. - * @param y the Y coordinate of the curve point for the public key. - */ - function setPubkey(bytes32 node, bytes32 x, bytes32 y) only_owner(node) public { - records[node].pubkey = PublicKey(x, y); - PubkeyChanged(node, x, y); - } - - /** - * Returns the text data associated with an ENS node and key. - * @param node The ENS node to query. - * @param key The text data key to query. - * @return The associated text data. - */ - function text(bytes32 node, string key) public constant returns (string ret) { - ret = records[node].text[key]; - } - - /** - * Sets the text data associated with an ENS node and key. - * May only be called by the owner of that node in the ENS registry. - * @param node The node to update. - * @param key The key to set. - * @param value The text data value to set. - */ - function setText(bytes32 node, string key, string value) only_owner(node) public { - records[node].text[key] = value; - TextChanged(node, key, key); - } -} \ No newline at end of file diff --git a/apps/shared/test-helpers/contracts/lib/math/Math.sol b/apps/shared/test-helpers/contracts/lib/math/Math.sol deleted file mode 100644 index 995250825..000000000 --- a/apps/shared/test-helpers/contracts/lib/math/Math.sol +++ /dev/null @@ -1,24 +0,0 @@ -pragma solidity ^0.4.24; - -/** - * @title Math - * @dev Assorted math operations - */ - -library Math { - function max64(uint64 a, uint64 b) internal pure returns (uint64) { - return a >= b ? a : b; - } - - function min64(uint64 a, uint64 b) internal pure returns (uint64) { - return a < b ? a : b; - } - - function max256(uint256 a, uint256 b) internal pure returns (uint256) { - return a >= b ? a : b; - } - - function min256(uint256 a, uint256 b) internal pure returns (uint256) { - return a < b ? a : b; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/math/SafeMath.sol b/apps/shared/test-helpers/contracts/lib/math/SafeMath.sol deleted file mode 100644 index b538d571c..000000000 --- a/apps/shared/test-helpers/contracts/lib/math/SafeMath.sol +++ /dev/null @@ -1,69 +0,0 @@ -// See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol -// Adapted to use pragma ^0.4.24 and satisfy our linter rules - -pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that revert on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, reverts on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - uint256 c = _a * _b; - require(c / _a == _b); - - return c; - } - - /** - * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - require(_b > 0); // Solidity only automatically asserts when dividing by 0 - uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - require(_b <= _a); - uint256 c = _a - _b; - - return c; - } - - /** - * @dev Adds two numbers, reverts on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256) { - uint256 c = _a + _b; - require(c >= _a); - - return c; - } - - /** - * @dev Divides two numbers and returns the remainder (unsigned integer modulo), - * reverts when dividing by zero. - */ - function mod(uint256 a, uint256 b) internal pure returns (uint256) { - require(b != 0); - return a % b; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/math/SafeMath64.sol b/apps/shared/test-helpers/contracts/lib/math/SafeMath64.sol deleted file mode 100644 index d549a2b76..000000000 --- a/apps/shared/test-helpers/contracts/lib/math/SafeMath64.sol +++ /dev/null @@ -1,63 +0,0 @@ -// See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol -// Adapted for uint64, pragma ^0.4.24, and satisfying our linter rules -// Also optimized the mul() implementation, see https://github.com/aragon/aragonOS/pull/417 - -pragma solidity ^0.4.24; - - -/** - * @title SafeMath64 - * @dev Math operations for uint64 with safety checks that revert on error - */ -library SafeMath64 { - - /** - * @dev Multiplies two numbers, reverts on overflow. - */ - function mul(uint64 _a, uint64 _b) internal pure returns (uint64) { - uint256 c = uint256(_a) * uint256(_b); - require(c < 0x010000000000000000); // 2**64 (less gas this way) - - return uint64(c); - } - - /** - * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. - */ - function div(uint64 _a, uint64 _b) internal pure returns (uint64) { - require(_b > 0); // Solidity only automatically asserts when dividing by 0 - uint64 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint64 _a, uint64 _b) internal pure returns (uint64) { - require(_b <= _a); - uint64 c = _a - _b; - - return c; - } - - /** - * @dev Adds two numbers, reverts on overflow. - */ - function add(uint64 _a, uint64 _b) internal pure returns (uint64) { - uint64 c = _a + _b; - require(c >= _a); - - return c; - } - - /** - * @dev Divides two numbers and returns the remainder (unsigned integer modulo), - * reverts when dividing by zero. - */ - function mod(uint64 a, uint64 b) internal pure returns (uint64) { - require(b != 0); - return a % b; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/math/SafeMath8.sol b/apps/shared/test-helpers/contracts/lib/math/SafeMath8.sol deleted file mode 100644 index b5588dc7d..000000000 --- a/apps/shared/test-helpers/contracts/lib/math/SafeMath8.sol +++ /dev/null @@ -1,63 +0,0 @@ -// See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol -// Adapted for uint8, pragma ^0.4.24, and satisfying our linter rules -// Also optimized the mul() implementation, see https://github.com/aragon/aragonOS/pull/417 - -pragma solidity ^0.4.24; - - -/** - * @title SafeMath8 - * @dev Math operations for uint8 with safety checks that revert on error - */ -library SafeMath8 { - - /** - * @dev Multiplies two numbers, reverts on overflow. - */ - function mul(uint8 _a, uint8 _b) internal pure returns (uint8) { - uint256 c = uint256(_a) * uint256(_b); - require(c < 256); - - return uint8(c); - } - - /** - * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. - */ - function div(uint8 _a, uint8 _b) internal pure returns (uint8) { - require(_b > 0); // Solidity only automatically asserts when dividing by 0 - uint8 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint8 _a, uint8 _b) internal pure returns (uint8) { - require(_b <= _a); - uint8 c = _a - _b; - - return c; - } - - /** - * @dev Adds two numbers, reverts on overflow. - */ - function add(uint8 _a, uint8 _b) internal pure returns (uint8) { - uint8 c = _a + _b; - require(c >= _a); - - return c; - } - - /** - * @dev Divides two numbers and returns the remainder (unsigned integer modulo), - * reverts when dividing by zero. - */ - function mod(uint8 a, uint8 b) internal pure returns (uint8) { - require(b != 0); - return a % b; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/minime/ITokenController.sol b/apps/shared/test-helpers/contracts/lib/minime/ITokenController.sol deleted file mode 100644 index 2c9bd0623..000000000 --- a/apps/shared/test-helpers/contracts/lib/minime/ITokenController.sol +++ /dev/null @@ -1,27 +0,0 @@ -pragma solidity ^0.4.24; - -/// @dev The token controller contract must implement these functions - - -interface ITokenController { - /// @notice Called when `_owner` sends ether to the MiniMe Token contract - /// @param _owner The address that sent the ether to create tokens - /// @return True if the ether is accepted, false if it throws - function proxyPayment(address _owner) external payable returns(bool); - - /// @notice Notifies the controller about a token transfer allowing the - /// controller to react if desired - /// @param _from The origin of the transfer - /// @param _to The destination of the transfer - /// @param _amount The amount of the transfer - /// @return False if the controller does not authorize the transfer - function onTransfer(address _from, address _to, uint _amount) external returns(bool); - - /// @notice Notifies the controller about an approval allowing the - /// controller to react if desired - /// @param _owner The address that calls `approve()` - /// @param _spender The spender in the `approve()` call - /// @param _amount The amount in the `approve()` call - /// @return False if the controller does not authorize the approval - function onApprove(address _owner, address _spender, uint _amount) external returns(bool); -} diff --git a/apps/shared/test-helpers/contracts/lib/minime/MiniMeToken.sol b/apps/shared/test-helpers/contracts/lib/minime/MiniMeToken.sol deleted file mode 100644 index 66fa337de..000000000 --- a/apps/shared/test-helpers/contracts/lib/minime/MiniMeToken.sol +++ /dev/null @@ -1,579 +0,0 @@ -pragma solidity ^0.4.24; - -/* - Copyright 2016, Jordi Baylina - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - */ - -/// @title MiniMeToken Contract -/// @author Jordi Baylina -/// @dev This token contract's goal is to make it easy for anyone to clone this -/// token using the token distribution at a given block, this will allow DAO's -/// and DApps to upgrade their features in a decentralized manner without -/// affecting the original token -/// @dev It is ERC20 compliant, but still needs to under go further testing. - -import "./ITokenController.sol"; - -contract Controlled { // solium-disable-line blank-lines - /// @notice The address of the controller is the only address that can call - /// a function with this modifier - modifier onlyController { - require(msg.sender == controller); - _; - } - - address public controller; - - constructor() public { controller = msg.sender;} - - /// @notice Changes the controller of the contract - /// @param _newController The new controller of the contract - function changeController(address _newController) public onlyController { - controller = _newController; - } -} - -contract ApproveAndCallFallBack { // solium-disable-line blank-lines - function receiveApproval( - address from, - uint256 _amount, - address _token, - bytes _data) public; -} - -/// @dev The actual token contract, the default controller is the msg.sender -/// that deploys the contract, so usually this token will be deployed by a -/// token controller contract, which Giveth will call a "Campaign" -contract MiniMeToken is Controlled { // solium-disable-line blank-lines - - string public name; //The Token's name: e.g. DigixDAO Tokens - uint8 public decimals; //Number of decimals of the smallest unit - string public symbol; //An identifier: e.g. REP - string public version = "MMT_0.1"; //An arbitrary versioning scheme - - - /// @dev `Checkpoint` is the structure that attaches a block number to a - /// given value, the block number attached is the one that last changed the - /// value - struct Checkpoint { - - // `fromBlock` is the block number that the value was generated from - uint128 fromBlock; - - // `value` is the amount of tokens at a specific block number - uint128 value; - } - - // `parentToken` is the Token address that was cloned to produce this token; - // it will be 0x0 for a token that was not cloned - MiniMeToken public parentToken; - - // `parentSnapShotBlock` is the block number from the Parent Token that was - // used to determine the initial distribution of the Clone Token - uint public parentSnapShotBlock; - - // `creationBlock` is the block number that the Clone Token was created - uint public creationBlock; - - // `balances` is the map that tracks the balance of each address, in this - // contract when the balance changes the block number that the change - // occurred is also included in the map - mapping (address => Checkpoint[]) balances; - - // `allowed` tracks any extra transfer rights as in all ERC20 tokens - mapping (address => mapping (address => uint256)) allowed; - - // Tracks the history of the `totalSupply` of the token - Checkpoint[] totalSupplyHistory; - - // Flag that determines if the token is transferable or not. - bool public transfersEnabled; - - // The factory used to create new clone tokens - MiniMeTokenFactory public tokenFactory; - -//////////////// -// Constructor -//////////////// - - /// @notice Constructor to create a MiniMeToken - /// @param _tokenFactory The address of the MiniMeTokenFactory contract that - /// will create the Clone token contracts, the token factory needs to be - /// deployed first - /// @param _parentToken Address of the parent token, set to 0x0 if it is a - /// new token - /// @param _parentSnapShotBlock Block of the parent token that will - /// determine the initial distribution of the clone token, set to 0 if it - /// is a new token - /// @param _tokenName Name of the new token - /// @param _decimalUnits Number of decimals of the new token - /// @param _tokenSymbol Token Symbol for the new token - /// @param _transfersEnabled If true, tokens will be able to be transferred - constructor( // solium-disable-line blank-lines - MiniMeTokenFactory _tokenFactory, - MiniMeToken _parentToken, - uint _parentSnapShotBlock, - string _tokenName, - uint8 _decimalUnits, - string _tokenSymbol, - bool _transfersEnabled - ) public - { - tokenFactory = _tokenFactory; - name = _tokenName; // Set the name - decimals = _decimalUnits; // Set the decimals - symbol = _tokenSymbol; // Set the symbol - parentToken = _parentToken; - parentSnapShotBlock = _parentSnapShotBlock; - transfersEnabled = _transfersEnabled; - creationBlock = block.number; - } - - -/////////////////// -// ERC20 Methods -/////////////////// - - /// @notice Send `_amount` tokens to `_to` from `msg.sender` - /// @param _to The address of the recipient - /// @param _amount The amount of tokens to be transferred - /// @return Whether the transfer was successful or not - function transfer(address _to, uint256 _amount) public returns (bool success) { - require(transfersEnabled); - return doTransfer(msg.sender, _to, _amount); - } - - /// @notice Send `_amount` tokens to `_to` from `_from` on the condition it - /// is approved by `_from` - /// @param _from The address holding the tokens being transferred - /// @param _to The address of the recipient - /// @param _amount The amount of tokens to be transferred - /// @return True if the transfer was successful - function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success) { - - // The controller of this contract can move tokens around at will, - // this is important to recognize! Confirm that you trust the - // controller of this contract, which in most situations should be - // another open source smart contract or 0x0 - if (msg.sender != controller) { - require(transfersEnabled); - - // The standard ERC 20 transferFrom functionality - if (allowed[_from][msg.sender] < _amount) - return false; - allowed[_from][msg.sender] -= _amount; - } - return doTransfer(_from, _to, _amount); - } - - /// @dev This is the actual transfer function in the token contract, it can - /// only be called by other functions in this contract. - /// @param _from The address holding the tokens being transferred - /// @param _to The address of the recipient - /// @param _amount The amount of tokens to be transferred - /// @return True if the transfer was successful - function doTransfer(address _from, address _to, uint _amount) internal returns(bool) { - if (_amount == 0) { - return true; - } - require(parentSnapShotBlock < block.number); - // Do not allow transfer to 0x0 or the token contract itself - require((_to != 0) && (_to != address(this))); - // If the amount being transfered is more than the balance of the - // account the transfer returns false - uint previousBalanceFrom = balanceOfAt(_from, block.number); - if (previousBalanceFrom < _amount) { - return false; - } - // Alerts the token controller of the transfer - if (isContract(controller)) { - // Adding the ` == true` makes the linter shut up so... - require(ITokenController(controller).onTransfer(_from, _to, _amount) == true); - } - // First update the balance array with the new value for the address - // sending the tokens - updateValueAtNow(balances[_from], previousBalanceFrom - _amount); - // Then update the balance array with the new value for the address - // receiving the tokens - uint previousBalanceTo = balanceOfAt(_to, block.number); - require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow - updateValueAtNow(balances[_to], previousBalanceTo + _amount); - // An event to make the transfer easy to find on the blockchain - emit Transfer(_from, _to, _amount); - return true; - } - - /// @param _owner The address that's balance is being requested - /// @return The balance of `_owner` at the current block - function balanceOf(address _owner) public view returns (uint256 balance) { // solium-disable-line function-order - return balanceOfAt(_owner, block.number); - } - - /// @notice `msg.sender` approves `_spender` to spend `_amount` tokens on - /// its behalf. This is a modified version of the ERC20 approve function - /// to be a little bit safer - /// @param _spender The address of the account able to transfer the tokens - /// @param _amount The amount of tokens to be approved for transfer - /// @return True if the approval was successful - function approve(address _spender, uint256 _amount) public returns (bool success) { // solium-disable-line function-order - require(transfersEnabled); - - // To change the approve amount you first have to reduce the addresses` - // allowance to zero by calling `approve(_spender,0)` if it is not - // already 0 to mitigate the race condition described here: - // https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - require((_amount == 0) || (allowed[msg.sender][_spender] == 0)); - - // Alerts the token controller of the approve function call - if (isContract(controller)) { - // Adding the ` == true` makes the linter shut up so... - require(ITokenController(controller).onApprove(msg.sender, _spender, _amount) == true); - } - - allowed[msg.sender][_spender] = _amount; - emit Approval(msg.sender, _spender, _amount); - return true; - } - - /// @dev This function makes it easy to read the `allowed[]` map - /// @param _owner The address of the account that owns the token - /// @param _spender The address of the account able to transfer the tokens - /// @return Amount of remaining tokens of _owner that _spender is allowed - /// to spend - function allowance(address _owner, address _spender) public view returns (uint256 remaining) { // solium-disable-line function-order - return allowed[_owner][_spender]; - } - - /// @notice `msg.sender` approves `_spender` to send `_amount` tokens on - /// its behalf, and then a function is triggered in the contract that is - /// being approved, `_spender`. This allows users to use their tokens to - /// interact with contracts in one function call instead of two - /// @param _spender The address of the contract able to transfer the tokens - /// @param _amount The amount of tokens to be approved for transfer - /// @return True if the function call was successful - function approveAndCall(ApproveAndCallFallBack _spender, uint256 _amount, bytes _extraData) // solium-disable-line function-order - public returns (bool success) - { - require(approve(_spender, _amount)); - - _spender.receiveApproval( - msg.sender, - _amount, - this, - _extraData - ); - - return true; - } - - /// @dev This function makes it easy to get the total number of tokens - /// @return The total number of tokens - function totalSupply() public view returns (uint) { // solium-disable-line function-order - return totalSupplyAt(block.number); - } - -//////////////// -// Query balance and totalSupply in History -//////////////// - - /// @dev Queries the balance of `_owner` at a specific `_blockNumber` - /// @param _owner The address from which the balance will be retrieved - /// @param _blockNumber The block number when the balance is queried - /// @return The balance at `_blockNumber` - function balanceOfAt(address _owner, uint _blockNumber) public view returns (uint) { // solium-disable-line function-order - - // These next few lines are used when the balance of the token is - // requested before a check point was ever created for this token, it - // requires that the `parentToken.balanceOfAt` be queried at the - // genesis block for that token as this contains initial balance of - // this token - if ((balances[_owner].length == 0) || (balances[_owner][0].fromBlock > _blockNumber)) { - if (address(parentToken) != 0) { - return parentToken.balanceOfAt(_owner, min(_blockNumber, parentSnapShotBlock)); - } else { - // Has no parent - return 0; - } - - // This will return the expected balance during normal situations - } else { - return getValueAt(balances[_owner], _blockNumber); - } - } - - /// @notice Total amount of tokens at a specific `_blockNumber`. - /// @param _blockNumber The block number when the totalSupply is queried - /// @return The total amount of tokens at `_blockNumber` - function totalSupplyAt(uint _blockNumber) public view returns(uint) { // solium-disable-line function-order - - // These next few lines are used when the totalSupply of the token is - // requested before a check point was ever created for this token, it - // requires that the `parentToken.totalSupplyAt` be queried at the - // genesis block for this token as that contains totalSupply of this - // token at this block number. - if ((totalSupplyHistory.length == 0) || (totalSupplyHistory[0].fromBlock > _blockNumber)) { - if (address(parentToken) != 0) { - return parentToken.totalSupplyAt(min(_blockNumber, parentSnapShotBlock)); - } else { - return 0; - } - - // This will return the expected totalSupply during normal situations - } else { - return getValueAt(totalSupplyHistory, _blockNumber); - } - } - -//////////////// -// Clone Token Method -//////////////// - - /// @notice Creates a new clone token with the initial distribution being - /// this token at `_snapshotBlock` - /// @param _cloneTokenName Name of the clone token - /// @param _cloneDecimalUnits Number of decimals of the smallest unit - /// @param _cloneTokenSymbol Symbol of the clone token - /// @param _snapshotBlock Block when the distribution of the parent token is - /// copied to set the initial distribution of the new clone token; - /// if the block is zero than the actual block, the current block is used - /// @param _transfersEnabled True if transfers are allowed in the clone - /// @return The address of the new MiniMeToken Contract - function createCloneToken( // solium-disable-line function-order - string _cloneTokenName, - uint8 _cloneDecimalUnits, - string _cloneTokenSymbol, - uint _snapshotBlock, - bool _transfersEnabled - ) public returns(MiniMeToken) - { - uint256 snapshot = _snapshotBlock == 0 ? block.number - 1 : _snapshotBlock; - - MiniMeToken cloneToken = tokenFactory.createCloneToken( - this, - snapshot, - _cloneTokenName, - _cloneDecimalUnits, - _cloneTokenSymbol, - _transfersEnabled - ); - - cloneToken.changeController(msg.sender); - - // An event to make the token easy to find on the blockchain - emit NewCloneToken(address(cloneToken), snapshot); - return cloneToken; - } - -//////////////// -// Generate and destroy tokens -//////////////// - - /// @notice Generates `_amount` tokens that are assigned to `_owner` - /// @param _owner The address that will be assigned the new tokens - /// @param _amount The quantity of tokens generated - /// @return True if the tokens are generated correctly - function generateTokens(address _owner, uint _amount) // solium-disable-line function-order - public onlyController returns (bool) - { - uint curTotalSupply = totalSupply(); - require(curTotalSupply + _amount >= curTotalSupply); // Check for overflow - uint previousBalanceTo = balanceOf(_owner); - require(previousBalanceTo + _amount >= previousBalanceTo); // Check for overflow - updateValueAtNow(totalSupplyHistory, curTotalSupply + _amount); - updateValueAtNow(balances[_owner], previousBalanceTo + _amount); - emit Transfer(0, _owner, _amount); - return true; - } - - /// @notice Burns `_amount` tokens from `_owner` - /// @param _owner The address that will lose the tokens - /// @param _amount The quantity of tokens to burn - /// @return True if the tokens are burned correctly - function destroyTokens(address _owner, uint _amount) public onlyController returns (bool) { // solium-disable-line function-order - uint curTotalSupply = totalSupply(); - require(curTotalSupply >= _amount); - uint previousBalanceFrom = balanceOf(_owner); - require(previousBalanceFrom >= _amount); - updateValueAtNow(totalSupplyHistory, curTotalSupply - _amount); - updateValueAtNow(balances[_owner], previousBalanceFrom - _amount); - emit Transfer(_owner, 0, _amount); - return true; - } - -//////////////// -// Enable tokens transfers -//////////////// - - - /// @notice Enables token holders to transfer their tokens freely if true - /// @param _transfersEnabled True if transfers are allowed in the clone - function enableTransfers(bool _transfersEnabled) public onlyController { // solium-disable-line function-order - transfersEnabled = _transfersEnabled; - } - -//////////////// -// Internal helper functions to query and set a value in a snapshot array -//////////////// - - /// @dev `getValueAt` retrieves the number of tokens at a given block number - /// @param checkpoints The history of values being queried - /// @param _block The block number to retrieve the value at - /// @return The number of tokens being queried - function getValueAt(Checkpoint[] storage checkpoints, uint _block) internal view returns (uint) { - if (checkpoints.length == 0) - return 0; - - // Shortcut for the actual value - if (_block >= checkpoints[checkpoints.length-1].fromBlock) - return checkpoints[checkpoints.length-1].value; - if (_block < checkpoints[0].fromBlock) - return 0; - - // Binary search of the value in the array - uint min = 0; - uint max = checkpoints.length-1; - while (max > min) { - uint mid = (max + min + 1) / 2; - if (checkpoints[mid].fromBlock<=_block) { - min = mid; - } else { - max = mid-1; - } - } - return checkpoints[min].value; - } - - /// @dev `updateValueAtNow` used to update the `balances` map and the - /// `totalSupplyHistory` - /// @param checkpoints The history of data being updated - /// @param _value The new number of tokens - function updateValueAtNow(Checkpoint[] storage checkpoints, uint _value) internal { - if ((checkpoints.length == 0) || (checkpoints[checkpoints.length - 1].fromBlock < block.number)) { - Checkpoint storage newCheckPoint = checkpoints[checkpoints.length++]; - newCheckPoint.fromBlock = uint128(block.number); - newCheckPoint.value = uint128(_value); - } else { - Checkpoint storage oldCheckPoint = checkpoints[checkpoints.length - 1]; - oldCheckPoint.value = uint128(_value); - } - } - - /// @dev Internal function to determine if an address is a contract - /// @param _addr The address being queried - /// @return True if `_addr` is a contract - function isContract(address _addr) internal view returns(bool) { - uint size; - if (_addr == 0) - return false; - - assembly { - size := extcodesize(_addr) - } - - return size>0; - } - - /// @dev Helper function to return a min betwen the two uints - function min(uint a, uint b) internal pure returns (uint) { - return a < b ? a : b; - } - - /// @notice The fallback function: If the contract's controller has not been - /// set to 0, then the `proxyPayment` method is called which relays the - /// ether and creates tokens as described in the token controller contract - function () external payable { // solium-disable-line function-order - require(isContract(controller)); - // Adding the ` == true` makes the linter shut up so... - require(ITokenController(controller).proxyPayment.value(msg.value)(msg.sender) == true); - } - -////////// -// Safety Methods -////////// - - /// @notice This method can be used by the controller to extract mistakenly - /// sent tokens to this contract. - /// @param _token The address of the token contract that you want to recover - /// set to 0 in case you want to extract ether. - function claimTokens(address _token) public onlyController { // solium-disable-line function-order - if (_token == 0x0) { - controller.transfer(address(this).balance); - return; - } - - MiniMeToken token = MiniMeToken(_token); - uint balance = token.balanceOf(this); - token.transfer(controller, balance); - emit ClaimedTokens(_token, controller, balance); - } - -//////////////// -// Events -//////////////// - event ClaimedTokens(address indexed _token, address indexed _controller, uint _amount); - event Transfer(address indexed _from, address indexed _to, uint256 _amount); - event NewCloneToken(address indexed _cloneToken, uint _snapshotBlock); - event Approval( - address indexed _owner, - address indexed _spender, - uint256 _amount - ); - -} - - -//////////////// -// MiniMeTokenFactory -//////////////// - -/// @dev This contract is used to generate clone contracts from a contract. -/// In solidity this is the way to create a contract from a contract of the -/// same class -contract MiniMeTokenFactory { - - /// @notice Update the DApp by creating a new token with new functionalities - /// the msg.sender becomes the controller of this clone token - /// @param _parentToken Address of the token being cloned - /// @param _snapshotBlock Block of the parent token that will - /// determine the initial distribution of the clone token - /// @param _tokenName Name of the new token - /// @param _decimalUnits Number of decimals of the new token - /// @param _tokenSymbol Token Symbol for the new token - /// @param _transfersEnabled If true, tokens will be able to be transferred - /// @return The address of the new token contract - function createCloneToken( - MiniMeToken _parentToken, - uint _snapshotBlock, - string _tokenName, - uint8 _decimalUnits, - string _tokenSymbol, - bool _transfersEnabled - ) public returns (MiniMeToken) - { - MiniMeToken newToken = new MiniMeToken( - this, - _parentToken, - _snapshotBlock, - _tokenName, - _decimalUnits, - _tokenSymbol, - _transfersEnabled - ); - - newToken.changeController(msg.sender); - return newToken; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/misc/ERCProxy.sol b/apps/shared/test-helpers/contracts/lib/misc/ERCProxy.sol deleted file mode 100644 index 13da6e51d..000000000 --- a/apps/shared/test-helpers/contracts/lib/misc/ERCProxy.sol +++ /dev/null @@ -1,14 +0,0 @@ -/* - * SPDX-License-Identitifer: MIT - */ - -pragma solidity ^0.4.24; - - -contract ERCProxy { - uint256 constant public FORWARDING = 1; - uint256 constant public UPGRADEABLE = 2; - - function proxyType() public pure returns (uint256 proxyTypeId); - function implementation() public view returns (address codeAddr); -} diff --git a/apps/shared/test-helpers/contracts/lib/misc/Migrations.sol b/apps/shared/test-helpers/contracts/lib/misc/Migrations.sol deleted file mode 100644 index a74e2cce0..000000000 --- a/apps/shared/test-helpers/contracts/lib/misc/Migrations.sol +++ /dev/null @@ -1,25 +0,0 @@ -pragma solidity ^0.4.24; - - -contract Migrations { - address public owner; - uint public lastCompletedMigration; - - modifier restricted() { - if (msg.sender == owner) - _; - } - - constructor() public { - owner = msg.sender; - } - - function setCompleted(uint completed) public restricted { - lastCompletedMigration = completed; - } - - function upgrade(address newAddress) public restricted { - Migrations upgraded = Migrations(newAddress); - upgraded.setCompleted(lastCompletedMigration); - } -} diff --git a/apps/shared/test-helpers/contracts/lib/token/ERC20.sol b/apps/shared/test-helpers/contracts/lib/token/ERC20.sol deleted file mode 100644 index de963bd12..000000000 --- a/apps/shared/test-helpers/contracts/lib/token/ERC20.sol +++ /dev/null @@ -1,37 +0,0 @@ -// See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/a9f910d34f0ab33a1ae5e714f69f9596a02b4d91/contracts/token/ERC20/ERC20.sol - -pragma solidity ^0.4.24; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 { - function totalSupply() public view returns (uint256); - - function balanceOf(address _who) public view returns (uint256); - - function allowance(address _owner, address _spender) - public view returns (uint256); - - function transfer(address _to, uint256 _value) public returns (bool); - - function approve(address _spender, uint256 _value) - public returns (bool); - - function transferFrom(address _from, address _to, uint256 _value) - public returns (bool); - - event Transfer( - address indexed from, - address indexed to, - uint256 value - ); - - event Approval( - address indexed owner, - address indexed spender, - uint256 value - ); -} diff --git a/apps/shared/test-helpers/contracts/lib/zeppelin/math/Math.sol b/apps/shared/test-helpers/contracts/lib/zeppelin/math/Math.sol deleted file mode 100644 index f0d1560d5..000000000 --- a/apps/shared/test-helpers/contracts/lib/zeppelin/math/Math.sol +++ /dev/null @@ -1,25 +0,0 @@ -pragma solidity ^0.4.24; - - -/** - * @title Math - * @dev Assorted math operations - */ - -library Math { - function max64(uint64 a, uint64 b) internal pure returns (uint64) { - return a >= b ? a : b; - } - - function min64(uint64 a, uint64 b) internal pure returns (uint64) { - return a < b ? a : b; - } - - function max256(uint256 a, uint256 b) internal pure returns (uint256) { - return a >= b ? a : b; - } - - function min256(uint256 a, uint256 b) internal pure returns (uint256) { - return a < b ? a : b; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath.sol b/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath.sol deleted file mode 100644 index b538d571c..000000000 --- a/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath.sol +++ /dev/null @@ -1,69 +0,0 @@ -// See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol -// Adapted to use pragma ^0.4.24 and satisfy our linter rules - -pragma solidity ^0.4.24; - - -/** - * @title SafeMath - * @dev Math operations with safety checks that revert on error - */ -library SafeMath { - - /** - * @dev Multiplies two numbers, reverts on overflow. - */ - function mul(uint256 _a, uint256 _b) internal pure returns (uint256) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - uint256 c = _a * _b; - require(c / _a == _b); - - return c; - } - - /** - * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. - */ - function div(uint256 _a, uint256 _b) internal pure returns (uint256) { - require(_b > 0); // Solidity only automatically asserts when dividing by 0 - uint256 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint256 _a, uint256 _b) internal pure returns (uint256) { - require(_b <= _a); - uint256 c = _a - _b; - - return c; - } - - /** - * @dev Adds two numbers, reverts on overflow. - */ - function add(uint256 _a, uint256 _b) internal pure returns (uint256) { - uint256 c = _a + _b; - require(c >= _a); - - return c; - } - - /** - * @dev Divides two numbers and returns the remainder (unsigned integer modulo), - * reverts when dividing by zero. - */ - function mod(uint256 a, uint256 b) internal pure returns (uint256) { - require(b != 0); - return a % b; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath64.sol b/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath64.sol deleted file mode 100644 index 08f651223..000000000 --- a/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath64.sol +++ /dev/null @@ -1,69 +0,0 @@ -// See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol -// Adapted for uint64, pragma ^0.4.24, and satisfying our linter rules - -pragma solidity ^0.4.24; - - -/** - * @title SafeMath64 - * @dev Math operations for uint64 with safety checks that revert on error - */ -library SafeMath64 { - - /** - * @dev Multiplies two numbers, reverts on overflow. - */ - function mul(uint64 _a, uint64 _b) internal pure returns (uint64) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - uint64 c = _a * _b; - require(c / _a == _b); - - return c; - } - - /** - * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. - */ - function div(uint64 _a, uint64 _b) internal pure returns (uint64) { - require(_b > 0); // Solidity only automatically asserts when dividing by 0 - uint64 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint64 _a, uint64 _b) internal pure returns (uint64) { - require(_b <= _a); - uint64 c = _a - _b; - - return c; - } - - /** - * @dev Adds two numbers, reverts on overflow. - */ - function add(uint64 _a, uint64 _b) internal pure returns (uint64) { - uint64 c = _a + _b; - require(c >= _a); - - return c; - } - - /** - * @dev Divides two numbers and returns the remainder (unsigned integer modulo), - * reverts when dividing by zero. - */ - function mod(uint64 a, uint64 b) internal pure returns (uint64) { - require(b != 0); - return a % b; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath8.sol b/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath8.sol deleted file mode 100644 index 7a53c24ba..000000000 --- a/apps/shared/test-helpers/contracts/lib/zeppelin/math/SafeMath8.sol +++ /dev/null @@ -1,69 +0,0 @@ -// See https://github.com/OpenZeppelin/openzeppelin-solidity/blob/d51e38758e1d985661534534d5c61e27bece5042/contracts/math/SafeMath.sol -// Adapted for uint8, pragma ^0.4.24, and satisfying our linter rules - -pragma solidity ^0.4.24; - - -/** - * @title SafeMath8 - * @dev Math operations for uint8 with safety checks that revert on error - */ -library SafeMath8 { - - /** - * @dev Multiplies two numbers, reverts on overflow. - */ - function mul(uint8 _a, uint8 _b) internal pure returns (uint8) { - // Gas optimization: this is cheaper than requiring 'a' not being zero, but the - // benefit is lost if 'b' is also tested. - // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522 - if (_a == 0) { - return 0; - } - - uint8 c = _a * _b; - require(c / _a == _b); - - return c; - } - - /** - * @dev Integer division of two numbers truncating the quotient, reverts on division by zero. - */ - function div(uint8 _a, uint8 _b) internal pure returns (uint8) { - require(_b > 0); // Solidity only automatically asserts when dividing by 0 - uint8 c = _a / _b; - // assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold - - return c; - } - - /** - * @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend). - */ - function sub(uint8 _a, uint8 _b) internal pure returns (uint8) { - require(_b <= _a); - uint8 c = _a - _b; - - return c; - } - - /** - * @dev Adds two numbers, reverts on overflow. - */ - function add(uint8 _a, uint8 _b) internal pure returns (uint8) { - uint8 c = _a + _b; - require(c >= _a); - - return c; - } - - /** - * @dev Divides two numbers and returns the remainder (unsigned integer modulo), - * reverts when dividing by zero. - */ - function mod(uint8 a, uint8 b) internal pure returns (uint8) { - require(b != 0); - return a % b; - } -} diff --git a/apps/shared/test-helpers/contracts/lib/zeppelin/token/BasicToken.sol b/apps/shared/test-helpers/contracts/lib/zeppelin/token/BasicToken.sol deleted file mode 100644 index a395febec..000000000 --- a/apps/shared/test-helpers/contracts/lib/zeppelin/token/BasicToken.sol +++ /dev/null @@ -1,44 +0,0 @@ -pragma solidity ^0.4.24; - - -import "./ERC20Basic.sol"; -import "../math/SafeMath.sol"; - - -/** - * @title Basic token - * @dev Basic version of StandardToken, with no allowances. - */ -contract BasicToken is ERC20Basic { - using SafeMath for uint256; - uint256 totalSupply_; - - mapping(address => uint256) balances; - - function totalSupply() public view returns (uint256) { return totalSupply_; } - /** - * @dev transfer token for a specified address - * @param _to The address to transfer to. - * @param _value The amount to be transferred. - */ - function transfer(address _to, uint256 _value) public returns (bool) { - require(_to != address(0)); - require(_value <= balances[msg.sender]); - - // SafeMath.sub will throw if there is not enough balance. - balances[msg.sender] = balances[msg.sender].sub(_value); - balances[_to] = balances[_to].add(_value); - emit Transfer(msg.sender, _to, _value); - return true; - } - - /** - * @dev Gets the balance of the specified address. - * @param _owner The address to query the the balance of. - * @return An uint256 representing the amount owned by the passed address. - */ - function balanceOf(address _owner) public view returns (uint256 balance) { - return balances[_owner]; - } - -} diff --git a/apps/shared/test-helpers/contracts/lib/zeppelin/token/ERC20.sol b/apps/shared/test-helpers/contracts/lib/zeppelin/token/ERC20.sol deleted file mode 100644 index 578e0355e..000000000 --- a/apps/shared/test-helpers/contracts/lib/zeppelin/token/ERC20.sol +++ /dev/null @@ -1,16 +0,0 @@ -pragma solidity ^0.4.24; - - -import "./ERC20Basic.sol"; - - -/** - * @title ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/20 - */ -contract ERC20 is ERC20Basic { - function allowance(address owner, address spender) public view returns (uint256); - function transferFrom(address from, address to, uint256 value) public returns (bool); - function approve(address spender, uint256 value) public returns (bool); - event Approval(address indexed owner, address indexed spender, uint256 value); -} diff --git a/apps/shared/test-helpers/contracts/lib/zeppelin/token/ERC20Basic.sol b/apps/shared/test-helpers/contracts/lib/zeppelin/token/ERC20Basic.sol deleted file mode 100644 index c326601de..000000000 --- a/apps/shared/test-helpers/contracts/lib/zeppelin/token/ERC20Basic.sol +++ /dev/null @@ -1,14 +0,0 @@ -pragma solidity ^0.4.24; - - -/** - * @title ERC20Basic - * @dev Simpler version of ERC20 interface - * @dev see https://github.com/ethereum/EIPs/issues/179 - */ -contract ERC20Basic { - function totalSupply() public view returns (uint256); - function balanceOf(address who) public view returns (uint256); - function transfer(address to, uint256 value) public returns (bool); - event Transfer(address indexed from, address indexed to, uint256 value); -} diff --git a/apps/shared/test-helpers/contracts/lib/zeppelin/token/StandardToken.sol b/apps/shared/test-helpers/contracts/lib/zeppelin/token/StandardToken.sol deleted file mode 100644 index fcb5beabb..000000000 --- a/apps/shared/test-helpers/contracts/lib/zeppelin/token/StandardToken.sol +++ /dev/null @@ -1,87 +0,0 @@ -pragma solidity ^0.4.24; - - -import './BasicToken.sol'; -import './ERC20.sol'; - - -/** - * @title Standard ERC20 token - * - * @dev Implementation of the basic standard token. - * @dev https://github.com/ethereum/EIPs/issues/20 - * @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol - */ -contract StandardToken is ERC20, BasicToken { - - mapping (address => mapping (address => uint256)) internal allowed; - - - /** - * @dev Transfer tokens from one address to another - * @param _from address The address which you want to send tokens from - * @param _to address The address which you want to transfer to - * @param _value uint256 the amount of tokens to be transferred - */ - function transferFrom(address _from, address _to, uint256 _value) public returns (bool) { - require(_to != address(0)); - require(_value <= balances[_from]); - require(_value <= allowed[_from][msg.sender]); - - balances[_from] = balances[_from].sub(_value); - balances[_to] = balances[_to].add(_value); - allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); - Transfer(_from, _to, _value); - return true; - } - - /** - * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. - * - * Beware that changing an allowance with this method brings the risk that someone may use both the old - * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this - * race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: - * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 - * @param _spender The address which will spend the funds. - * @param _value The amount of tokens to be spent. - */ - function approve(address _spender, uint256 _value) public returns (bool) { - allowed[msg.sender][_spender] = _value; - Approval(msg.sender, _spender, _value); - return true; - } - - /** - * @dev Function to check the amount of tokens that an owner allowed to a spender. - * @param _owner address The address which owns the funds. - * @param _spender address The address which will spend the funds. - * @return A uint256 specifying the amount of tokens still available for the spender. - */ - function allowance(address _owner, address _spender) public constant returns (uint256 remaining) { - return allowed[_owner][_spender]; - } - - /** - * approve should be called when allowed[_spender] == 0. To increment - * allowed value is better to use this function to avoid 2 calls (and wait until - * the first transaction is mined) - * From MonolithDAO Token.sol - */ - function increaseApproval (address _spender, uint _addedValue) public returns (bool success) { - allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue); - Approval(msg.sender, _spender, allowed[msg.sender][_spender]); - return true; - } - - function decreaseApproval (address _spender, uint _subtractedValue) public returns (bool success) { - uint oldValue = allowed[msg.sender][_spender]; - if (_subtractedValue > oldValue) { - allowed[msg.sender][_spender] = 0; - } else { - allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue); - } - Approval(msg.sender, _spender, allowed[msg.sender][_spender]); - return true; - } - -} diff --git a/apps/shared/test-helpers/contracts/test/TestACLInterpreter.sol b/apps/shared/test-helpers/contracts/test/TestACLInterpreter.sol deleted file mode 100644 index ca909e91e..000000000 --- a/apps/shared/test-helpers/contracts/test/TestACLInterpreter.sol +++ /dev/null @@ -1,268 +0,0 @@ -pragma solidity 0.4.24; - -import "../acl/ACL.sol"; -import "./helpers/Assert.sol"; -import "./helpers/ACLHelper.sol"; - - -contract TestACLInterpreter is ACL, ACLHelper { - function testEqualityUint() public { - // Assert param 0 is equal to 10, given that params are [10, 11] - assertEval(arr(uint256(10), 11), 0, Op.EQ, 10, true); - assertEval(arr(uint256(10), 11), 1, Op.EQ, 10, false); - assertEval(arr(uint256(10), 11), 1, Op.EQ, 11, true); - } - - function testEqualityAddr() public { - assertEval(arr(msg.sender), 0, Op.EQ, uint256(msg.sender), true); - assertEval(arr(msg.sender), 0, Op.EQ, uint256(this), false); - } - - function testEqualityBytes() public { - assertEval(arr(keccak256("hi")), 0, Op.EQ, uint256(keccak256("hi")), true); - assertEval(arr(keccak256("hi")), 0, Op.EQ, uint256(keccak256("bye")), false); - } - - function testInequalityUint() public { - assertEval(arr(uint256(10), 11), 0, Op.NEQ, 10, false); - assertEval(arr(uint256(10), 11), 1, Op.NEQ, 10, true); - assertEval(arr(uint256(10), 11), 1, Op.NEQ, 11, false); - } - - function testInequalityBytes() public { - assertEval(arr(keccak256("hi")), 0, Op.NEQ, uint256(keccak256("hi")), false); - assertEval(arr(keccak256("hi")), 0, Op.NEQ, uint256(keccak256("bye")), true); - } - - function testInequalityAddr() public { - assertEval(arr(msg.sender), 0, Op.NEQ, uint256(msg.sender), false); - assertEval(arr(msg.sender), 0, Op.NEQ, uint256(this), true); - } - - function testGreatherThan() public { - assertEval(arr(uint256(10), 11), 0, Op.GT, 9, true); - assertEval(arr(uint256(10), 11), 0, Op.GT, 10, false); - assertEval(arr(uint256(10), 11), 1, Op.GT, 10, true); - } - - function testLessThan() public { - assertEval(arr(uint256(10), 11), 0, Op.LT, 9, false); - assertEval(arr(uint256(9), 11), 0, Op.LT, 10, true); - assertEval(arr(uint256(10), 11), 1, Op.LT, 10, false); - } - - function testGreatherThanOrEqual() public { - assertEval(arr(uint256(10), 11), 0, Op.GTE, 9, true); - assertEval(arr(uint256(10), 11), 0, Op.GTE, 10, true); - assertEval(arr(uint256(10), 11), 1, Op.GTE, 12, false); - } - - function testLessThanOrEqual() public { - assertEval(arr(uint256(10), 11), 0, Op.LTE, 9, false); - assertEval(arr(uint256(9), 11), 0, Op.LTE, 10, true); - assertEval(arr(uint256(10), 11), 1, Op.LTE, 11, true); - } - - function testTimestamp() public { - assertEval(arr(), TIMESTAMP_PARAM_ID, Op.EQ, uint256(block.timestamp), true); - assertEval(arr(), TIMESTAMP_PARAM_ID, Op.EQ, uint256(1), false); - assertEval(arr(), TIMESTAMP_PARAM_ID, Op.GT, uint256(1), true); - } - - function testBlockNumber() public { - assertEval(arr(), BLOCK_NUMBER_PARAM_ID, Op.EQ, uint256(block.number), true); - assertEval(arr(), BLOCK_NUMBER_PARAM_ID, Op.EQ, uint256(1), false); - assertEval(arr(), BLOCK_NUMBER_PARAM_ID, Op.GT, uint256(block.number - 1), true); - } - - function testOracle() public { - assertEval(arr(), ORACLE_PARAM_ID, Op.EQ, uint256(new AcceptOracle()), true); - assertEval(arr(), ORACLE_PARAM_ID, Op.EQ, uint256(new RejectOracle()), false); - assertEval(arr(), ORACLE_PARAM_ID, Op.NEQ, uint256(new RejectOracle()), true); - - // doesn't revert even if oracle reverts - assertEval(arr(), ORACLE_PARAM_ID, Op.EQ, uint256(new RevertOracle()), false); - // the staticcall will error as the oracle tries to modify state, so a no is returned - assertEval(arr(), ORACLE_PARAM_ID, Op.EQ, uint256(new StateModifyingOracle()), false); - // if returned data size is not correct, returns false - assertEval(arr(), ORACLE_PARAM_ID, Op.EQ, uint256(new EmptyDataReturnOracle()), false); - - // conditional oracle returns true if first param > 0 - ConditionalOracle conditionalOracle = new ConditionalOracle(); - - assertEval(arr(uint256(1)), ORACLE_PARAM_ID, Op.EQ, uint256(conditionalOracle), true); - assertEval(arr(uint256(0), uint256(1)), ORACLE_PARAM_ID, Op.EQ, uint256(conditionalOracle), false); - } - - function testReturn() public { - assertEval(arr(), PARAM_VALUE_PARAM_ID, Op.RET, uint256(1), true); - assertEval(arr(), PARAM_VALUE_PARAM_ID, Op.RET, uint256(0), false); - assertEval(arr(), PARAM_VALUE_PARAM_ID, Op.RET, uint256(100), true); - assertEval(arr(), TIMESTAMP_PARAM_ID, Op.RET, uint256(0), true); - } - - function testNot() public { - Param memory retTrue = Param(PARAM_VALUE_PARAM_ID, uint8(Op.RET), 1); - Param memory retFalse = Param(PARAM_VALUE_PARAM_ID, uint8(Op.RET), 0); - - Param memory notOp = Param(LOGIC_OP_PARAM_ID, uint8(Op.NOT), encodeOperator(1, 0)); - Param[] memory params = new Param[](2); - - // !true == false - params[0] = notOp; - params[1] = retTrue; - assertEval(params, false); - - // !false == true - params[1] = retFalse; - assertEval(params, true); - } - - function testComplexCombination() public { - // if (oracle and block number > block number - 1) then arg 0 < 10 or oracle else false - Param[] memory params = new Param[](7); - params[0] = Param(LOGIC_OP_PARAM_ID, uint8(Op.IF_ELSE), encodeIfElse(1, 4, 6)); - params[1] = Param(LOGIC_OP_PARAM_ID, uint8(Op.AND), encodeOperator(2, 3)); - params[2] = Param(ORACLE_PARAM_ID, uint8(Op.EQ), uint240(new AcceptOracle())); - params[3] = Param(BLOCK_NUMBER_PARAM_ID, uint8(Op.GT), uint240(block.number - 1)); - params[4] = Param(LOGIC_OP_PARAM_ID, uint8(Op.OR), encodeOperator(5, 2)); - params[5] = Param(0, uint8(Op.LT), uint240(10)); - params[6] = Param(PARAM_VALUE_PARAM_ID, uint8(Op.RET), 0); - - assertEval(params, arr(uint256(10)), true); - - params[4] = Param(LOGIC_OP_PARAM_ID, uint8(Op.AND), encodeOperator(5, 2)); - assertEval(params, arr(uint256(10)), false); - } - - function testParamOutOfBoundsFail() public { - Param[] memory params = new Param[](2); - - params[1] = Param(PARAM_VALUE_PARAM_ID, uint8(Op.RET), 1); - assertEval(params, arr(uint256(10)), false); - - params[0] = Param(LOGIC_OP_PARAM_ID, uint8(Op.IF_ELSE), encodeIfElse(2, 2, 2)); - assertEval(params, arr(uint256(10)), false); - } - - function testArgOutOfBoundsFail() public { - assertEval(arr(uint256(10), 11), 3, Op.EQ, 10, false); - } - - function testIfElse() public { - Param memory retTrue = Param(PARAM_VALUE_PARAM_ID, uint8(Op.RET), 1); - Param memory retFalse = Param(PARAM_VALUE_PARAM_ID, uint8(Op.RET), 0); - - // If 1 then 2 else 3 - Param memory ifOp = Param(LOGIC_OP_PARAM_ID, uint8(Op.IF_ELSE), encodeIfElse(1, 2, 3)); - Param[] memory params = new Param[](4); - - // true ? true : false == true - params[0] = ifOp; - params[1] = retTrue; - params[2] = retTrue; - params[3] = retFalse; - assertEval(params, true); - - // false ? true : false == false - params[1] = retFalse; - assertEval(params, false); - } - - function testCombinators() public { - Param memory retTrue = Param(PARAM_VALUE_PARAM_ID, uint8(Op.RET), 1); - Param memory retFalse = Param(PARAM_VALUE_PARAM_ID, uint8(Op.RET), 0); - - // OR param at index 1 or param 2 - Param memory orOp = Param(LOGIC_OP_PARAM_ID, uint8(Op.OR), encodeOperator(1, 2)); - Param memory andOp = Param(LOGIC_OP_PARAM_ID, uint8(Op.AND), encodeOperator(1, 2)); - Param memory xorOp = Param(LOGIC_OP_PARAM_ID, uint8(Op.XOR), encodeOperator(1, 2)); - - Param[] memory params = new Param[](3); - - // or true true == true - params[0] = orOp; - params[1] = retTrue; - params[2] = retTrue; - assertEval(params, true); - - // or false true == true - params[1] = retFalse; - assertEval(params, true); - - // or true false == true - params[1] = retTrue; - params[2] = retFalse; - assertEval(params, true); - - // or false false == false - params[1] = retFalse; - assertEval(params, false); - - // and false false == false - params[0] = andOp; - assertEval(params, false); - - // and true false == false - params[1] = retTrue; - assertEval(params, false); - - // and false true == false - params[1] = retFalse; - params[2] = retTrue; - assertEval(params, false); - - // and true true == true - params[1] = retTrue; - params[2] = retTrue; - assertEval(params, true); - - // xor true true == false - params[0] = xorOp; - assertEval(params, false); - - // xor false true == true - params[1] = retFalse; - assertEval(params, true); - - // xor true false == true - params[1] = retTrue; - params[2] = retFalse; - assertEval(params, true); - - // xor false false == false - params[1] = retFalse; - assertEval(params, false); - } - - - function assertEval(uint256[] memory args, uint8 argId, Op op, uint256 value, bool expected) internal { - Param[] memory params = new Param[](1); - params[0] = Param(argId, uint8(op), uint240(value)); - assertEval(params, args, expected); - } - - function assertEval(Param[] memory params, bool expected) internal { - assertEval(params, new uint256[](0), expected); - } - - function assertEval(Param[] memory params, uint256[] memory args, bool expected) internal { - bytes32 paramHash = encodeAndSaveParams(params); - bool allow = _evalParam(paramHash, 0, address(0), address(0), bytes32(0), args); - - Assert.equal(allow, expected, "eval got unexpected result"); - } - - event LogParam(bytes32 param); - function encodeAndSaveParams(Param[] memory params) internal returns (bytes32) { - uint256[] memory encodedParams = new uint256[](params.length); - - for (uint256 i = 0; i < params.length; i++) { - Param memory param = params[i]; - encodedParams[i] = (uint256(param.id) << 248) + (uint256(param.op) << 240) + param.value; - emit LogParam(bytes32(encodedParams[i])); - } - - return _saveParams(encodedParams); - } -} diff --git a/apps/shared/test-helpers/contracts/test/TestDelegateProxy.sol b/apps/shared/test-helpers/contracts/test/TestDelegateProxy.sol deleted file mode 100644 index 3fdc83ab9..000000000 --- a/apps/shared/test-helpers/contracts/test/TestDelegateProxy.sol +++ /dev/null @@ -1,74 +0,0 @@ -pragma solidity 0.4.24; - -import "./helpers/Assert.sol"; -import "./helpers/ThrowProxy.sol"; - -import "../common/DelegateProxy.sol"; -import "../evmscript/ScriptHelpers.sol"; - - -contract Target { - function dontReturn() public pure {} - function fail() public pure { revert(); } - function die() public { selfdestruct(0); } -} - - -contract TestDelegateProxy is DelegateProxy { - using ScriptHelpers for *; - - Target target; - ThrowProxy throwProxy; - - // Mock ERCProxy implementation - function implementation() public view returns (address) { - return this; - } - - function proxyType() public pure returns (uint256) { - return FORWARDING; - } - - // Tests - function beforeAll() public { - target = new Target(); - } - - function beforeEach() public { - throwProxy = new ThrowProxy(address(this)); - } - - function testFailIfNoContract() public { - TestDelegateProxy(throwProxy).noContract(); - throwProxy.assertThrows("should have reverted if target is not a contract"); - } - - function noContract() public { - delegatedFwd(address(0x1234), target.dontReturn.selector.toBytes()); - } - - function testFailIfReverts() public { - TestDelegateProxy(throwProxy).revertCall(); - throwProxy.assertThrows("should have reverted if call reverted"); - } - - function revertCall() public { - delegatedFwd(target, target.fail.selector.toBytes()); - } - - function testIsContractZero() public { - bool result = isContract(address(0)); - Assert.isFalse(result, "should return false"); - } - - function testIsContractAddress() public { - address nonContract = 0x1234; - bool result = isContract(nonContract); - Assert.isFalse(result, "should return false"); - } - - // keep as last test as it will kill this contract - function testDieIfMinReturn0() public { - delegatedFwd(target, target.die.selector.toBytes()); - } -} diff --git a/apps/shared/test-helpers/contracts/test/helpers/ACLHelper.sol b/apps/shared/test-helpers/contracts/test/helpers/ACLHelper.sol deleted file mode 100644 index 404978572..000000000 --- a/apps/shared/test-helpers/contracts/test/helpers/ACLHelper.sol +++ /dev/null @@ -1,59 +0,0 @@ -pragma solidity 0.4.24; - -import "../../acl/IACLOracle.sol"; - - -contract ACLHelper { - function encodeOperator(uint256 param1, uint256 param2) internal pure returns (uint240) { - return encodeIfElse(param1, param2, 0); - } - - function encodeIfElse(uint256 condition, uint256 successParam, uint256 failureParam) internal pure returns (uint240) { - return uint240(condition + (successParam << 32) + (failureParam << 64)); - } -} - - -contract AcceptOracle is IACLOracle { - function canPerform(address, address, bytes32, uint256[]) external view returns (bool) { - return true; - } -} - - -contract RejectOracle is IACLOracle { - function canPerform(address, address, bytes32, uint256[]) external view returns (bool) { - return false; - } -} - - -contract RevertOracle is IACLOracle { - function canPerform(address, address, bytes32, uint256[]) external view returns (bool) { - revert(); - } -} - -// Can't implement from IACLOracle as its canPerform() is marked as view-only -contract StateModifyingOracle /* is IACLOracle */ { - bool modifyState; - - function canPerform(address, address, bytes32, uint256[]) external returns (bool) { - modifyState = true; - return true; - } -} - -contract EmptyDataReturnOracle is IACLOracle { - function canPerform(address, address, bytes32, uint256[]) external view returns (bool) { - assembly { - return(0, 0) - } - } -} - -contract ConditionalOracle is IACLOracle { - function canPerform(address, address, bytes32, uint256[] how) external view returns (bool) { - return how[0] > 0; - } -} diff --git a/apps/shared/test-helpers/contracts/test/helpers/Assert.sol b/apps/shared/test-helpers/contracts/test/helpers/Assert.sol deleted file mode 100644 index eed4edcd2..000000000 --- a/apps/shared/test-helpers/contracts/test/helpers/Assert.sol +++ /dev/null @@ -1,1405 +0,0 @@ -// Taken from https://github.com/trufflesuite/truffle/blob/ef03be9e35909e5e7c97a9ecb07ccae4872645ca/packages/truffle-core/lib/testing/Assert.sol - -pragma solidity ^0.4.24; - -/* - File: Assertions.slb - Author: Andreas Olofsson (androlo1980@gmail.com) - Library: Assertions - Assertions for unit testing contracts. Tests are run with the - - unit-testing framework. - (start code) - contract ModAdder { - function addMod(uint a, uint b, uint modulus) constant returns (uint sum) { - if (modulus == 0) - throw; - return addmod(a, b, modulus); - } - } - contract SomeTest { - using Assertions for uint; - function testAdd() { - var adder = new ModAdder(); - adder.addMod(50, 66, 30).equal(26, "addition returned the wrong sum"); - } - } - (end) - It is also possible to extend , to have all bindings (using) properly set up. - (start code) - contract SomeTest is Test { - function testAdd() { - var adder = new ModAdder(); - adder.addMod(50, 66, 30).equal(26, "addition returned the wrong sum"); - } - } - (end) -*/ - -library Assert { - - // Constant: ADDRESS_NULL - // The null address: 0 - address constant ADDRESS_NULL = 0x0000000000000000000000000000000000000000; - // Constant: BYTES32_NULL - // The null bytes32: 0 - bytes32 constant BYTES32_NULL = 0x0; - // Constant: STRING_NULL - // The null string: "" - string constant STRING_NULL = ""; - - uint8 constant ZERO = uint8(byte('0')); - uint8 constant A = uint8(byte('a')); - - byte constant MINUS = byte('-'); - - /* - Event: TestEvent - Fired when an assertion is made. - Params: - result (bool) - Whether or not the assertion holds. - message (string) - A message to display if the assertion does not hold. - */ - event TestEvent(bool indexed result, string message); - - // ************************************** general ************************************** - - /* - Function: fail() - Mark the test as failed. - Params: - message (string) - A message associated with the failure. - Returns: - result (bool) - false. - */ - function fail(string message) public returns (bool result) { - _report(false, message); - return false; - } - - // ************************************** strings ************************************** - - /* - Function: equal(string) - Assert that two strings are equal. - : _stringsEqual(A, B) == true - Params: - A (string) - The first string. - B (string) - The second string. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(string a, string b, string message) public returns (bool result) { - result = _stringsEqual(a, b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: notEqual(string) - Assert that two strings are not equal. - : _stringsEqual(A, B) == false - Params: - A (string) - The first string. - B (string) - The second string. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(string a, string b, string message) public returns (bool result) { - result = !_stringsEqual(a, b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isEmpty(string) - Assert that a string is empty. - : _stringsEqual(str, STRING_NULL) == true - Params: - str (string) - The string. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isEmpty(string str, string message) public returns (bool result) { - result = _stringsEqual(str, STRING_NULL); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(str, "Tested"), message)); - } - - /* - Function: isNotEmpty(string) - Assert that a string is not empty. - : _stringsEqual(str, STRING_NULL) == false - Params: - str (string) - The string. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isNotEmpty(string str, string message) public returns (bool result) { - result = !_stringsEqual(str, STRING_NULL); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(str, "Tested"), message)); - } - - // ************************************** bytes32 ************************************** - - /* - Function: equal(bytes32) - Assert that two 'bytes32' are equal. - : A == B - Params: - A (bytes32) - The first 'bytes32'. - B (bytes32) - The second 'bytes32'. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(bytes32 a, bytes32 b, string message) public returns (bool result) { - result = (a == b); - _report(result, message); - } - - /* - Function: notEqual(bytes32) - Assert that two 'bytes32' are not equal. - : A != B - Params: - A (bytes32) - The first 'bytes32'. - B (bytes32) - The second 'bytes32'. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(bytes32 a, bytes32 b, string message) public returns (bool result) { - result = (a != b); - _report(result, message); - } - - /* - Function: isZero(bytes32) - Assert that a 'bytes32' is zero. - : bts == BYTES32_NULL - Params: - bts (bytes32) - The 'bytes32'. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isZero(bytes32 bts, string message) public returns (bool result) { - result = (bts == BYTES32_NULL); - _report(result, message); - } - - /* - Function: isNotZero(bytes32) - Assert that a 'bytes32' is not zero. - : bts != BYTES32_NULL - Params: - bts (bytes32) - The 'bytes32'. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isNotZero(bytes32 bts, string message) public returns (bool result) { - result = (bts != BYTES32_NULL); - _report(result, message); - } - - // ************************************** address ************************************** - - /* - Function: equal(address) - Assert that two addresses are equal. - : A == B - Params: - A (address) - The first address. - B (address) - The second address. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(address a, address b, string message) public returns (bool result) { - result = (a == b); - _report(result, message); - } - /* - Function: notEqual(address) - Assert that two addresses are not equal. - : A != B - Params: - A (address) - The first address. - B (address) - The second address. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(address a, address b, string message) public returns (bool result) { - result = (a != b); - _report(result, message); - } - - /* - Function: isZero(address) - Assert that an address is zero. - : addr == ADDRESS_NULL - Params: - addr (address) - The address. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isZero(address addr, string message) public returns (bool result) { - result = (addr == ADDRESS_NULL); - _report(result, message); - } - - /* - Function: isNotZero(address) - Assert that an address is not zero. - : addr != ADDRESS_NULL - Params: - addr (address) - The address. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isNotZero(address addr, string message) public returns (bool result) { - result = (addr != ADDRESS_NULL); - _report(result, message); - } - - // ************************************** bool ************************************** - - /* - Function: isTrue - Assert that a boolean is 'true'. - : b == true - Params: - b (bool) - The boolean. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isTrue(bool b, string message) public returns (bool result) { - result = b; - _report(result, message); - } - - /* - Function: isFalse - Assert that a boolean is 'false'. - : b == false - Params: - b (bool) - The boolean. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isFalse(bool b, string message) public returns (bool result) { - result = !b; - _report(result, message); - } - - /* - Function: equal(bool) - Assert that two booleans are equal. - : A == B - Params: - A (bool) - The first boolean. - B (bool) - The second boolean. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(bool a, bool b, string message) public returns (bool result) { - result = (a == b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: notEqual(bool) - Assert that two booleans are not equal. - : A != B - Params: - A (bool) - The first boolean. - B (bool) - The second boolean. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(bool a, bool b, string message) public returns (bool result) { - result = (a != b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - // ************************************** uint ************************************** - - /* - Function: equal(uint) - Assert that two (256 bit) unsigned integers are equal. - : A == B - Params: - A (uint) - The first uint. - B (uint) - The second uint. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(uint a, uint b, string message) public returns (bool result) { - result = (a == b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: notEqual(uint) - Assert that two (256 bit) unsigned integers are not equal. - : A != B - Params: - A (uint) - The first uint. - B (uint) - The second uint. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(uint a, uint b, string message) public returns (bool result) { - result = (a != b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isAbove(uint) - Assert that the uint 'A' is greater than the uint 'B'. - : A > B - Params: - A (uint) - The first uint. - B (uint) - The second uint. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isAbove(uint a, uint b, string message) public returns (bool result) { - result = (a > b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isAtLeast(uint) - Assert that the uint 'A' is greater than or equal to the uint 'B'. - : A >= B - Params: - A (uint) - The first uint. - B (uint) - The second uint. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isAtLeast(uint a, uint b, string message) public returns (bool result) { - result = (a >= b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isBelow(uint) - Assert that the uint 'A' is lesser than the uint 'B'. - : A < B - Params: - A (uint) - The first uint. - B (uint) - The second uint. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isBelow(uint a, uint b, string message) public returns (bool result) { - result = (a < b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isAtMost(uint) - Assert that the uint 'A' is lesser than or equal to the uint 'B'. - : A <= B - Params: - A (uint) - The first uint. - B (uint) - The second uint. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isAtMost(uint a, uint b, string message) public returns (bool result) { - result = (a <= b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isZero(uint) - Assert that a (256 bit) unsigned integer is 0. - : number == 0 - Params: - number (uint) - The uint. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isZero(uint number, string message) public returns (bool result) { - result = (number == 0); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(number, "Tested"), message)); - } - - /* - Function: isNotZero(uint) - Assert that a (256 bit) unsigned integer is not 0. - : number != 0 - Params: - number (uint) - The uint. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isNotZero(uint number, string message) public returns (bool result) { - result = (number != 0); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(number, "Tested"), message)); - } - - // ************************************** int ************************************** - - /* - Function: equal(int) - Assert that two (256 bit) signed integers are equal. - : A == B - Params: - A (int) - The first int. - B (int) - The second int. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(int a, int b, string message) public returns (bool result) { - result = (a == b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: notEqual(int) - Assert that two (256 bit) signed integers are not equal. - : A != B - Params: - A (int) - The first int. - B (int) - The second int. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(int a, int b, string message) public returns (bool result) { - result = (a != b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isAbove(int) - Assert that the int 'A' is greater than the int 'B'. - : A > B - Params: - A (int) - The first int. - B (int) - The second int. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isAbove(int a, int b, string message) public returns (bool result) { - result = (a > b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isAtLeast(int) - Assert that the int 'A' is greater than or equal to the int 'B'. - : A >= B - Params: - A (int) - The first int. - B (int) - The second int. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isAtLeast(int a, int b, string message) public returns (bool result) { - result = (a >= b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isBelow(int) - Assert that the int 'A' is lesser than the int 'B'. - : A < B - Params: - A (int) - The first int. - B (int) - The second int. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isBelow(int a, int b, string message) public returns (bool result) { - result = (a < b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isAtMost(int) - Assert that the int 'A' is lesser than or equal to the int 'B'. - : A <= B - Params: - A (int) - The first int. - B (int) - The second int. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isAtMost(int a, int b, string message) public returns (bool result) { - result = (a <= b); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(a, "Tested"), _tag(b, "Against"), message)); - } - - /* - Function: isZero(int) - Assert that a (256 bit) signed integer is 0. - : number == 0 - Params: - number (int) - The int. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isZero(int number, string message) public returns (bool result) { - result = (number == 0); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(number, "Tested"), message)); - } - - /* - Function: isNotZero(int) - Assert that a (256 bit) signed integer is not 0. - : number != 0 - Params: - number (int) - The int. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function isNotZero(int number, string message) public returns (bool result) { - result = (number != 0); - if (result) - _report(result, message); - else - _report(result, _appendTagged(_tag(number, "Tested"), message)); - } - - // ************************************** uint[] ************************************** - - /* - Function: equal(uint[]) - Assert that two 'uint[ ]' are equal. - : arrA.length == arrB.length - and, for all valid indices 'i' - : arrA[i] == arrB[i] - Params: - A (uint[]) - The first array. - B (uint[]) - The second array. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(uint[] arrA, uint[] arrB, string message) public returns (bool result) { - result = arrA.length == arrB.length; - if (result) { - for (uint i = 0; i < arrA.length; i++) { - if (arrA[i] != arrB[i]) { - result = false; - break; - } - } - } - _report(result, message); - } - - /* - Function: notEqual(uint[]) - Assert that two 'uint[]' are not equal. - : arrA.length != arrB.length - or, for some valid index 'i' - : arrA[i] != arrB[i] - Params: - A (uint[]) - The first string. - B (uint[]) - The second string. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(uint[] arrA, uint[] arrB, string message) public returns (bool result) { - result = arrA.length == arrB.length; - if (result) { - for (uint i = 0; i < arrA.length; i++) { - if (arrA[i] != arrB[i]) { - result = false; - break; - } - } - } - result = !result; - _report(result, message); - } - - /* - Function: lengthEqual(uint[]) - Assert that the length of a 'uint[]' is equal to a given value. - : arr.length == length - Params: - arr (uint[]) - The array. - length (uint) - The length. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function lengthEqual(uint[] arr, uint length, string message) public returns (bool result) { - uint arrLength = arr.length; - if (arrLength == length) - _report(result, ""); - else - _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message)); - } - - /* - Function: lengthNotEqual(uint[]) - Assert that the length of a 'uint[]' is not equal to a given value. - : arr.length != length - Params: - arr (uint[]) - The array. - length (uint) - The length. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function lengthNotEqual(uint[] arr, uint length, string message) public returns (bool result) { - uint arrLength = arr.length; - if (arrLength != arr.length) - _report(result, ""); - else - _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message)); - } - - // ************************************** int[] ************************************** - - /* - Function: equal(int[]) - Assert that two 'int[]' are equal. - : arrA.length == arrB.length - and, for all valid indices 'i' - : arrA[i] == arrB[i] - Params: - A (int[]) - The first array. - B (int[]) - The second array. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(int[] arrA, int[] arrB, string message) public returns (bool result) { - result = arrA.length == arrB.length; - if (result) { - for (uint i = 0; i < arrA.length; i++) { - if (arrA[i] != arrB[i]) { - result = false; - break; - } - } - } - _report(result, message); - } - - /* - Function: notEqual(int[]) - Assert that two 'int[]' are not equal. - : arrA.length != arrB.length - or, for some valid index 'i' - : arrA[i] != arrB[i] - Params: - A (int[]) - The first string. - B (int[]) - The second string. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(int[] arrA, int[] arrB, string message) public returns (bool result) { - result = arrA.length == arrB.length; - if (result) { - for (uint i = 0; i < arrA.length; i++) { - if (arrA[i] != arrB[i]) { - result = false; - break; - } - } - } - result = !result; - _report(result, message); - } - - /* - Function: lengthEqual(int[]) - Assert that the length of an 'int[]' is equal to a given value. - : arr.length == length - Params: - arr (int[]) - The array. - length (uint) - The length. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function lengthEqual(int[] arr, uint length, string message) public returns (bool result) { - uint arrLength = arr.length; - if (arrLength == length) - _report(result, ""); - else - _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message)); - } - - /* - Function: lengthNotEqual(int[]) - Assert that the length of an 'int[]' is not equal to a given value. - : arr.length != length - Params: - arr (int[]) - The array. - length (uint) - The length. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function lengthNotEqual(int[] arr, uint length, string message) public returns (bool result) { - uint arrLength = arr.length; - if (arrLength != arr.length) - _report(result, ""); - else - _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message)); - } - - // ************************************** address[] ************************************** - - /* - Function: equal(address[]) - Assert that two 'address[]' are equal. - : arrA.length == arrB.length - and, for all valid indices 'i' - : arrA[i] == arrB[i] - Params: - A (address[]) - The first array. - B (address[]) - The second array. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(address[] arrA, address[] arrB, string message) public returns (bool result) { - result = arrA.length == arrB.length; - if (result) { - for (uint i = 0; i < arrA.length; i++) { - if (arrA[i] != arrB[i]) { - result = false; - break; - } - } - } - _report(result, message); - } - - /* - Function: notEqual(address[]) - Assert that two 'address[]' are not equal. - : arrA.length != arrB.length - or, for some valid index 'i' - : arrA[i] != arrB[i] - Params: - A (address[]) - The first string. - B (address[]) - The second string. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(address[] arrA, address[] arrB, string message) public returns (bool result) { - result = arrA.length == arrB.length; - if (result) { - for (uint i = 0; i < arrA.length; i++) { - if (arrA[i] != arrB[i]) { - result = false; - break; - } - } - } - result = !result; - _report(result, message); - } - - /* - Function: lengthEqual(address[]) - Assert that the length of an 'address[]' is equal to a given value. - : arr.length == length - Params: - arr (address[]) - The array. - length (uint) - The length. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function lengthEqual(address[] arr, uint length, string message) public returns (bool result) { - uint arrLength = arr.length; - if (arrLength == length) - _report(result, ""); - else - _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message)); - } - - /* - Function: lengthNotEqual(address[]) - Assert that the length of an 'address[]' is not equal to a given value. - : arr.length != length - Params: - arr (address[]) - The array. - length (uint) - The length. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function lengthNotEqual(address[] arr, uint length, string message) public returns (bool result) { - uint arrLength = arr.length; - if (arrLength != arr.length) - _report(result, ""); - else - _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message)); - } - - // ************************************** bytes32[] ************************************** - - /* - Function: equal(bytes32[]) - Assert that two 'bytes32[]' are equal. - : arrA.length == arrB.length - and, for all valid indices 'i' - : arrA[i] == arrB[i] - Params: - A (bytes32[]) - The first array. - B (bytes32[]) - The second array. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function equal(bytes32[] arrA, bytes32[] arrB, string message) public returns (bool result) { - result = arrA.length == arrB.length; - if (result) { - for (uint i = 0; i < arrA.length; i++) { - if (arrA[i] != arrB[i]) { - result = false; - break; - } - } - } - _report(result, message); - } - - /* - Function: notEqual(bytes32[]) - Assert that two 'bytes32[]' are not equal. - : arrA.length != arrB.length - or, for some valid index 'i' - : arrA[i] != arrB[i] - Params: - A (bytes32[]) - The first string. - B (bytes32[]) - The second string. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function notEqual(bytes32[] arrA, bytes32[] arrB, string message) public returns (bool result) { - result = arrA.length == arrB.length; - if (result) { - for (uint i = 0; i < arrA.length; i++) { - if (arrA[i] != arrB[i]) { - result = false; - break; - } - } - } - result = !result; - _report(result, message); - } - - /* - Function: lengthEqual(bytes32[]) - Assert that the length of an 'bytes32[]' is equal to a given value. - : arr.length == length - Params: - arr (bytes32[]) - The array. - length (uint) - The length. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function lengthEqual(bytes32[] arr, uint length, string message) public returns (bool result) { - uint arrLength = arr.length; - if (arrLength == length) - _report(result, ""); - else - _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message)); - } - - /* - Function: lengthNotEqual(bytes32[]) - Assert that the length of an 'bytes32[]' is not equal to a given value. - : arr.length != length - Params: - arr (bytes32[]) - The array. - length (uint) - The length. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function lengthNotEqual(bytes32[] arr, uint length, string message) public returns (bool result) { - uint arrLength = arr.length; - if (arrLength != arr.length) - _report(result, ""); - else - _report(result, _appendTagged(_tag(arrLength, "Tested"), _tag(length, "Against"), message)); - } - - // ************************************** balances ************************************** - - /* - Function: balanceEqual - Assert that the balance of an account 'A' is equal to a given number 'b'. - : A.balance = b - Params: - A (address) - The first address. - b (uint) - The balance. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function balanceEqual(address a, uint b, string message) public returns (bool result) { - result = (a.balance == b); - _report(result, message); - } - - /* - Function: balanceNotEqual - Assert that the balance of an account 'A' is not equal to a given number 'b'. - : A.balance != b - Params: - A (address) - The first address. - b (uint) - The balance. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function balanceNotEqual(address a, uint b, string message) public returns (bool result) { - result = (a.balance != b); - _report(result, message); - } - - /* - Function: balanceIsZero - Assert that the balance of an account 'A' is zero. - : A.balance == 0 - Params: - A (address) - The first address. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function balanceIsZero(address a, string message) public returns (bool result) { - result = (a.balance == 0); - _report(result, message); - } - - /* - Function: balanceIsNotZero - Assert that the balance of an account 'A' is not zero. - : A.balance != 0 - Params: - A (address) - The first address. - message (string) - A message that is sent if the assertion fails. - Returns: - result (bool) - The result. - */ - function balanceIsNotZero(address a, string message) public returns (bool result) { - result = (a.balance != 0); - _report(result, message); - } - - /******************************** internal ********************************/ - - /* - Function: _report - Internal function for triggering . - Params: - result (bool) - The test result (true or false). - message (string) - The message that is sent if the assertion fails. - */ - function _report(bool result, string message) internal { - if(result) - emit TestEvent(true, ""); - else - emit TestEvent(false, message); - } - - /* - Function: _stringsEqual - Compares two strings. Taken from the StringUtils contract in the Ethereum Dapp-bin - (https://github.com/ethereum/dapp-bin/blob/master/library/stringUtils.sol). - Params: - a (string) - The first string. - b (string) - The second string. - Returns: - result (bool) - 'true' if the strings are equal, otherwise 'false'. - */ - function _stringsEqual(string a, string b) internal pure returns (bool result) { - bytes memory ba = bytes(a); - bytes memory bb = bytes(b); - - if (ba.length != bb.length) - return false; - for (uint i = 0; i < ba.length; i ++) { - if (ba[i] != bb[i]) - return false; - } - return true; - } - - /* - Function: _itoa - Convert a signed integer to a string. Negative numbers gets a '-' in front, e.g. "-54". - Params: - n (int) - The integer. - radix (uint8) - A number between 2 and 16 (inclusive). Characters used are 0-9,a-f - Returns: - result (string) - The resulting string. - */ - function _itoa(int n, uint8 radix) internal pure returns (string) { - if (n == 0 || radix < 2 || radix > 16) - return '0'; - bytes memory bts = new bytes(256); - uint i; - bool neg = false; - if (n < 0) { - n = -n; - neg = true; - } - while (n > 0) { - bts[i++] = _utoa(uint8(n % radix)); // Turn it to ascii. - n /= radix; - } - // Reverse - uint size = i; - uint j = 0; - bytes memory rev; - if (neg) { - size++; - j = 1; - rev = new bytes(size); - rev[0] = MINUS; - } - else - rev = new bytes(size); - - for (; j < size; j++) { - rev[j] = bts[size - j - 1]; - } - return string(rev); - } - - /* - Function: _utoa(uint) - Convert an unsigned integer to a string. - Params: - n (uint) - The unsigned integer. - radix (uint8) - A number between 2 and 16 (inclusive). Characters used are 0-9,a-f - Returns: - result (string) - The resulting string. - */ - function _utoa(uint n, uint8 radix) internal pure returns (string) { - if (n == 0 || radix < 2 || radix > 16) - return '0'; - bytes memory bts = new bytes(256); - uint i; - while (n > 0) { - bts[i++] = _utoa(uint8(n % radix)); // Turn it to ascii. - n /= radix; - } - // Reverse - bytes memory rev = new bytes(i); - for (uint j = 0; j < i; j++) - rev[j] = bts[i - j - 1]; - return string(rev); - } - - /* - Function: _utoa(uint8) - Convert an unsigned 8-bit integer to its ASCII byte representation. Numbers 0-9 are converted to '0'-'9', - numbers 10-16 to 'a'-'f'. Numbers larger then 16 return the null byte. - Params: - u (uint8) - The unsigned 8-bit integer. - Returns: - result (string) - The ASCII byte. - */ - function _utoa(uint8 u) internal pure returns (byte) { - if (u < 10) - return byte(u + ZERO); - else if (u < 16) - return byte(u - 10 + A); - else - return 0; - } - - /* - Function: _ltoa - Convert an boolean to a string. - Params: - val (bool) - The boolean. - Returns: - result (string) - "true" if true, "false" if false. - */ - function _ltoa(bool val) internal pure returns (string) { - bytes memory b; - if (val) { - b = new bytes(4); - b[0] = 't'; - b[1] = 'r'; - b[2] = 'u'; - b[3] = 'e'; - return string(b); - } - else { - b = new bytes(5); - b[0] = 'f'; - b[1] = 'a'; - b[2] = 'l'; - b[3] = 's'; - b[4] = 'e'; - return string(b); - } - } - - /* - function htoa(address addr) constant returns (string) { - bytes memory bts = new bytes(40); - bytes20 addrBts = bytes20(addr); - for (uint i = 0; i < 20; i++) { - bts[2*i] = addrBts[i] % 16; - bts[2*i + 1] = (addrBts[i] / 16) % 16; - } - return string(bts); - } - */ - - /* - Function: _tag(string) - Add a tag to a string. The 'value' and 'tag' strings are returned on the form "tag: value". - Params: - value (string) - The value. - tag (string) - The tag. - Returns: - result (string) - "tag: value" - */ - function _tag(string value, string tag) internal pure returns (string) { - - bytes memory valueB = bytes(value); - bytes memory tagB = bytes(tag); - - uint vl = valueB.length; - uint tl = tagB.length; - - bytes memory newB = new bytes(vl + tl + 2); - - uint i; - uint j; - - for (i = 0; i < tl; i++) - newB[j++] = tagB[i]; - newB[j++] = ':'; - newB[j++] = ' '; - for (i = 0; i < vl; i++) - newB[j++] = valueB[i]; - - return string(newB); - } - - /* - Function: _tag(int) - Add a tag to an int. - Params: - value (int) - The value. - tag (string) - The tag. - Returns: - result (string) - "tag: _itoa(value)" - */ - function _tag(int value, string tag) internal pure returns (string) { - string memory nstr = _itoa(value, 10); - return _tag(nstr, tag); - } - - /* - Function: _tag(uint) - Add a tag to an uint. - Params: - value (uint) - The value. - tag (string) - The tag. - Returns: - result (string) - "tag: _utoa(value)" - */ - function _tag(uint value, string tag) internal pure returns (string) { - string memory nstr = _utoa(value, 10); - return _tag(nstr, tag); - } - - /* - Function: _tag(bool) - Add a tag to a boolean. - Params: - value (bool) - The value. - tag (string) - The tag. - Returns: - result (string) - "tag: _ltoa(value)" - */ - function _tag(bool value, string tag) internal pure returns (string) { - string memory nstr = _ltoa(value); - return _tag(nstr, tag); - } - - /* - Function: _appendTagged(string) - Append a tagged value to a string. - Params: - tagged (string) - The tagged value. - str (string) - The string. - Returns: - result (string) - "str (tagged)" - */ - function _appendTagged(string tagged, string str) internal pure returns (string) { - - bytes memory taggedB = bytes(tagged); - bytes memory strB = bytes(str); - - uint sl = strB.length; - uint tl = taggedB.length; - - bytes memory newB = new bytes(sl + tl + 3); - - uint i; - uint j; - - for (i = 0; i < sl; i++) - newB[j++] = strB[i]; - newB[j++] = ' '; - newB[j++] = '('; - for (i = 0; i < tl; i++) - newB[j++] = taggedB[i]; - newB[j++] = ')'; - - return string(newB); - } - - /* - Function: _appendTagged(string, string) - Append two tagged values to a string. - Params: - tagged0 (string) - The first tagged value. - tagged1 (string) - The second tagged value. - str (string) - The string. - Returns: - result (string) - "str (tagged0, tagged1)" - */ - function _appendTagged(string tagged0, string tagged1, string str) internal pure returns (string) { - - bytes memory tagged0B = bytes(tagged0); - bytes memory tagged1B = bytes(tagged1); - bytes memory strB = bytes(str); - - uint sl = strB.length; - uint t0l = tagged0B.length; - uint t1l = tagged1B.length; - - bytes memory newB = new bytes(sl + t0l + t1l + 5); - - uint i; - uint j; - - for (i = 0; i < sl; i++) - newB[j++] = strB[i]; - newB[j++] = ' '; - newB[j++] = '('; - for (i = 0; i < t0l; i++) - newB[j++] = tagged0B[i]; - newB[j++] = ','; - newB[j++] = ' '; - for (i = 0; i < t1l; i++) - newB[j++] = tagged1B[i]; - newB[j++] = ')'; - - return string(newB); - } - -} diff --git a/apps/shared/test-helpers/contracts/test/helpers/ThrowProxy.sol b/apps/shared/test-helpers/contracts/test/helpers/ThrowProxy.sol deleted file mode 100644 index f901046ba..000000000 --- a/apps/shared/test-helpers/contracts/test/helpers/ThrowProxy.sol +++ /dev/null @@ -1,33 +0,0 @@ -pragma solidity ^0.4.24; - -import "./Assert.sol"; - -// Based on Simon de la Rouviere method: http://truffleframework.com/tutorials/testing-for-throws-in-solidity-tests - - -// Proxy contract for testing throws -contract ThrowProxy { - address public target; - bytes data; - - constructor(address _target) public { - target = _target; - } - - //prime the data using the fallback function. - function() public { - data = msg.data; - } - - function assertThrows(string _msg) public { - Assert.isFalse(execute(), _msg); - } - - function assertItDoesntThrow(string _msg) public { - Assert.isTrue(execute(), _msg); - } - - function execute() public returns (bool) { - return target.call(data); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/APMNamehashWrapper.sol b/apps/shared/test-helpers/contracts/test/mocks/APMNamehashWrapper.sol deleted file mode 100644 index 3695dc2c7..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/APMNamehashWrapper.sol +++ /dev/null @@ -1,10 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apm/APMNamehash.sol"; - - -contract APMNamehashWrapper is APMNamehash { - function getAPMNamehash(string name) external pure returns (bytes32) { - return apmNamehash(name); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/APMRegistryFactoryMock.sol b/apps/shared/test-helpers/contracts/test/mocks/APMRegistryFactoryMock.sol deleted file mode 100644 index cadd24c0a..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/APMRegistryFactoryMock.sol +++ /dev/null @@ -1,90 +0,0 @@ -pragma solidity 0.4.24; - -// Mock that doesn't grant enough permissions -// external ENS - -import "../../factory/APMRegistryFactory.sol"; - -contract APMRegistryFactoryMock is APMRegistryFactory { - constructor( - DAOFactory _daoFactory, - APMRegistry _registryBase, - Repo _repoBase, - ENSSubdomainRegistrar _ensSubBase, - ENS _ens, - ENSFactory _ensFactory - ) - APMRegistryFactory(_daoFactory, _registryBase, _repoBase, _ensSubBase, _ens, _ensFactory) public {} - - function newAPM(bytes32, bytes32, address) public returns (APMRegistry) {} - - function newBadAPM(bytes32 tld, bytes32 label, address _root, bool withoutACL) public returns (APMRegistry) { - bytes32 node = keccak256(abi.encodePacked(tld, label)); - - // Assume it is the test ENS - if (ens.owner(node) != address(this)) { - // If we weren't in test ens and factory doesn't have ownership, will fail - ens.setSubnodeOwner(tld, label, this); - } - - Kernel dao = daoFactory.newDAO(this); - ACL acl = ACL(dao.acl()); - - acl.createPermission(this, dao, dao.APP_MANAGER_ROLE(), this); - - // Deploy app proxies - bytes memory noInit = new bytes(0); - ENSSubdomainRegistrar ensSub = ENSSubdomainRegistrar( - dao.newAppInstance( - keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(ENS_SUB_APP_NAME)))), - ensSubdomainRegistrarBase, - noInit, - false - ) - ); - APMRegistry apm = APMRegistry( - dao.newAppInstance( - keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(APM_APP_NAME)))), - registryBase, - noInit, - false - ) - ); - - // APMRegistry controls Repos - bytes32 repoAppId = keccak256(abi.encodePacked(node, keccak256(abi.encodePacked(REPO_APP_NAME)))); - dao.setApp(dao.APP_BASES_NAMESPACE(), repoAppId, repoBase); - - emit DeployAPM(node, apm); - - // Grant permissions needed for APM on ENSSubdomainRegistrar - - if (withoutACL) { - acl.createPermission(apm, ensSub, ensSub.CREATE_NAME_ROLE(), _root); - } - - acl.createPermission(apm, ensSub, ensSub.POINT_ROOTNODE_ROLE(), _root); - - configureAPMPermissions(acl, apm, _root); - - // allow apm to create permissions for Repos in Kernel - bytes32 permRole = acl.CREATE_PERMISSIONS_ROLE(); - - if (!withoutACL) { - acl.grantPermission(apm, acl, permRole); - } - - // Permission transition to _root - acl.setPermissionManager(_root, dao, dao.APP_MANAGER_ROLE()); - acl.revokePermission(this, acl, permRole); - acl.grantPermission(_root, acl, permRole); - acl.setPermissionManager(_root, acl, permRole); - - // Initialize - ens.setOwner(node, ensSub); - ensSub.initialize(ens, node); - apm.initialize(ensSub); - - return apm; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/AppProxyPinnedStorageMock.sol b/apps/shared/test-helpers/contracts/test/mocks/AppProxyPinnedStorageMock.sol deleted file mode 100644 index 5de96a493..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/AppProxyPinnedStorageMock.sol +++ /dev/null @@ -1,41 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apps/AppProxyPinned.sol"; -import "../../kernel/IKernel.sol"; -import "../../kernel/Kernel.sol"; - - -contract FakeAppConstants { - bytes32 constant FAKE_APP_ID = keccak256('FAKE_APP_ID'); -} - -contract KernelPinnedStorageMock is Kernel, FakeAppConstants { - bytes32 constant FAKE_APP_ID = keccak256('FAKE_APP_ID'); - constructor(address _fakeApp) Kernel(false) public { - _setApp(APP_BASES_NAMESPACE, FAKE_APP_ID, _fakeApp); - } -} - - -// Testing this contract is a bit of a pain... we can't overload anything to make the contract check -// pass in the constructor, so we're forced to initialize this with a mocked Kernel that already -// sets a contract for the fake app. -contract AppProxyPinnedStorageMock is AppProxyPinned, FakeAppConstants { - constructor(KernelPinnedStorageMock _mockKernel) - AppProxyPinned(IKernel(_mockKernel), FAKE_APP_ID, new bytes(0)) - public // solium-disable-line visibility-first - { - } - - function setPinnedCodeExt(address _pinnedCode) public { - setPinnedCode(_pinnedCode); - } - - function getPinnedCodePosition() public pure returns (bytes32) { - return PINNED_CODE_POSITION; - } - - function pinnedCodeExt() public view returns (address) { - return pinnedCode(); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/AppStorageMock.sol b/apps/shared/test-helpers/contracts/test/mocks/AppStorageMock.sol deleted file mode 100644 index 53d977e69..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/AppStorageMock.sol +++ /dev/null @@ -1,22 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apps/AppStorage.sol"; - - -contract AppStorageMock is AppStorage { - function setKernelExt(IKernel _kernel) public { - setKernel(_kernel); - } - - function setAppIdExt(bytes32 _appId) public { - setAppId(_appId); - } - - function getKernelPosition() public pure returns (bytes32) { - return KERNEL_POSITION; - } - - function getAppIdPosition() public pure returns (bytes32) { - return APP_ID_POSITION; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/AppStub.sol b/apps/shared/test-helpers/contracts/test/mocks/AppStub.sol deleted file mode 100644 index 3225e4518..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/AppStub.sol +++ /dev/null @@ -1,48 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apps/AragonApp.sol"; -import "../../apps/UnsafeAragonApp.sol"; -import "../../kernel/IKernel.sol"; - - -contract AppStubStorage { - uint a; - string public stringTest; -} - -contract AppStub is AragonApp, AppStubStorage { - bytes32 constant public ROLE = keccak256("ROLE"); - - function initialize() onlyInit public { - initialized(); - stringTest = "hola"; - } - - function requiresInitialization() isInitialized public constant returns (bool) { - return true; - } - - function setValue(uint i) auth(ROLE) public { - a = i; - } - - function setValueParam(uint i) authP(ROLE, arr(i)) public { - a = i; - } - - function getValue() public constant returns (uint) { - return a; - } -} - -contract AppStub2 is AragonApp, AppStubStorage { - function getValue() public constant returns (uint) { - return a * 2; - } -} - -contract UnsafeAppStub is AppStub, UnsafeAragonApp { - constructor(IKernel _kernel) public { - setKernel(_kernel); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/AppStubConditionalRecovery.sol b/apps/shared/test-helpers/contracts/test/mocks/AppStubConditionalRecovery.sol deleted file mode 100644 index 65298671d..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/AppStubConditionalRecovery.sol +++ /dev/null @@ -1,17 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apps/AragonApp.sol"; -import "../../common/DepositableStorage.sol"; - - -contract AppStubConditionalRecovery is AragonApp, DepositableStorage { - function initialize() onlyInit public { - initialized(); - setDepositable(true); - } - - function allowRecoverability(address token) public view returns (bool) { - // Doesn't allow to recover ether - return token != address(0); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/AppStubDepositable.sol b/apps/shared/test-helpers/contracts/test/mocks/AppStubDepositable.sol deleted file mode 100644 index 095b89ee5..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/AppStubDepositable.sol +++ /dev/null @@ -1,26 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apps/AragonApp.sol"; -import "../../apps/UnsafeAragonApp.sol"; -import "../../common/DepositableStorage.sol"; - - -contract AppStubDepositable is AragonApp, DepositableStorage { - function () external payable { - require(isDepositable()); - } - - function initialize() onlyInit public { - initialized(); - } - - function enableDeposits() external { - setDepositable(true); - } -} - -contract UnsafeAppStubDepositable is AppStubDepositable, UnsafeAragonApp { - constructor(IKernel _kernel) public { - setKernel(_kernel); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/DepositableStorageMock.sol b/apps/shared/test-helpers/contracts/test/mocks/DepositableStorageMock.sol deleted file mode 100644 index ede41cde5..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/DepositableStorageMock.sol +++ /dev/null @@ -1,14 +0,0 @@ -pragma solidity 0.4.24; - -import "../../common/DepositableStorage.sol"; - - -contract DepositableStorageMock is DepositableStorage { - function setDepositableExt(bool _depositable) public { - setDepositable(_depositable); - } - - function getDepositablePosition() public pure returns (bytes32) { - return DEPOSITABLE_POSITION; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/ERCProxyMock.sol b/apps/shared/test-helpers/contracts/test/mocks/ERCProxyMock.sol deleted file mode 100644 index ecce348ec..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/ERCProxyMock.sol +++ /dev/null @@ -1,17 +0,0 @@ -pragma solidity 0.4.24; - -import "../../lib/misc/ERCProxy.sol"; - - -contract ERCProxyMock is ERCProxy { - uint256 constant public FORWARDING = 1; - uint256 constant public UPGRADEABLE = 2; - - function proxyType() public pure returns (uint256 proxyTypeId) { - return 0; - } - - function implementation() public view returns (address codeAddr) { - return address(0); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/EVMScriptExecutorMock.sol b/apps/shared/test-helpers/contracts/test/mocks/EVMScriptExecutorMock.sol deleted file mode 100644 index fde68481d..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/EVMScriptExecutorMock.sol +++ /dev/null @@ -1,15 +0,0 @@ -pragma solidity 0.4.24; - - -import "../../evmscript/executors/BaseEVMScriptExecutor.sol"; - -contract EVMScriptExecutorMock is BaseEVMScriptExecutor { - bytes32 constant internal EXECUTOR_TYPE = keccak256("MOCK_SCRIPT"); - - function execScript(bytes, bytes, address[]) external isInitialized returns (bytes) { - } - - function executorType() external pure returns (bytes32) { - return EXECUTOR_TYPE; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/ExecutionTarget.sol b/apps/shared/test-helpers/contracts/test/mocks/ExecutionTarget.sol deleted file mode 100644 index c37930c17..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/ExecutionTarget.sol +++ /dev/null @@ -1,21 +0,0 @@ -pragma solidity 0.4.24; - - -contract ExecutionTarget { - uint public counter; - - function execute() public { - counter += 1; - emit Executed(counter); - } - - function failExecute() public pure { - revert(); - } - - function setCounter(uint x) public { - counter = x; - } - - event Executed(uint x); -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/InitializableStorageMock.sol b/apps/shared/test-helpers/contracts/test/mocks/InitializableStorageMock.sol deleted file mode 100644 index 7dd93f1a2..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/InitializableStorageMock.sol +++ /dev/null @@ -1,14 +0,0 @@ -pragma solidity 0.4.24; - -import "../../common/Initializable.sol"; - - -contract InitializableStorageMock is Initializable { - function initialize() onlyInit public { - initialized(); - } - - function getInitializationBlockPosition() public pure returns (bytes32) { - return INITIALIZATION_BLOCK_POSITION; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/KeccakConstants.sol b/apps/shared/test-helpers/contracts/test/mocks/KeccakConstants.sol deleted file mode 100644 index 45e8103fc..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/KeccakConstants.sol +++ /dev/null @@ -1,57 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apm/APMNamehash.sol"; - - -contract KeccakConstants is APMNamehash { - // Note: we can't use APMNamehash.apmNamehash() for constants, starting from pragma 0.5 :( - - // Kernel - bytes32 constant public CORE_NAMESPACE = keccak256(abi.encodePacked("core")); - bytes32 constant public APP_BASES_NAMESPACE = keccak256(abi.encodePacked("base")); - bytes32 constant public APP_ADDR_NAMESPACE = keccak256(abi.encodePacked("app")); - - bytes32 constant public KERNEL_APP_ID = keccak256(abi.encodePacked(APM_NODE, keccak256("kernel"))); - bytes32 constant public ACL_APP_ID = keccak256(abi.encodePacked(APM_NODE, keccak256("acl"))); - - bytes32 constant public APP_MANAGER_ROLE = keccak256(abi.encodePacked("APP_MANAGER_ROLE")); - - bytes32 constant public DEFAULT_VAULT_APP_ID = keccak256(abi.encodePacked(APM_NODE, keccak256("vault"))); - - // ENS - bytes32 constant public ENS_ROOT = bytes32(0); - bytes32 constant public ETH_TLD_LABEL = keccak256(abi.encodePacked("eth")); - bytes32 constant public ETH_TLD_NODE = keccak256(abi.encodePacked(ENS_ROOT, ETH_TLD_LABEL)); - bytes32 constant public PUBLIC_RESOLVER_LABEL = keccak256(abi.encodePacked("resolver")); - bytes32 constant public PUBLIC_RESOLVER_NODE = keccak256(abi.encodePacked(ETH_TLD_NODE, PUBLIC_RESOLVER_LABEL)); - - // ACL - bytes32 constant public CREATE_PERMISSIONS_ROLE = keccak256(abi.encodePacked("CREATE_PERMISSIONS_ROLE")); - bytes32 constant public EMPTY_PARAM_HASH = keccak256(abi.encodePacked(uint256(0))); - - // APMRegistry - bytes32 constant public CREATE_REPO_ROLE = keccak256(abi.encodePacked("CREATE_REPO_ROLE")); - - // ENSSubdomainRegistrar - bytes32 constant public CREATE_NAME_ROLE = keccak256(abi.encodePacked("CREATE_NAME_ROLE")); - bytes32 constant public DELETE_NAME_ROLE = keccak256(abi.encodePacked("DELETE_NAME_ROLE")); - bytes32 constant public POINT_ROOTNODE_ROLE = keccak256(abi.encodePacked("POINT_ROOTNODE_ROLE")); - - // EVMScriptRegistry - bytes32 constant public EVMSCRIPT_REGISTRY_APP_ID = keccak256(abi.encodePacked(APM_NODE, keccak256("evmreg"))); - bytes32 constant public REGISTRY_ADD_EXECUTOR_ROLE = keccak256("REGISTRY_ADD_EXECUTOR_ROLE"); - bytes32 constant public REGISTRY_MANAGER_ROLE = keccak256(abi.encodePacked("REGISTRY_MANAGER_ROLE")); - - // EVMScriptExecutor types - bytes32 constant public EVMSCRIPT_EXECUTOR_CALLS_SCRIPT = keccak256(abi.encodePacked("CALLS_SCRIPT")); - - // Repo - bytes32 constant public CREATE_VERSION_ROLE = keccak256(abi.encodePacked("CREATE_VERSION_ROLE")); - - // Unstructured storage - bytes32 public constant initializationBlockPosition = keccak256(abi.encodePacked("aragonOS.initializable.initializationBlock")); - bytes32 public constant depositablePosition = keccak256(abi.encodePacked("aragonOS.depositableStorage.depositable")); - bytes32 public constant kernelPosition = keccak256(abi.encodePacked("aragonOS.appStorage.kernel")); - bytes32 public constant appIdPosition = keccak256(abi.encodePacked("aragonOS.appStorage.appId")); - bytes32 public constant pinnedCodePosition = keccak256(abi.encodePacked("aragonOS.appStorage.pinnedCode")); -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/KernelDepositableMock.sol b/apps/shared/test-helpers/contracts/test/mocks/KernelDepositableMock.sol deleted file mode 100644 index cf0e16f11..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/KernelDepositableMock.sol +++ /dev/null @@ -1,17 +0,0 @@ -pragma solidity 0.4.24; - -import "../../common/DepositableStorage.sol"; -import "../../kernel/Kernel.sol"; - -contract KernelDepositableMock is Kernel, DepositableStorage { - constructor(bool _shouldPetrify) Kernel(_shouldPetrify) public { - } - - function () external payable { - require(isDepositable()); - } - - function enableDeposits() external isInitialized { - setDepositable(true); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/KernelOverloadMock.sol b/apps/shared/test-helpers/contracts/test/mocks/KernelOverloadMock.sol deleted file mode 100644 index 6a9d36c39..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/KernelOverloadMock.sol +++ /dev/null @@ -1,31 +0,0 @@ -pragma solidity 0.4.24; - -import "../../kernel/Kernel.sol"; -import "../../lib/misc/ERCProxy.sol"; - - -/** Ugly hack to work around this issue: - * https://github.com/trufflesuite/truffle/issues/569 - * https://github.com/trufflesuite/truffle/issues/737 - */ -contract KernelOverloadMock { - Kernel kernel; - - event NewAppProxy(address proxy); - - constructor(address _kernel) public { - kernel = Kernel(_kernel); - } - - //function newAppInstance(bytes32 _name, address _appBase, bytes _initializePayload, bool _setDefault) auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _name)) public returns (ERCProxy appProxy) { - function newAppInstance(bytes32 _name, address _appBase, bytes _initializePayload, bool _setDefault) public returns (ERCProxy appProxy) { - appProxy = kernel.newAppInstance(_name, _appBase, _initializePayload, _setDefault); - emit NewAppProxy(appProxy); - } - - // function newPinnedAppInstance(bytes32 _name, address _appBase, bytes _initializePayload, bool _setDefault) auth(APP_MANAGER_ROLE, arr(APP_BASES_NAMESPACE, _name)) public returns (ERCProxy appProxy) { - function newPinnedAppInstance(bytes32 _name, address _appBase, bytes _initializePayload, bool _setDefault) public returns (ERCProxy appProxy) { - appProxy = kernel.newPinnedAppInstance(_name, _appBase, _initializePayload, _setDefault); - emit NewAppProxy(appProxy); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/KernelSetAppMock.sol b/apps/shared/test-helpers/contracts/test/mocks/KernelSetAppMock.sol deleted file mode 100644 index df713cee4..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/KernelSetAppMock.sol +++ /dev/null @@ -1,13 +0,0 @@ -pragma solidity 0.4.24; - -import "../../kernel/Kernel.sol"; - -contract KernelSetAppMock is Kernel { - constructor() Kernel(false) public { - } - - // Overloaded mock to bypass the auth and isContract checks - function setApp(bytes32 _namespace, bytes32 _appId, address _app) public { - apps[_namespace][_appId] = _app; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/LifecycleMock.sol b/apps/shared/test-helpers/contracts/test/mocks/LifecycleMock.sol deleted file mode 100644 index bb52fcb85..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/LifecycleMock.sol +++ /dev/null @@ -1,15 +0,0 @@ -pragma solidity 0.4.24; - -import "../../common/Initializable.sol"; -import "../../common/Petrifiable.sol"; - - -contract LifecycleMock is Initializable, Petrifiable { - function initializeMock() public { - initialized(); - } - - function petrifyMock() public { - petrify(); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/MockScriptExecutorApp.sol b/apps/shared/test-helpers/contracts/test/mocks/MockScriptExecutorApp.sol deleted file mode 100644 index 291272390..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/MockScriptExecutorApp.sol +++ /dev/null @@ -1,33 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apps/AragonApp.sol"; - - -contract MockScriptExecutorApp is AragonApp { - // Initialization is required to access any of the real executors - function initialize() public { - initialized(); - } - - function execute(bytes script) public { - runScript(script, new bytes(0), new address[](0)); - } - - function executeWithBan(bytes script, address[] memory blacklist) public { - runScript(script, new bytes(0), blacklist); - } - - function executeWithIO(bytes script, bytes input, address[] memory blacklist) public returns (bytes) { - return runScript(script, input, blacklist); - } - - /* - function getActionsCount(bytes script) public constant returns (uint256) { - return getScriptActionsCount(script); - } - - function getAction(bytes script, uint256 i) public constant returns (address, bytes) { - return getScriptAction(script, i); - } - */ -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/SafeMath64Mock.sol b/apps/shared/test-helpers/contracts/test/mocks/SafeMath64Mock.sol deleted file mode 100644 index bd1fec780..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/SafeMath64Mock.sol +++ /dev/null @@ -1,28 +0,0 @@ -pragma solidity 0.4.24; - -import "../../lib/math/SafeMath64.sol"; - - -contract SafeMath64Mock { - using SafeMath64 for uint64; - - function mulExt(uint64 _a, uint64 _b) public pure returns (uint64) { - return _a.mul(_b); - } - - function divExt(uint64 _a, uint64 _b) public pure returns (uint64) { - return _a.div(_b); - } - - function subExt(uint64 _a, uint64 _b) public pure returns (uint64) { - return _a.sub(_b); - } - - function addExt(uint64 _a, uint64 _b) public pure returns (uint64) { - return _a.add(_b); - } - - function modExt(uint64 _a, uint64 _b) public pure returns (uint64) { - return _a.mod(_b); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/SafeMath8Mock.sol b/apps/shared/test-helpers/contracts/test/mocks/SafeMath8Mock.sol deleted file mode 100644 index 7105f0ee9..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/SafeMath8Mock.sol +++ /dev/null @@ -1,28 +0,0 @@ -pragma solidity 0.4.24; - -import "../../lib/math/SafeMath8.sol"; - - -contract SafeMath8Mock { - using SafeMath8 for uint8; - - function mulExt(uint8 _a, uint8 _b) public pure returns (uint8) { - return _a.mul(_b); - } - - function divExt(uint8 _a, uint8 _b) public pure returns (uint8) { - return _a.div(_b); - } - - function subExt(uint8 _a, uint8 _b) public pure returns (uint8) { - return _a.sub(_b); - } - - function addExt(uint8 _a, uint8 _b) public pure returns (uint8) { - return _a.add(_b); - } - - function modExt(uint8 _a, uint8 _b) public pure returns (uint8) { - return _a.mod(_b); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/TimeHelpersMock.sol b/apps/shared/test-helpers/contracts/test/mocks/TimeHelpersMock.sol deleted file mode 100644 index d8bf3234b..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/TimeHelpersMock.sol +++ /dev/null @@ -1,30 +0,0 @@ -pragma solidity 0.4.24; - -import "../../common/TimeHelpers.sol"; - - -contract TimeHelpersMock is TimeHelpers { - function getBlockNumberDirect() public view returns (uint256) { - return block.number; - } - - function getBlockNumberExt() public view returns (uint256) { - return getBlockNumber(); - } - - function getBlockNumber64Ext() public view returns (uint64) { - return getBlockNumber64(); - } - - function getTimestampDirect() public view returns (uint256) { - return now; - } - - function getTimestampExt() public view returns (uint256) { - return getTimestamp(); - } - - function getTimestamp64Ext() public view returns (uint64) { - return getTimestamp64(); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/TokenMock.sol b/apps/shared/test-helpers/contracts/test/mocks/TokenMock.sol deleted file mode 100644 index 7442d80be..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/TokenMock.sol +++ /dev/null @@ -1,46 +0,0 @@ -// Stripped from https://github.com/OpenZeppelin/openzeppelin-solidity/blob/a9f910d34f0ab33a1ae5e714f69f9596a02b4d91/contracts/token/ERC20/StandardToken.sol - -pragma solidity 0.4.24; - -import "../../lib/math/SafeMath.sol"; - - -contract TokenMock { - using SafeMath for uint256; - mapping (address => uint256) private balances; - uint256 private totalSupply_; - - event Transfer(address indexed from, address indexed to, uint256 value); - - // Allow us to set the inital balance for an account on construction - constructor(address initialAccount, uint256 initialBalance) public { - balances[initialAccount] = initialBalance; - totalSupply_ = initialBalance; - } - - function totalSupply() public view returns (uint256) { return totalSupply_; } - - /** - * @dev Gets the balance of the specified address. - * @param _owner The address to query the the balance of. - * @return An uint256 representing the amount owned by the passed address. - */ - function balanceOf(address _owner) public view returns (uint256) { - return balances[_owner]; - } - - /** - * @dev Transfer token for a specified address - * @param _to The address to transfer to. - * @param _value The amount to be transferred. - */ - function transfer(address _to, uint256 _value) public returns (bool) { - require(_value <= balances[msg.sender]); - require(_to != address(0)); - - balances[msg.sender] = balances[msg.sender].sub(_value); - balances[_to] = balances[_to].add(_value); - emit Transfer(msg.sender, _to, _value); - return true; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/Uint256Mock.sol b/apps/shared/test-helpers/contracts/test/mocks/Uint256Mock.sol deleted file mode 100644 index 9616376d7..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/Uint256Mock.sol +++ /dev/null @@ -1,12 +0,0 @@ -pragma solidity 0.4.24; - -import "../../common/Uint256Helpers.sol"; - - -contract Uint256Mock { - using Uint256Helpers for uint256; - - function convert(uint256 a) public pure returns (uint64) { - return a.toUint64(); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/UnsafeAragonAppMock.sol b/apps/shared/test-helpers/contracts/test/mocks/UnsafeAragonAppMock.sol deleted file mode 100644 index 61551949c..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/UnsafeAragonAppMock.sol +++ /dev/null @@ -1,19 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apps/UnsafeAragonApp.sol"; -import "../../kernel/IKernel.sol"; - - -contract UnsafeAragonAppMock is UnsafeAragonApp { - function initialize() public { - initialized(); - } - - function getKernel() public view returns (IKernel) { - return kernel(); - } - - function setKernelOnMock(IKernel _kernel) public { - setKernel(_kernel); - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/UnsafeRepo.sol b/apps/shared/test-helpers/contracts/test/mocks/UnsafeRepo.sol deleted file mode 100644 index ce121b9c0..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/UnsafeRepo.sol +++ /dev/null @@ -1,13 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apm/Repo.sol"; -import "../../apps/UnsafeAragonApp.sol"; - - -// Allows Repo to be used without a proxy or access controls -contract UnsafeRepo is Repo, UnsafeAragonApp { - // Protected actions are always performable - function canPerform(address, bytes32, uint256[]) public view returns (bool) { - return true; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/UpgradedKernel.sol b/apps/shared/test-helpers/contracts/test/mocks/UpgradedKernel.sol deleted file mode 100644 index 5a00fd2a5..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/UpgradedKernel.sol +++ /dev/null @@ -1,14 +0,0 @@ -pragma solidity 0.4.24; - -import "../../kernel/Kernel.sol"; - - -contract UpgradedKernel is Kernel { - constructor(bool _shouldPetrify) Kernel(_shouldPetrify) public {} - - // just adds one more function to the kernel implementation. - // calling this function on the previous instance will fail - function isUpgraded() public pure returns (bool) { - return true; - } -} diff --git a/apps/shared/test-helpers/contracts/test/mocks/VaultMock.sol b/apps/shared/test-helpers/contracts/test/mocks/VaultMock.sol deleted file mode 100644 index 452f8ea25..000000000 --- a/apps/shared/test-helpers/contracts/test/mocks/VaultMock.sol +++ /dev/null @@ -1,18 +0,0 @@ -pragma solidity 0.4.24; - -import "../../apps/UnsafeAragonApp.sol"; -import "../../common/DepositableStorage.sol"; - - -contract VaultMock is UnsafeAragonApp, DepositableStorage { - event LogFund(address sender, uint256 amount); - - function initialize() external { - initialized(); - setDepositable(true); - } - - function () external payable { - emit LogFund(msg.sender, msg.value); - } -} From 1c3d05ea31dacde7ff5a430ad1b8df4808ebdaaf Mon Sep 17 00:00:00 2001 From: Otto G Date: Mon, 10 Feb 2020 09:37:14 +0100 Subject: [PATCH 2/2] style: remove trailing whitespaces everywhere --- apps/address-book/app/app-state-reducer.js | 2 +- apps/address-book/public/meta/audit.md | 8 +- apps/allocations/app/store/allocation.js | 2 +- apps/allocations/public/meta/audit.md | 12 +- apps/allocations/public/meta/details.md | 2 +- apps/allocations/test/Allocations.test.js | 4 +- apps/dot-voting/app/utils/useUserVoteStats.js | 2 +- apps/dot-voting/public/meta/audit.md | 114 +++++++++--------- apps/projects/app/assets/IconOpen.js | 2 +- apps/projects/app/utils/math-utils.js | 8 +- apps/projects/public/meta/audit.md | 14 +-- apps/rewards/app/app-state-reducer.js | 4 +- .../app/components/Panel/RewardSummary.js | 4 +- apps/rewards/app/store/token.js | 2 +- apps/rewards/public/meta/audit.md | 20 +-- cypress/integration/address-book.spec.js | 2 +- cypress/integration/allocations.spec.js | 10 +- cypress/integration/projects.spec.js | 8 +- cypress/integration/rewards.spec.js | 8 +- docs/DEVELOPMENT_NOTES.md | 2 +- docs/GETTING_STARTED.md | 6 +- shared/deployments/check-publish.sh | 2 +- shared/deployments/rinkeby.md | 14 +-- shared/deployments/staging.md | 6 +- .../StandardBounties/docs/documentation_v1.md | 2 +- .../integrations/StandardBounties/graph.txt | 2 +- shared/store-utils/token.js | 4 +- templates/dev/scripts/new-dao.js | 4 +- templates/dev/temp/helpers/apps.js | 2 +- .../open-enterprise/public/Template.audit.md | 4 +- .../open-enterprise/temp/helpers/apps.js | 2 +- .../open-enterprise/temp/lib/OEDeployer.js | 2 +- .../open-enterprise/temp/scripts/new-dao.js | 8 +- .../temp/scripts/test-ganache.sh | 2 +- 34 files changed, 145 insertions(+), 145 deletions(-) diff --git a/apps/address-book/app/app-state-reducer.js b/apps/address-book/app/app-state-reducer.js index 1d441e192..9fa691695 100644 --- a/apps/address-book/app/app-state-reducer.js +++ b/apps/address-book/app/app-state-reducer.js @@ -3,5 +3,5 @@ const appStateReducer = state => { ...state } } - + export default appStateReducer \ No newline at end of file diff --git a/apps/address-book/public/meta/audit.md b/apps/address-book/public/meta/audit.md index 577ce5129..0b787c2c4 100644 --- a/apps/address-book/public/meta/audit.md +++ b/apps/address-book/public/meta/audit.md @@ -54,12 +54,12 @@ Stages of the audit were as follows: ### CRITICAL Not found - + ### MAJOR Not found ### WARNINGS - + Not found ### COMMENTS @@ -72,7 +72,7 @@ We recommend adding the explicit check `isInitialized`. 2\. [AddressBook.sol#L91](https://github.com/AutarkLabs/planning-suite/blob/66a851551888ba7eadaab6a5f037048655bc5d88/apps/address-book/contracts/AddressBook.sol#L91) -There is a constant for this kind of error message - `ERROR_CID_MALFORMED`. We recommend factoring out the entire check as a modifier. +There is a constant for this kind of error message - `ERROR_CID_MALFORMED`. We recommend factoring out the entire check as a modifier. *Fixed at [ed2f199](https://github.com/AutarkLabs/planning-suite/blob/ed2f199ddda280d1e7033648b69399547f05eec7/apps/address-book/contracts/AddressBook.sol)* @@ -95,7 +95,7 @@ The important thing to understand is that the memory layout of the next version It is expected that structured content objects for the entries will be stored in IPFS. Users and developers should keep in mind that IPFS does not guarantee data availability. After some time unused data is removed from IPFS unless explicitly pinned by some node. -*Acknowledged, dev notes were created at [AddressBook.sol#L60](https://github.com/AutarkLabs/planning-suite/blob/4f3f11c194b285f8e407e3cd4def56afb418b233/apps/address-book/contracts/AddressBook.sol#L60)* +*Acknowledged, dev notes were created at [AddressBook.sol#L60](https://github.com/AutarkLabs/planning-suite/blob/4f3f11c194b285f8e407e3cd4def56afb418b233/apps/address-book/contracts/AddressBook.sol#L60)* 6\. [AddressBook.sol#L64](https://github.com/AutarkLabs/planning-suite/blob/66a851551888ba7eadaab6a5f037048655bc5d88/apps/address-book/contracts/AddressBook.sol#L64) diff --git a/apps/allocations/app/store/allocation.js b/apps/allocations/app/store/allocation.js index 53fb7ae80..dbeab7956 100644 --- a/apps/allocations/app/store/allocation.js +++ b/apps/allocations/app/store/allocation.js @@ -122,7 +122,7 @@ const getRecipientData = (_accountId, _payoutId) => { return app.call('getNumberOfCandidates', _accountId, _payoutId) .pipe( first(), - mergeMap(candidateLength => + mergeMap(candidateLength => range(0, candidateLength) ), mergeMap(candidateIndex => ( diff --git a/apps/allocations/public/meta/audit.md b/apps/allocations/public/meta/audit.md index 03c1e4c66..8acfc6f66 100644 --- a/apps/allocations/public/meta/audit.md +++ b/apps/allocations/public/meta/audit.md @@ -57,7 +57,7 @@ Not found ### MAJOR Not found - + ### WARNINGS 1\. [Allocations.sol#L463](https://github.com/AutarkLabs/planning-suite/blob/5be80e35f6e8e2c58f2b1b0f95f43baf40886507/apps/allocations/contracts/Allocations.sol#L463) @@ -96,7 +96,7 @@ The cycle will be aborted and the transaction will be rolled back if there are ` 5\. [Allocations.sol#L358](https://github.com/AutarkLabs/planning-suite/blob/5be80e35f6e8e2c58f2b1b0f95f43baf40886507/apps/allocations/contracts/Allocations.sol#L358) -New periods are not being initialized. We suggest adding the `transitionsPeriod` modifier. +New periods are not being initialized. We suggest adding the `transitionsPeriod` modifier. *Fixed at [26e6d37](https://github.com/AutarkLabs/open-enterprise/commit/26e6d3766393ed2d12fc57471b56d42c4a680fef)* @@ -121,7 +121,7 @@ When calling `runPayout`, `paid` should be passed externally, otherwise this var ### COMMENTS -1\. [Allocations.sol#L40-L45](https://github.com/AutarkLabs/planning-suite/blob/5be80e35f6e8e2c58f2b1b0f95f43baf40886507/apps/allocations/contracts/Allocations.sol#L40-L45) +1\. [Allocations.sol#L40-L45](https://github.com/AutarkLabs/planning-suite/blob/5be80e35f6e8e2c58f2b1b0f95f43baf40886507/apps/allocations/contracts/Allocations.sol#L40-L45) Constants can be calculated in advance. @@ -149,7 +149,7 @@ Gas consumption required to save `Account` can be reduced. Place `uint64 payouts There’s no need to use the `uint64` key instead of the `uint` one as element adding requires the same amount of gas as `uint`. -*Acknowledged* +*Acknowledged* 5\. [Allocations.sol#L95](https://github.com/AutarkLabs/planning-suite/blob/5be80e35f6e8e2c58f2b1b0f95f43baf40886507/apps/allocations/contracts/Allocations.sol#L95) @@ -314,7 +314,7 @@ This check should also involve `_recurrences`, as at the moment it does not refl [26e6d37](https://github.com/AutarkLabs/open-enterprise/commit/26e6d3766393ed2d12fc57471b56d42c4a680fef)* -23\. [Allocations.sol#L76](https://github.com/AutarkLabs/planning-suite/blob/5be80e35f6e8e2c58f2b1b0f95f43baf40886507/apps/allocations/contracts/Allocations.sol#L76) +23\. [Allocations.sol#L76](https://github.com/AutarkLabs/planning-suite/blob/5be80e35f6e8e2c58f2b1b0f95f43baf40886507/apps/allocations/contracts/Allocations.sol#L76) If it is not planned to set the budget for the account equal to 0, then `hasBudget` can be omitted, as the `budget != 0` comparison will be equivalent to `hasBudget`. @@ -368,7 +368,7 @@ We recommend adding extra checks: Zero initialization is unnecessary. -*Fixed at +*Fixed at [26e6d37](https://github.com/AutarkLabs/open-enterprise/commit/26e6d3766393ed2d12fc57471b56d42c4a680fef)* diff --git a/apps/allocations/public/meta/details.md b/apps/allocations/public/meta/details.md index 5de61851b..3f4e215b6 100644 --- a/apps/allocations/public/meta/details.md +++ b/apps/allocations/public/meta/details.md @@ -1,4 +1,4 @@ -The Allocations app is used to manage multi-recipient financial allocations that are budget-controlled. Budgets represent spending limits on categorized allocation payments. +The Allocations app is used to manage multi-recipient financial allocations that are budget-controlled. Budgets represent spending limits on categorized allocation payments. ## Features - Create and edit budgets that set spending limits on allocation categories. diff --git a/apps/allocations/test/Allocations.test.js b/apps/allocations/test/Allocations.test.js index 780038e65..b9aa64b9f 100644 --- a/apps/allocations/test/Allocations.test.js +++ b/apps/allocations/test/Allocations.test.js @@ -334,7 +334,7 @@ contract('Allocations', accounts => { (web3.toWei(0.01, 'ether') * SUPPORTS[2]) / TOTAL_SUPPORT, 'bossk expense' ) - + await app.runPayout(accountId, ethPayoutId) // calling runPayout has no effect @@ -415,7 +415,7 @@ contract('Allocations', accounts => { it('execute single payout by candidate', async () => { let empireBalance = await web3.eth.getBalance(empire) - + //Repay gas costs to empire const costs = ( empireInitialBalance.toNumber() diff --git a/apps/dot-voting/app/utils/useUserVoteStats.js b/apps/dot-voting/app/utils/useUserVoteStats.js index 5b1edeab3..df74e53d8 100644 --- a/apps/dot-voting/app/utils/useUserVoteStats.js +++ b/apps/dot-voting/app/utils/useUserVoteStats.js @@ -7,7 +7,7 @@ import tokenBalanceOfAbi from '../abi/token-balanceof.json' const tokenAbi = [].concat(tokenBalanceOfAbi) // TODO: apply cleanups to the useEffects since this is generating errors in the browser: -/* +/* react-dom.development.js:558 Warning: Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in a useEffect cleanup function. diff --git a/apps/dot-voting/public/meta/audit.md b/apps/dot-voting/public/meta/audit.md index 7c60f8f39..904beef47 100644 --- a/apps/dot-voting/public/meta/audit.md +++ b/apps/dot-voting/public/meta/audit.md @@ -57,18 +57,18 @@ Not found ### MAJOR Not found - + ### WARNINGS -1\. [ADynamicForwarder.sol#L344](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L344) +1\. [ADynamicForwarder.sol#L344](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L344) -[ADynamicForwarder.sol#L474](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L474) +[ADynamicForwarder.sol#L474](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L474) -[ADynamicForwarder.sol#L328](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L328) +[ADynamicForwarder.sol#L328](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L328) -[ADynamicForwarder.sol#L454](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L454) +[ADynamicForwarder.sol#L454](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L454) -[ADynamicForwarder.sol#L460](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L460) +[ADynamicForwarder.sol#L460](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L460) During the `copy` function execution ([see here](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L55)) extra 32 bytes are being copied. The copy function is probably being used incorrectly or contains an error. We recommend checking this behavior. @@ -76,27 +76,27 @@ During the `copy` function execution ([see here](https://github.com/AutarkLabs/p [5490732](https://github.com/AutarkLabs/open-enterprise/commit/549073274f690f65aef2e01dd68dc25703cbffce)* -2\. [DotVoting.sol#L157](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L157) +2\. [DotVoting.sol#L157](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L157) -[DotVoting.sol#L277](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L277) +[DotVoting.sol#L277](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L277) -[DotVoting.sol#L265](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L265) +[DotVoting.sol#L265](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L265) -[DotVoting.sol#L278](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L278) +[DotVoting.sol#L278](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L278) -[DotVoting.sol#L310](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L310) +[DotVoting.sol#L310](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L310) -[DotVoting.sol#L332](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L332) +[DotVoting.sol#L332](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L332) -[DotVoting.sol#L342](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L342) +[DotVoting.sol#L342](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L342) -[DotVoting.sol#L352](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L352) +[DotVoting.sol#L352](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L352) -[DotVoting.sol#L419](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L419) +[DotVoting.sol#L419](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L419) -[DotVoting.sol#L465](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L465) +[DotVoting.sol#L465](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L465) -[DotVoting.sol#L486](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L486) +[DotVoting.sol#L486](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L486) Access to a non-existent voting is allowed. We recommend adding a check that the voting id passed in the parameters exists. @@ -106,7 +106,7 @@ Access to a non-existent voting is allowed. We recommend adding a check that the 3\. [DotVoting.sol#L442](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L442) -[DotVoting.sol#L452](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L452) +[DotVoting.sol#L452](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L452) It is allowed to go beyond the boundaries of the `cKeys` array. We recommend adding a check that `i` does not go beyond the boundaries of the array. @@ -114,17 +114,17 @@ It is allowed to go beyond the boundaries of the `cKeys` array. We recommend add [b5dd6c3](https://github.com/AutarkLabs/open-enterprise/commit/b5dd6c3c879c7e4123b1e10108359bcccee57d8a/apps/dot-voting/contracts/DotVoting.sol)* -4\. [ScriptHelpers.sol#L74](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L74) +4\. [ScriptHelpers.sol#L74](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L74) -[ScriptHelpers.sol#L80](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L80) +[ScriptHelpers.sol#L80](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L80) -[ScriptHelpers.sol#L86](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L86) +[ScriptHelpers.sol#L86](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L86) -[ScriptHelpers.sol#L95](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L95) +[ScriptHelpers.sol#L95](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L95) -[ScriptHelpers.sol#L50](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L50) +[ScriptHelpers.sol#L50](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/evmscript/ScriptHelpers.sol#L50) -[ADynamicForwarder.sol#L456](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L456) +[ADynamicForwarder.sol#L456](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L456) We suggest controlling and preventing memory references from going beyond array boundaries for functions that deal directly with array memory. This will prevent errors at an early stage and reduce the risk of hard-to-diagnose memory corruption errors. @@ -133,7 +133,7 @@ We suggest controlling and preventing memory references from going beyond array ### COMMENTS -1\. [DotVoting.sol#L213](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L213) +1\. [DotVoting.sol#L213](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L213) The account with the `ADD_CANDIDATES_ROLE` rights is able to block the vote. It can either add a large number of candidates or a long `_metadata`, so that further processing (`_executeVote` in particular) will be impossible due to block gas restrictions. @@ -158,10 +158,10 @@ or a long `_metadata`, so that further processing (`_executeVote` in particular) [DotVoting.sol#L351](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L351) -We recommend adding the `isInitialized` modifier. +We recommend adding the `isInitialized` modifier. *Fixed at -[b5dd6c3](https://github.com/AutarkLabs/open-enterprise/commit/b5dd6c3c879c7e4123b1e10108359bcccee57d8a/apps/dot-voting/contracts/DotVoting.sol)* +[b5dd6c3](https://github.com/AutarkLabs/open-enterprise/commit/b5dd6c3c879c7e4123b1e10108359bcccee57d8a/apps/dot-voting/contracts/DotVoting.sol)* 3\. [DotVoting.sol#L159-L160](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L159-L160) @@ -169,14 +169,14 @@ We recommend adding the `isInitialized` modifier. Access to a non-existent option is allowed. We recommend adding a check that `_candidateIndex` is valid. *Fixed at -[b5dd6c3](https://github.com/AutarkLabs/open-enterprise/commit/b5dd6c3c879c7e4123b1e10108359bcccee57d8a/apps/dot-voting/contracts/DotVoting.sol)* +[b5dd6c3](https://github.com/AutarkLabs/open-enterprise/commit/b5dd6c3c879c7e4123b1e10108359bcccee57d8a/apps/dot-voting/contracts/DotVoting.sol)* -4\. [DotVoting.sol#L443](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L443) +4\. [DotVoting.sol#L443](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L443) -[DotVoting.sol#L446](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L446) +[DotVoting.sol#L446](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L446) -[DotVoting.sol#L454](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L454) +[DotVoting.sol#L454](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L454) During the function execution, the value of `voteInstance.totalParticipation` can be maintained in a local variable and then written to storage at the end of the method to save gas. @@ -184,12 +184,12 @@ During the function execution, the value of `voteInstance.totalParticipation` ca [b5dd6c3](https://github.com/AutarkLabs/open-enterprise/commit/b5dd6c3c879c7e4123b1e10108359bcccee57d8a/apps/dot-voting/contracts/DotVoting.sol)* -5\. [DotVoting.sol#L504](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L504) +5\. [DotVoting.sol#L504](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L504) There is no need to copy `Action` into memory and waste gas on reading the entire structure and allocating memory. We recommend replacing the `memory` qualifier with `storage`. *Fixed at -[b5dd6c3](https://github.com/AutarkLabs/open-enterprise/commit/b5dd6c3c879c7e4123b1e10108359bcccee57d8a/apps/dot-voting/contracts/DotVoting.sol)* +[b5dd6c3](https://github.com/AutarkLabs/open-enterprise/commit/b5dd6c3c879c7e4123b1e10108359bcccee57d8a/apps/dot-voting/contracts/DotVoting.sol)* 6\. [DotVoting.sol#L77-L80](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L77-L80) @@ -203,12 +203,12 @@ In fact, there’s no truncation of the data specified in the comment. We recomm The data type is not a `string` but an `address`. Moreover, this field is used to generate internal keys in the code, and options with the same `_description` are not allowed. We suggest verifying that this behavior is appropriate and update the comment accordingly. *Fixed at -[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol) +[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol) -8\. [DotVoting.sol#L53](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L53) +8\. [DotVoting.sol#L53](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L53) -[ADynamicForwarder.sol#L57-L59](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L57-L59) +[ADynamicForwarder.sol#L57-L59](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L57-L59) Since explicit positions of the storage data are not used, migration of the current contract instance to a new one may be complicated. A simple example of explicit storage data positions can be seen [here](https://github.com/aragon/aragonOS/blob/940605977685cc9ad5ee85d67a6c310e3e8aab24/contracts/apps/AppStorage.sol). @@ -219,15 +219,15 @@ Since explicit positions of the storage data are not used, migration of the curr The incorrect comment was most likely copied from the function below. We recommend updating the comment. *Fixed at -[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol)* +[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol)* -10\. [DotVoting.sol#L212](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L212) +10\. [DotVoting.sol#L212](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L212) A check proving that the vote is still open can be added. Otherwise, it makes no sense to write data to the blockchain. *Fixed at -[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol)* +[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol)* 11\. [DotVoting.sol#L376](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L376) @@ -235,7 +235,7 @@ A check proving that the vote is still open can be added. Otherwise, it makes no The “Description” parameter in the comment is missing. We suggest adding it. *Fixed at -[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol)* +[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol)* 12\. [DotVoting.sol#L415](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L415) @@ -246,10 +246,10 @@ We recommend checking that the length of the `_supports` array does not exceed t 13\. [DotVoting.sol#L372](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L372) -At the moment, the first parameter can only be an address. We recommend correcting the comment. +At the moment, the first parameter can only be an address. We recommend correcting the comment. *Fixed at -[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol)* +[62bf419](https://github.com/AutarkLabs/open-enterprise/commit/62bf4199beba3d71c4023fd698fe9ded66c3d892/apps/dot-voting/contracts/DotVoting.sol)* 14\. [DotVoting.sol#L474](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/dot-voting/contracts/DotVoting.sol#L474) @@ -262,13 +262,13 @@ At the moment, the first parameter can only be an address. We recommend correcti [ADynamicForwarder.sol#L460](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L460) -[ADynamicForwarder.sol#L499](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L499) +[ADynamicForwarder.sol#L499](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L499) -We recommend using the `SafeMath` library for performing subtraction. +We recommend using the `SafeMath` library for performing subtraction. *Acknowledged* -15\. [ADynamicForwarder.sol#L115](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L115) +15\. [ADynamicForwarder.sol#L115](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L115) During processing of the specified expression, a value truncation may occur. Voting options must not exceed 256, which is not controlled. However, the `keyArrayIndex` field is not used. We recommend either deleting the field or adding the according preliminary overflow check. @@ -286,17 +286,17 @@ Intermediate hashing of options can be omitted. In `Action.optionKeys` you can i *Acknowledged* -17\. [ADynamicForwarder.sol#L75](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L75) +17\. [ADynamicForwarder.sol#L75](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L75) -[ADynamicForwarder.sol#L91](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L91) +[ADynamicForwarder.sol#L91](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L91) -[ADynamicForwarder.sol#L107](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L107) +[ADynamicForwarder.sol#L107](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L107) Access to a non-existent `Action` is allowed. We recommend adding a check that `_actionId` is valid. *Acknowledged* -18\. [ADynamicForwarder.sol#L76](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L76) +18\. [ADynamicForwarder.sol#L76](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L76) Access to a non-existent `OptionState` is allowed. We recommend adding a check that `_optionIndex` is valid. @@ -308,36 +308,36 @@ We recommend adding the parameters for description and additional identifiers to *Acknowledged* -20\. [ADynamicForwarder.sol#L122](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L122) +20\. [ADynamicForwarder.sol#L122](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L122) This operation does not change the `actionInstance.optionKeys` value and may consume gas. We recommend removing the assignment. *Acknowledged* -21\. [ADynamicForwarder.sol#L41-L42](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L41-L42) +21\. [ADynamicForwarder.sol#L41-L42](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L41-L42) These fields are assigned but are not used further on. *Acknowledged* -22\. [ADynamicForwarder.sol#L414](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L414) +22\. [ADynamicForwarder.sol#L414](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L414) There is no need to allocate 32 memory bytes as the value will be replaced in the next line. *Acknowledged* -23\. [ADynamicForwarder.sol#L363](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L363) +23\. [ADynamicForwarder.sol#L363](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L363) -[ADynamicForwarder.sol#L380](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L380) +[ADynamicForwarder.sol#L380](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L380) -The incorrect comment was most likely copied from the function below. We recommend updating the comment. +The incorrect comment was most likely copied from the function below. We recommend updating the comment. *Acknowledged* -24\. [ADynamicForwarder.sol#L460](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L460) +24\. [ADynamicForwarder.sol#L460](https://github.com/AutarkLabs/planning-suite/blob/efd5cdee9c649593f95b65818a2dde1d515dc65a/apps/shared/test-helpers/contracts/common/ADynamicForwarder.sol#L460) In case numerical values (for instance, `288` and `256`) are calculated in a sophisticated way, we do not recommend writing them into the code in a pre-calculated form. This greatly complicates the code maintainability and readability. Structural parameter changes will entail verification and/or recalculation of such values. Some of these recalculations may be missed by mistake. -We recommend calculating them in the code explicitly, based on the number and nature of the calldata parameters. This will lead to higher gas consumption, but reduce the likelihood of errors. +We recommend calculating them in the code explicitly, based on the number and nature of the calldata parameters. This will lead to higher gas consumption, but reduce the likelihood of errors. *Acknowledged* diff --git a/apps/projects/app/assets/IconOpen.js b/apps/projects/app/assets/IconOpen.js index 53cf4ff21..cc31615a8 100644 --- a/apps/projects/app/assets/IconOpen.js +++ b/apps/projects/app/assets/IconOpen.js @@ -1,6 +1,6 @@ import React from 'react' -const IconOpen = () => ( +const IconOpen = () => ( diff --git a/apps/projects/app/utils/math-utils.js b/apps/projects/app/utils/math-utils.js index 82f2233f1..a4e47691b 100644 --- a/apps/projects/app/utils/math-utils.js +++ b/apps/projects/app/utils/math-utils.js @@ -27,23 +27,23 @@ export function fromDecimals(num, decimals, { truncate = true } = {}) { if (!whole && !dec) { return '0' } - + const paddedWhole = whole.padStart(decimals + 1, '0') const decimalIndex = paddedWhole.length - decimals const wholeWithoutBase = paddedWhole.slice(0, decimalIndex) const decWithoutBase = paddedWhole.slice(decimalIndex) - + if (!truncate && dec) { // We need to keep all the zeroes in this case return `${wholeWithoutBase}.${decWithoutBase}${dec}` } - + // Trim any trailing zeroes from the new decimals const decWithoutBaseTrimmed = decWithoutBase.replace(/0*$/, '') if (decWithoutBaseTrimmed) { return `${wholeWithoutBase}.${decWithoutBaseTrimmed}` } - + return wholeWithoutBase } diff --git a/apps/projects/public/meta/audit.md b/apps/projects/public/meta/audit.md index b3faada56..44d213a82 100644 --- a/apps/projects/public/meta/audit.md +++ b/apps/projects/public/meta/audit.md @@ -71,7 +71,7 @@ Before calling `acceptFulfillment`, make sure that the sum of all the values in ### WARNINGS -1\. [Projects.sol#L340](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L340) +1\. [Projects.sol#L340](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L340) When a repository is deleted, funds in open bounties related to repository issues become (at least temporarily) blocked. We recommend you keep score of open bounty repositories and prohibit deleting them if this entails a loss of funds. @@ -189,7 +189,7 @@ Re-calling `isContract(_bountiesAddr)` is not beneficial and gas-consuming. We r *Fixed at [0d1835d](https://github.com/AutarkLabs/open-enterprise/commit/0d1835d5499af056fc24969e9d5d306e856b674d)* -7\. [Projects.sol#L269](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L269) +7\. [Projects.sol#L269](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L269) We recommend using the current `bountySize` directly from `Bounties`. This step may be skipped if, after fixing major issue #1, `bountySize` will always be equal to the corresponding bounty balance in `Bounties`. @@ -197,7 +197,7 @@ We recommend using the current `bountySize` directly from `Bounties`. This step 8\. [Projects.sol#L572](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L572) -[Projects.sol#L622](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L622) +[Projects.sol#L622](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L622) Input array length validation is missing. We recommend adding a check that all input array lengths are equal. @@ -223,11 +223,11 @@ Since `assignee` is set here, using `ETH` instead of `address(0)` is misleading. *Fixed at [0d1835d](https://github.com/AutarkLabs/open-enterprise/commit/0d1835d5499af056fc24969e9d5d306e856b674d)* 12\. There is no way to withdraw or use contributions made directly through the `Bounties` contract. -One of the possible solutions is multiple `drainBounty` function calls. +One of the possible solutions is multiple `drainBounty` function calls. *Acknowledged* -13\. There is no way to get all issues for a given repository. Problems may arise while creating the issue list. +13\. There is no way to get all issues for a given repository. Problems may arise while creating the issue list. One of the possible solutions is using a repository issue counter. *Acknowledged* @@ -240,7 +240,7 @@ This comment is not accurate because the function does not return the id of the 15\. [Projects.sol#L150-L151](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L150-L151) -[Projects.sol#L157](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L157) +[Projects.sol#L157](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L157) [Projects.sol#L162](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L162) @@ -275,7 +275,7 @@ The common code (comprising 90% of the given functions) may be moved to a separa [Projects.sol#L882](https://github.com/AutarkLabs/planning-suite/blob/d6acd0820939813c974625b634361156dfced360/apps/projects/contracts/Projects.sol#L882) -We recommend eliminating the commented code fragments. +We recommend eliminating the commented code fragments. *Fixed at [0d1835d](https://github.com/AutarkLabs/open-enterprise/commit/0d1835d5499af056fc24969e9d5d306e856b674d)* diff --git a/apps/rewards/app/app-state-reducer.js b/apps/rewards/app/app-state-reducer.js index 1d8a914f9..30128efbe 100644 --- a/apps/rewards/app/app-state-reducer.js +++ b/apps/rewards/app/app-state-reducer.js @@ -15,7 +15,7 @@ import { import { MILLISECONDS_IN_A_MONTH, MILLISECONDS_IN_A_WEEK, MILLISECONDS_IN_A_YEAR, MILLISECONDS_IN_A_DAY } from '../../../shared/ui/utils/math-utils' function appStateReducer(state) { - + if(state){ state.amountTokens = state.balances.map(token => { return { amount: token.amount, symbol: token.symbol, address: token.address, decimals: token.decimals, transferable: token.transfersEnabled } @@ -24,7 +24,7 @@ function appStateReducer(state) { state.claims = state.claims || [] state.rewards = state.rewards === [] ? [] : state.rewards.reduce((rewards, reward) => { const currentReward = reward.isMerit ? undefined : rewards.find(filteredElement => { - return filteredElement.description === reward.description && parseInt(filteredElement.rewardId, 10) + filteredElement.occurances === parseInt(reward.rewardId) && + return filteredElement.description === reward.description && parseInt(filteredElement.rewardId, 10) + filteredElement.occurances === parseInt(reward.rewardId) && reward.amount === filteredElement.amount && filteredElement.duration === reward.duration }) if(currentReward !== undefined){ diff --git a/apps/rewards/app/components/Panel/RewardSummary.js b/apps/rewards/app/components/Panel/RewardSummary.js index f00731bc4..a256c0e83 100644 --- a/apps/rewards/app/components/Panel/RewardSummary.js +++ b/apps/rewards/app/components/Panel/RewardSummary.js @@ -65,10 +65,10 @@ const RewardSummary = ({ reward, theme, onCancel, onSubmit }) => { {rewardType === ONE_TIME_MERIT ? 'Earning the reference asset between the start and end date' - : 'Holding the reference asset at the disbursement date' + : 'Holding the reference asset at the disbursement date' + (rewardType === 'RECURRING_DIVIDEND' ? 's' : '') } - + {' will issue a proportionally split reward across all token holders.'} { onCancel && onSubmit && ( diff --git a/apps/rewards/app/store/token.js b/apps/rewards/app/store/token.js index e73eb77b5..5c0b96aff 100644 --- a/apps/rewards/app/store/token.js +++ b/apps/rewards/app/store/token.js @@ -4,7 +4,7 @@ import { getTransferable, isTokenVerified, } from '../utils/token-utils' -import { +import { getPresetTokens, getTokenDecimals, getTokenName, diff --git a/apps/rewards/public/meta/audit.md b/apps/rewards/public/meta/audit.md index 5077ebb6f..977a1b841 100644 --- a/apps/rewards/public/meta/audit.md +++ b/apps/rewards/public/meta/audit.md @@ -52,20 +52,20 @@ Stages of the audit were as follows: ## Detected Issues ### CRITICAL - + 1\. [Rewards.sol#L84](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L84) -There is no check that the user has not already claimed his reward. As a result, anybody with some reference token amount can claim all reward tokens from the vault. +There is no check that the user has not already claimed his reward. As a result, anybody with some reference token amount can claim all reward tokens from the vault. We recommend adding the check. *Fixed at [7dab770](https://github.com/AutarkLabs/planning-suite/blob/7dab770e5bcf758268e51429e3702eb8305ce242/apps/rewards/contracts/Rewards.sol)* - + ### MAJOR Not found - + ### WARNINGS 1\. [Rewards.sol#L211](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L211) @@ -74,7 +74,7 @@ There are no blockchain-enforced guarantees that the vault will be able to distr *Acknowledged* -2\. [Rewards.sol#L252](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L252) +2\. [Rewards.sol#L252](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L252) The current implementation of one-time rewards would work only if the balances of the reference token holders and the total supply were monotonically increasing functions. This requirement is not provided by the MiniMeToken. Strictly speaking, the code does not adhere to the Aragon Planning App paper. @@ -84,7 +84,7 @@ The simplest way to solve the problem is to implement an ancestor of the MiniMeT [Rewards.sol#L213-L215](https://github.com/AutarkLabs/planning-suite/blob/7dab770e5bcf758268e51429e3702eb8305ce242/apps/rewards/contracts/Rewards.sol#L213-L215)* -3\. [Rewards.sol#L256](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L256) +3\. [Rewards.sol#L256](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L256) As an example of the previous warning: suppose a user received newly minted reference tokens, but the total supply remains unchanged (some tokens were destroyed). As a result, the user will get zero payout. @@ -105,7 +105,7 @@ Check that end balance >= start balance and end supply >= start supply must be u 5\. [Rewards.sol#L94](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L94) -Even if the vault held enough tokens to send a payout, the payout would not be performed. This issue can affect the last receiver of the reward. +Even if the vault held enough tokens to send a payout, the payout would not be performed. This issue can affect the last receiver of the reward. We recommend changing the condition to `>=`. *Fixed at [7dab770](https://github.com/AutarkLabs/planning-suite/blob/7dab770e5bcf758268e51429e3702eb8305ce242/apps/rewards/contracts/Rewards.sol)* @@ -144,7 +144,7 @@ Duration is not a timestamp or time, but a number of blocks. *Fixed at [7dab770](https://github.com/AutarkLabs/planning-suite/blob/7dab770e5bcf758268e51429e3702eb8305ce242/apps/rewards/contracts/Rewards.sol)* -4\. [Rewards.sol#L125](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L125) , [Rewards.sol#L186](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L186) +4\. [Rewards.sol#L125](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L125) , [Rewards.sol#L186](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L186) Delay is not a timestamp or time, but a number of blocks. @@ -170,7 +170,7 @@ Check that _duration > 0 could be added. 8\. [Rewards.sol#L109](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L109) , -[Rewards.sol#L131](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L131) +[Rewards.sol#L131](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L131) We recommend adding the explicit check `isInitialized`. @@ -238,7 +238,7 @@ Similarly to dividend payouts in stock assets, after reward creation (at the mom 16\. [Rewards.sol#L90](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L90) , -[Rewards.sol#L100](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L100) +[Rewards.sol#L100](https://github.com/AutarkLabs/planning-suite/blob/1508acf91ebfd31472cd3cb527ea3e8fa1330757/apps/rewards/contracts/Rewards.sol#L100) We recommend reverting the transaction as soon as it is known that the reward amount is zero. Otherwise, the blockchain is polluted with the excess state and event. diff --git a/cypress/integration/address-book.spec.js b/cypress/integration/address-book.spec.js index a66dc4df3..7cbb6ede9 100644 --- a/cypress/integration/address-book.spec.js +++ b/cypress/integration/address-book.spec.js @@ -16,7 +16,7 @@ context('Address Book', () => { cy.contains('button','Address Book',{ timeout: 150000 }).wait(1000).click() }) it('creates Address Entry', () =>{ - + cy.getWithinIframe('button:contains("New entity")').trigger('click') .getWithinIframe('input[name="name"]').type('Hello World', { force: true }) .getWithinIframe('input[name="address"]').type('0xb4124ceb3451635dacedd11767f004d8a28c6ee7', { force: true }) diff --git a/cypress/integration/allocations.spec.js b/cypress/integration/allocations.spec.js index a33886aab..3dbb44aa4 100644 --- a/cypress/integration/allocations.spec.js +++ b/cypress/integration/allocations.spec.js @@ -16,11 +16,11 @@ context('Allocations', () => { cy.on("window:load", async (win) => { if (win.web3) { console.log(win.web3) - await win.web3.eth.sendTransaction({ - from: root, + await win.web3.eth.sendTransaction({ + from: root, to: finance, // needs to be updated when aragonCLI or aragen are updated - value: 2.5e17, - gas: 350000 + value: 2.5e17, + gas: 350000 }) } }) @@ -81,7 +81,7 @@ context('Allocations', () => { console.log('+!!!+', el[0]) } }) - + }) } }) diff --git a/cypress/integration/projects.spec.js b/cypress/integration/projects.spec.js index f09c91585..5698bbbfe 100644 --- a/cypress/integration/projects.spec.js +++ b/cypress/integration/projects.spec.js @@ -20,11 +20,11 @@ context('Projects', () => { cy.on("window:load", async (win) => { if (win.web3) { console.log(win.web3) - await win.web3.eth.sendTransaction({ - from: root, + await win.web3.eth.sendTransaction({ + from: root, to: finance, // needs to be updated when aragonCLI or aragen are updated - value: 1.25e17, - gas: 350000 + value: 1.25e17, + gas: 350000 }) } }) diff --git a/cypress/integration/rewards.spec.js b/cypress/integration/rewards.spec.js index ca77676f1..2b5f2d79a 100644 --- a/cypress/integration/rewards.spec.js +++ b/cypress/integration/rewards.spec.js @@ -18,11 +18,11 @@ context('Rewards', () => { cy.on("window:load", async (win) => { if (win.web3) { console.log(win.web3) - await win.web3.eth.sendTransaction({ - from: root, + await win.web3.eth.sendTransaction({ + from: root, to: finance, // needs to be updated when aragonCLI or aragen are updated - value: 2e18, - gas: 350000 + value: 2e18, + gas: 350000 }) let tokenAddress = "0xf2804D07A941F77F34EEEb252D172E4268d0e9D4" diff --git a/docs/DEVELOPMENT_NOTES.md b/docs/DEVELOPMENT_NOTES.md index b20f47fd7..5227b1dc1 100644 --- a/docs/DEVELOPMENT_NOTES.md +++ b/docs/DEVELOPMENT_NOTES.md @@ -89,7 +89,7 @@ require a republish to view changes in the browser. If you get a TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object - + , install Aragon CLI globally with `npm i -g @aragon/cli@5.6.2`. ### Backend diff --git a/docs/GETTING_STARTED.md b/docs/GETTING_STARTED.md index ed36a288a..90e7164f5 100644 --- a/docs/GETTING_STARTED.md +++ b/docs/GETTING_STARTED.md @@ -13,7 +13,7 @@ The basic command to install an app is: #### App with no initialization parameters ``` -dao install +dao install ``` #### App with initialization parameters (two for example) @@ -21,7 +21,7 @@ dao install dao install --app-init-args ``` -Be sure to also pass the `--environment aragon:rinkeby` flag if you are working with a rinkeby organization. +Be sure to also pass the `--environment aragon:rinkeby` flag if you are working with a rinkeby organization. ### Permissions In order to make the apps appear in the UI, you need to initialize at least one permission per app via the cli. Once you setup at least one permission via the cli, you can do the rest in the UI via Permissions. @@ -106,7 +106,7 @@ The Rewards app requires the following initialization parameter: #### Sample install command ``` -dao install rewards.aragonpm.eth --app-init-args [Vault] +dao install rewards.aragonpm.eth --app-init-args [Vault] ``` ## Install the Allocations app diff --git a/shared/deployments/check-publish.sh b/shared/deployments/check-publish.sh index 45b47cf15..54804cc87 100755 --- a/shared/deployments/check-publish.sh +++ b/shared/deployments/check-publish.sh @@ -6,7 +6,7 @@ if [ $? == "1" ] then aragon apm publish major --files dist/ --environment continuous-deployment --apm.ipfs.rpc https://ipfs.autark.xyz:5001 --ipfs-check false --propagate-content false --skip-confirmation --no-prepublish exit $? -else +else echo "no contract changes" fi diff --git a/shared/deployments/rinkeby.md b/shared/deployments/rinkeby.md index 5331c2786..37765de3d 100644 --- a/shared/deployments/rinkeby.md +++ b/shared/deployments/rinkeby.md @@ -12,7 +12,7 @@ ## Allocations ```sh -✔ Successfully published tps-allocations.open.aragonpm.eth v1.0.1: +✔ Successfully published tps-allocations.open.aragonpm.eth v1.0.1: ℹ Contract address: 0x2f9A75f6e81F8cF3711b482CD56aAC029B6843d1 ℹ Content (ipfs): QmVW23vYVyjTw7b1nG8YrwYVxkMXUPaJDo2VgorNFEipNQ ℹ Transaction hash: 0x12d6f818b44bf68328d719ae48a8505061685fefa159b36c36a68d60c78abb3d @@ -23,7 +23,7 @@ ### v1.0.3 (current) ```sh -✔ Successfully published tps-projects.open.aragonpm.eth v1.0.3: +✔ Successfully published tps-projects.open.aragonpm.eth v1.0.3: ℹ Contract address: 0x341706591aDE66ea57D02c471e8aAa0C484DE861 ℹ Content (ipfs): QmPxzWikJ4etLLrVZseuesNSwLFgmZFg49hxNNRYuEKtG7 ℹ Transaction hash: 0x50cc90dd6480c8f33480f96fadf8e8025c50323b38b2240eb237c223d02efaa5 @@ -38,7 +38,7 @@ Command: ### v1.0.2 ```sh -✔ Successfully published tps-projects.open.aragonpm.eth v1.0.2: +✔ Successfully published tps-projects.open.aragonpm.eth v1.0.2: ℹ Contract address: 0x341706591aDE66ea57D02c471e8aAa0C484DE861 ℹ Content (ipfs): QmQnAfrMYrWNoQR8HFRKFQZZHMuMz5edPYWDMzQnP9i88Y ℹ Transaction hash: 0x0756df9c7b8d3f09b4ca6c16ac03d33351c4e214cff1f4100430bd41d203e332 @@ -53,7 +53,7 @@ Command: ### 1.0.5 ```sh -✔ Successfully published tps-dot-voting.open.aragonpm.eth v1.0.5: +✔ Successfully published tps-dot-voting.open.aragonpm.eth v1.0.5: ℹ Contract address: 0xd191581d372a07d83E8e06Da5a0678b845E638A1 ℹ Content (ipfs): QmYxZ4rixjAspoDYYQFz4ajTiKKBoNwxRr9HuBGBmEMq4W ℹ Transaction hash: 0x0ee849e2250821b335eb56d293fa0e42f1d427092b5b16f659c45f167b91cd72 @@ -62,14 +62,14 @@ Command: ### 1.0.2 ```sh -✔️ Successfully published tps-dot-voting.open.aragonpm.eth v1.0.2: +✔️ Successfully published tps-dot-voting.open.aragonpm.eth v1.0.2: ℹ️ Contract address: 0xd191581d372a07d83E8e06Da5a0678b845E638A1 ℹ️ Content (ipfs): QmVKwco5AHw5nPz2iWn43PE8hx1mccmkyzhmveXYoDbbLR ℹ️ Transaction hash: 0xfa1c10ff2345a79b195a42705c55f738e656df5bff8268105fef12ae870bd063 ``` ```sh -✔ Successfully published tps-dot-voting.open.aragonpm.eth v1.0.1: +✔ Successfully published tps-dot-voting.open.aragonpm.eth v1.0.1: ℹ Contract address: 0xd191581d372a07d83E8e06Da5a0678b845E638A1 ℹ Content (ipfs): QmUcyfhx2tHs2tepyWAZ9jjSKUSwxVKYHm7GAnYNA7StFw ℹ Transaction hash: 0x05d61cea5324f9e0424876fbcab4c7778b30d85e9abff6fc8f88cf49de7aecc0 @@ -77,7 +77,7 @@ Command: ## Rewards ```sh -✔ Successfully published tps-rewards.open.aragonpm.eth v1.0.1: +✔ Successfully published tps-rewards.open.aragonpm.eth v1.0.1: ℹ Contract address: 0xD22010C362Ac01b6371c0ca3Eebf98e8b586c5B8 ℹ Content (ipfs): QmSovs2sw821JmmT52Se37dbQarbDW6Df8JoyhXwqBbNdY ℹ Transaction hash: 0x20e7e88081c41f4b07c7ddd0e29a9071747bb9bdd422f56c7a865d939f44ae04 diff --git a/shared/deployments/staging.md b/shared/deployments/staging.md index 25181828a..9b152c3d3 100644 --- a/shared/deployments/staging.md +++ b/shared/deployments/staging.md @@ -68,7 +68,7 @@ ### 8.0.2 ```sh -✔ Successfully published projects-staging.open.aragonpm.eth v8.0.2: +✔ Successfully published projects-staging.open.aragonpm.eth v8.0.2: ℹ Contract address: 0xD4e2b5Dbb7264c1DaE2A20a28b4E3E99D7ea78bf ℹ Content (ipfs): QmWwL1ViZvCJViMMdDxHHMfJ3RLkCCAHQQsxcPAoAUiykk ℹ TTransaction hash: 0xc93b6c07eb27c229cecc50bde3da9d06102164416a433739eba961913f32f8e6 @@ -112,7 +112,7 @@ ### 5.0.4 ```sh -✔ Successfully published dot-voting-staging.open.aragonpm.eth v5.0.4: +✔ Successfully published dot-voting-staging.open.aragonpm.eth v5.0.4: ℹ Contract address: 0x67f9E279f1eC6C126fA2Db3A51204583cE3A72AB ℹ Content (ipfs): QmVKwco5AHw5nPz2iWn43PE8hx1mccmkyzhmveXYoDbbLR ℹ Transaction hash: 0x2502298f3576e88dd28d6f6995e45cd2b56c2d916ffe970f499e69255b2eb09f @@ -164,7 +164,7 @@ ```sh -✔ Successfully published rewards-staging.open.aragonpm.eth v3.0.2: +✔ Successfully published rewards-staging.open.aragonpm.eth v3.0.2: ℹ Contract address: 0xB5ab72EBF552fC4B32c80616410b2b28D33b715b ℹ Content (ipfs): QmQzaRbM7Dwk2Ab7UqZwTH1jvgJy5MLchN5sdgEXc3igq6 ℹ Transaction hash: 0x3ef749fd7e2442e6b79704ed1e964a620bf6c5f89e3e6c9285b8bc9735a94e7a diff --git a/shared/integrations/StandardBounties/docs/documentation_v1.md b/shared/integrations/StandardBounties/docs/documentation_v1.md index 82d415144..9de54492e 100644 --- a/shared/integrations/StandardBounties/docs/documentation_v1.md +++ b/shared/integrations/StandardBounties/docs/documentation_v1.md @@ -9,7 +9,7 @@ A bounty is a simple mechanism for individuals or groups to pay out for the comp ## Contract Details -Any application can take advantage of the Bounties Network registry, which is currently deployed on the Main Ethereum Network at `0x2af47a65da8cd66729b4209c22017d6a5c2d2400`, and on the Rinkeby network at `0xf209d2b723b6417cbf04c07e733bee776105a073`. +Any application can take advantage of the Bounties Network registry, which is currently deployed on the Main Ethereum Network at `0x2af47a65da8cd66729b4209c22017d6a5c2d2400`, and on the Rinkeby network at `0xf209d2b723b6417cbf04c07e733bee776105a073`. ### Storage diff --git a/shared/integrations/StandardBounties/graph.txt b/shared/integrations/StandardBounties/graph.txt index ec2c4e892..8b6134256 100644 --- a/shared/integrations/StandardBounties/graph.txt +++ b/shared/integrations/StandardBounties/graph.txt @@ -196,7 +196,7 @@ subgraph "cluster_to" { rankdir=LR node [shape=plaintext] -subgraph cluster_01 { +subgraph cluster_01 { label = "Legend"; key [label=< diff --git a/shared/store-utils/token.js b/shared/store-utils/token.js index 5bb82a867..42772eb0c 100644 --- a/shared/store-utils/token.js +++ b/shared/store-utils/token.js @@ -28,7 +28,7 @@ export const initEthToken = () => { } export const initializeTokens = async (cachedState = {}, settings) => { - + initEthToken() const newState = { ...cachedState, @@ -49,7 +49,7 @@ const loadTokenBalances = async (state, includedTokenAddresses, settings) => { let newState = { ...state, } - + if ( !Array.isArray(newState.balances) && !Array.isArray(includedTokenAddresses) diff --git a/templates/dev/scripts/new-dao.js b/templates/dev/scripts/new-dao.js index 8345dabd3..d8d7f2689 100644 --- a/templates/dev/scripts/new-dao.js +++ b/templates/dev/scripts/new-dao.js @@ -16,7 +16,7 @@ module.exports = async function newDao({ votingSettings, } = settings - + const { getEventArgument } = require('@aragon/test-helpers/events') const { getTemplateAddress } = require('../../open-enterprise/temp/lib/ens')(web3, artifacts) @@ -38,7 +38,7 @@ module.exports = async function newDao({ 0, { from: members[0] } ) - + const dao = Kernel.at(getEventArgument(baseDAO, 'DeployDao', 'dao')) const baseOpenEnterprise = await template.newOpenEnterprise( dotVotingSettings, diff --git a/templates/dev/temp/helpers/apps.js b/templates/dev/temp/helpers/apps.js index 9139b8787..d06072d7a 100644 --- a/templates/dev/temp/helpers/apps.js +++ b/templates/dev/temp/helpers/apps.js @@ -12,7 +12,7 @@ const ARAGON_APPS = [ // { name: 'token-manager.hatch', contractName: 'TokenManager' }, // { name: 'whitelist-oracle.hatch', contractName: 'WhitelistOracle' }, ] - + const ARAGON_APP_IDS = ARAGON_APPS.reduce((ids, { name }) => { ids[name] = namehash(`${name}.aragonpm.eth`) return ids diff --git a/templates/open-enterprise/public/Template.audit.md b/templates/open-enterprise/public/Template.audit.md index 92260120a..98ddef815 100644 --- a/templates/open-enterprise/public/Template.audit.md +++ b/templates/open-enterprise/public/Template.audit.md @@ -57,9 +57,9 @@ Stages of the audit were as follows: ## Detected Issues ### CRITICAL - + Not found - + ### MAJOR 1\. [OpenEnterpriseTemplate.sol#L177](https://github.com/AutarkLabs/open-enterprise/blob/1502373a0071253f5b90c9e703395754d2f947cc/templates/open-enterprise/contracts/OpenEnterpriseTemplate.sol#L177) diff --git a/templates/open-enterprise/temp/helpers/apps.js b/templates/open-enterprise/temp/helpers/apps.js index d5ce64248..4dbcae0f8 100644 --- a/templates/open-enterprise/temp/helpers/apps.js +++ b/templates/open-enterprise/temp/helpers/apps.js @@ -12,7 +12,7 @@ const ARAGON_APPS = [ { name: 'token-manager.hatch', contractName: 'TokenManager' }, { name: 'whitelist-oracle.hatch', contractName: 'WhitelistOracle' }, ] - + const ARAGON_APP_IDS = ARAGON_APPS.reduce((ids, { name }) => { ids[name] = namehash(`${name}.aragonpm.eth`) return ids diff --git a/templates/open-enterprise/temp/lib/OEDeployer.js b/templates/open-enterprise/temp/lib/OEDeployer.js index b641cf6ab..fb2ad3709 100644 --- a/templates/open-enterprise/temp/lib/OEDeployer.js +++ b/templates/open-enterprise/temp/lib/OEDeployer.js @@ -6,7 +6,7 @@ module.exports = class OEDeployer extends TemplateDeployer { constructor(web3, artifacts, owner, options = { verbose: false }) { super(web3, artifacts, owner, options) } - + async deploy(templateName, contractName) { // console.log('deployed!', this.options) await this._fetchOrDeployStandardBounties() diff --git a/templates/open-enterprise/temp/scripts/new-dao.js b/templates/open-enterprise/temp/scripts/new-dao.js index d671d4069..90d5cefd1 100644 --- a/templates/open-enterprise/temp/scripts/new-dao.js +++ b/templates/open-enterprise/temp/scripts/new-dao.js @@ -23,10 +23,10 @@ module.exports = async function newDao({ const { getTemplateAddress } = require('../lib/ens')(web3, artifacts) const OpenEnterpriseTemplate = artifacts.require('OpenEnterpriseTemplate') const Kernel = artifacts.require('Kernel') - + try { const template = OpenEnterpriseTemplate.at(await getTemplateAddress()) - + const baseDAO = await template.newTokensAndInstance( id, token1.name, @@ -38,9 +38,9 @@ module.exports = async function newDao({ useAgentAsVault, { from: members[0] } ) - + const dao = Kernel.at(getEventArgument(baseDAO, 'DeployDao', 'dao')) - + const baseDaoWithTokenMgrs = await template.newTokenManagers( members, diff --git a/templates/open-enterprise/temp/scripts/test-ganache.sh b/templates/open-enterprise/temp/scripts/test-ganache.sh index 1728a6673..414a41b99 100755 --- a/templates/open-enterprise/temp/scripts/test-ganache.sh +++ b/templates/open-enterprise/temp/scripts/test-ganache.sh @@ -17,7 +17,7 @@ cleanup() { } setup_coverage_variables() { - ACCOUNTS=${ACCOUNTS-200} + ACCOUNTS=${ACCOUNTS-200} BALANCE=${BALANCE-100000} COMMAND=${COMMAND-testrpc-sc} ENVIRONMENT=${ENVIRONMENT-coverage}
Internal Call