diff --git a/contracts/schemes/SchemeConstraints.sol b/contracts/schemes/SchemeConstraints.sol index 60d5091f..3230e9c5 100644 --- a/contracts/schemes/SchemeConstraints.sol +++ b/contracts/schemes/SchemeConstraints.sol @@ -6,6 +6,9 @@ import "../controller/Avatar.sol"; contract SchemeConstraints { address[] public contractsWhiteList; + //descriptionHash can be used to add detalis description of the constraints. + //e.g it can be ipfs hash of the contractsWhiteList abis +names. + string public descriptionHash; /* * @dev isAllowedToCall should be called upon a proposal execution. diff --git a/contracts/schemes/SimpleSchemeConstraints.sol b/contracts/schemes/SimpleSchemeConstraints.sol new file mode 100644 index 00000000..051d8ff8 --- /dev/null +++ b/contracts/schemes/SimpleSchemeConstraints.sol @@ -0,0 +1,69 @@ +pragma solidity 0.5.17; +pragma experimental ABIEncoderV2; + +import "./SchemeConstraints.sol"; + +//a simple genericSchemeMultiCall constraint which put constraints only on white listed contracts to call. + +contract SimpleSchemeConstraints is SchemeConstraints { + + mapping(address=>bool) public contractsWhiteListMap; + bool public initialized; + + /* @dev initialize + * @param _contractsWhiteList the contracts the scheme is allowed to interact with + * @param _descriptionHash can be used to add detalis description of the constraints. + */ + function initialize( + address[] calldata _contractsWhiteList, + string calldata _descriptionHash + ) + external { + require(!initialized, "cannot initialize twice"); + initialized = true; + for (uint i = 0; i < _contractsWhiteList.length; i++) { + contractsWhiteListMap[_contractsWhiteList[i]] = true; + } + contractsWhiteList = _contractsWhiteList; + descriptionHash = _descriptionHash; + } + + /* + * @dev isAllowedToCall should be called upon a proposal execution. + * @param _contractsToCall the contracts to be called + * @return bool value true-allowed false not allowed + */ + function isAllowedToCall( + address[] calldata _contractsToCall, + bytes[] calldata, + uint256[] calldata, + Avatar + ) + external + returns(bool) + { + for (uint i = 0; i < _contractsToCall.length; i++) { + require(contractsWhiteListMap[_contractsToCall[i]], "contract not whitelisted"); + } + return true; + } + + /* + * @dev isAllowedToPropose should be called upon a proposal submition. + * @param _contractsToCall the contracts to be called + * @return bool value true-allowed false not allowed + */ + function isAllowedToPropose( + address[] calldata _contractsToCall, + bytes[] calldata, + uint256[] calldata, + Avatar) + external + returns(bool) + { + for (uint i = 0; i < _contractsToCall.length; i++) { + require(contractsWhiteListMap[_contractsToCall[i]], "contract not whitelisted"); + } + return true; + } +} diff --git a/package-lock.json b/package-lock.json index fbb23438..dfe2b937 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.47", + "version": "0.0.1-rc.48", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -32,12 +32,12 @@ } }, "@babel/generator": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.12.1.tgz", - "integrity": "sha512-DB+6rafIdc9o72Yc3/Ph5h+6hUjeOp66pF0naQBgUFFuPqzQwIlPTm3xZR7YNvduIMtkDIj2t21LSQwnbCrXvg==", + "version": "7.12.5", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.12.5.tgz", + "integrity": "sha512-m16TQQJ8hPt7E+OS/XVQg/7U184MLXtvuGbCdA7na61vha+ImkyyNM/9DDA0unYCVZn3ZOhng+qz48/KBOT96A==", "dev": true, "requires": { - "@babel/types": "^7.12.1", + "@babel/types": "^7.12.5", "jsesc": "^2.5.1", "source-map": "^0.5.0" } @@ -89,9 +89,9 @@ } }, "@babel/parser": { - "version": "7.12.3", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.12.3.tgz", - "integrity": "sha512-kFsOS0IbsuhO5ojF8Hc8z/8vEIOkylVBrjiZUbLTE3XFe0Qi+uu6HjzQixkFaqr0ZPAMZcBVxEwmsnsLPZ2Xsw==", + "version": "7.12.5", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.12.5.tgz", + "integrity": "sha512-FVM6RZQ0mn2KCf1VUED7KepYeUWoVShczewOCfm3nzoBybaih51h+sYVVGthW9M6lPByEPTQf+xm27PBdlpwmQ==", "dev": true }, "@babel/template": { @@ -106,17 +106,17 @@ } }, "@babel/traverse": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.12.1.tgz", - "integrity": "sha512-MA3WPoRt1ZHo2ZmoGKNqi20YnPt0B1S0GTZEPhhd+hw2KGUzBlHuVunj6K4sNuK+reEvyiPwtp0cpaqLzJDmAw==", + "version": "7.12.5", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.12.5.tgz", + "integrity": "sha512-xa15FbQnias7z9a62LwYAA5SZZPkHIXpd42C6uW68o8uTuua96FHZy1y61Va5P/i83FAAcMpW8+A/QayntzuqA==", "dev": true, "requires": { "@babel/code-frame": "^7.10.4", - "@babel/generator": "^7.12.1", + "@babel/generator": "^7.12.5", "@babel/helper-function-name": "^7.10.4", "@babel/helper-split-export-declaration": "^7.11.0", - "@babel/parser": "^7.12.1", - "@babel/types": "^7.12.1", + "@babel/parser": "^7.12.5", + "@babel/types": "^7.12.5", "debug": "^4.1.0", "globals": "^11.1.0", "lodash": "^4.17.19" @@ -134,9 +134,9 @@ } }, "@babel/types": { - "version": "7.12.1", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.1.tgz", - "integrity": "sha512-BzSY3NJBKM4kyatSOWh3D/JJ2O3CVzBybHWxtgxnggaxEuaSTTDqeiSb/xk9lrkw2Tbqyivw5ZU4rT+EfznQsA==", + "version": "7.12.6", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.12.6.tgz", + "integrity": "sha512-hwyjw6GvjBLiyy3W0YQf0Z5Zf4NpYejUnKFcfcUhZCSffoBBp30w6wP2Wn6pk31jMYZvcOrB/1b7cGXvEoKogA==", "dev": true, "requires": { "@babel/helper-validator-identifier": "^7.10.4", @@ -170,6 +170,34 @@ "@ethersproject/strings": ">=5.0.0-beta.130" } }, + "@ethersproject/abstract-provider": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-provider/-/abstract-provider-5.0.5.tgz", + "integrity": "sha512-i/CjElAkzV7vQBAeoz+IpjGfcFYEP9eD7j3fzZ0fzTq03DO7PPnR+xkEZ1IoDXGwDS+55aLM1xvLDwB/Lx6IOQ==", + "dev": true, + "requires": { + "@ethersproject/bignumber": "^5.0.7", + "@ethersproject/bytes": "^5.0.4", + "@ethersproject/logger": "^5.0.5", + "@ethersproject/networks": "^5.0.3", + "@ethersproject/properties": "^5.0.3", + "@ethersproject/transactions": "^5.0.5", + "@ethersproject/web": "^5.0.6" + } + }, + "@ethersproject/abstract-signer": { + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/@ethersproject/abstract-signer/-/abstract-signer-5.0.7.tgz", + "integrity": "sha512-8W8gy/QutEL60EoMEpvxZ8MFAEWs/JvH5nmZ6xeLXoZvmBCasGmxqHdYjo2cxg0nevkPkq9SeenSsBBZSCx+SQ==", + "dev": true, + "requires": { + "@ethersproject/abstract-provider": "^5.0.4", + "@ethersproject/bignumber": "^5.0.7", + "@ethersproject/bytes": "^5.0.4", + "@ethersproject/logger": "^5.0.5", + "@ethersproject/properties": "^5.0.3" + } + }, "@ethersproject/address": { "version": "5.0.5", "resolved": "https://registry.npmjs.org/@ethersproject/address/-/address-5.0.5.tgz", @@ -184,6 +212,15 @@ "bn.js": "^4.4.0" } }, + "@ethersproject/base64": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@ethersproject/base64/-/base64-5.0.4.tgz", + "integrity": "sha512-4KRykQ7BQMeOXfvio1YITwHjxwBzh92UoXIdzxDE1p53CK28bbHPdsPNYo0wl0El7lJAMpT2SOdL0hhbWRnyIA==", + "dev": true, + "requires": { + "@ethersproject/bytes": "^5.0.4" + } + }, "@ethersproject/bignumber": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/@ethersproject/bignumber/-/bignumber-5.0.8.tgz", @@ -214,14 +251,18 @@ } }, "@ethersproject/hash": { - "version": "5.0.5", - "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.0.5.tgz", - "integrity": "sha512-GpI80/h2HDpfNKpCZoxQJCjOQloGnlD5hM1G+tZe8FQDJhEvFjJoPDuWv+NaYjJfOciKS2Axqc4Q4WamdLoUgg==", + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@ethersproject/hash/-/hash-5.0.6.tgz", + "integrity": "sha512-Gvh57v6BWhwnud6l7tMfQm32PRQ2DYx2WaAAQmAxAfYvmzUkpQCBstnGeNMXIL8/2wdkvcB2u+WZRWaZtsFuUQ==", "dev": true, "requires": { + "@ethersproject/abstract-signer": "^5.0.6", + "@ethersproject/address": "^5.0.5", + "@ethersproject/bignumber": "^5.0.8", "@ethersproject/bytes": "^5.0.4", "@ethersproject/keccak256": "^5.0.3", "@ethersproject/logger": "^5.0.5", + "@ethersproject/properties": "^5.0.4", "@ethersproject/strings": "^5.0.4" } }, @@ -241,6 +282,15 @@ "integrity": "sha512-FrX0Vnb3JZ1md/7GIZfmJ06XOAA8r3q9Uqt9O5orr4ZiksnbpXKlyDzQtlZ5Yv18RS8CAUbiKH9vwidJg1BPmQ==", "dev": true }, + "@ethersproject/networks": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@ethersproject/networks/-/networks-5.0.4.tgz", + "integrity": "sha512-/wHDTRms5mpJ09BoDrbNdFWINzONe05wZRgohCXvEv39rrH/Gd/yAnct8wC0RsW3tmFOgjgQxuBvypIxuUynTw==", + "dev": true, + "requires": { + "@ethersproject/logger": "^5.0.5" + } + }, "@ethersproject/properties": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/@ethersproject/properties/-/properties-5.0.4.tgz", @@ -300,6 +350,19 @@ "@ethersproject/signing-key": "^5.0.4" } }, + "@ethersproject/web": { + "version": "5.0.9", + "resolved": "https://registry.npmjs.org/@ethersproject/web/-/web-5.0.9.tgz", + "integrity": "sha512-//QNlv1MSkOII1hv3+HQwWoiVFS+BMVGI0KYeUww4cyrEktnx1QIez5bTSab9s9fWTFaWKNmQNBwMbxAqPuYDw==", + "dev": true, + "requires": { + "@ethersproject/base64": "^5.0.3", + "@ethersproject/bytes": "^5.0.4", + "@ethersproject/logger": "^5.0.5", + "@ethersproject/properties": "^5.0.3", + "@ethersproject/strings": "^5.0.4" + } + }, "@nicolo-ribaudo/chokidar-2": { "version": "2.1.8", "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8.tgz", @@ -404,9 +467,9 @@ "dev": true }, "@solidity-parser/parser": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.8.1.tgz", - "integrity": "sha512-DF7H6T8I4lo2IZOE2NZwt3631T8j1gjpQLjmvY2xBNK50c4ltslR4XPKwT6RkeSd4+xCAK0GHC/k7sbRDBE4Yw==" + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/@solidity-parser/parser/-/parser-0.8.2.tgz", + "integrity": "sha512-8LySx3qrNXPgB5JiULfG10O3V7QTxI/TLzSw5hFQhXWSkVxZBAv4rZQ0sYgLEbc8g3L2lmnujj1hKul38Eu5NQ==" }, "@szmarczak/http-timer": { "version": "1.1.2", @@ -436,9 +499,9 @@ }, "dependencies": { "@types/node": { - "version": "12.12.68", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.68.tgz", - "integrity": "sha512-3RW2s24ewB7F9dAHvgb9FRvNHn6nO9IK6Eaknbz7HTOe2a5GVne5XbUh5+YA+kcCn67glyHhClUUdFP73LWrgQ==", + "version": "12.19.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.4.tgz", + "integrity": "sha512-o3oj1bETk8kBwzz1WlO6JWL/AfAA3Vm6J1B3C9CsdxHYp7XgPiH7OEXPUbZTndHlRaIElrANkQfe6ZmfJb3H2w==", "dev": true }, "web3": { @@ -471,9 +534,9 @@ }, "dependencies": { "@types/node": { - "version": "10.17.40", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.40.tgz", - "integrity": "sha512-3hZT2z2/531A5pc8hYhn1gU5Qb1SIRSgMLQ6zuHA5xtt16lWAxUGprtr8lJuc9zNJMXEIIBWfSnzqBP/4mglpA==", + "version": "10.17.44", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.44.tgz", + "integrity": "sha512-vHPAyBX1ffLcy4fQHmDyIUMUb42gHZjPHU66nhvbMzAWJqHnySGZ6STwN3rwrnSd1FHB0DI/RWgGELgKSYRDmw==", "dev": true }, "bn.js": { @@ -887,9 +950,9 @@ "dev": true }, "@types/node": { - "version": "14.11.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-14.11.10.tgz", - "integrity": "sha512-yV1nWZPlMFpoXyoknm4S56y2nlTAuFYaJuQtYRAOU7xA/FJ9RY0Xm7QOkaYMMmr8ESdHIuUb6oQgR/0+2NqlyA==" + "version": "14.14.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.14.7.tgz", + "integrity": "sha512-Zw1vhUSQZYw+7u5dAwNbIA9TuTotpzY/OF7sJM9FqPOF3SPjKnxrjoTktXDZgUjybf4cWVBP7O8wvKdSaGHweg==" }, "@types/pbkdf2": { "version": "3.1.0", @@ -1247,9 +1310,9 @@ "integrity": "sha1-tG6JCTSpWR8tL2+G1+ap8bP+dqg=" }, "aws4": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.1.tgz", - "integrity": "sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA==" + "version": "1.11.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.11.0.tgz", + "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==" }, "babel-code-frame": { "version": "6.26.0", @@ -2288,13 +2351,13 @@ } }, "buffer": { - "version": "5.6.0", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz", - "integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==", + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", + "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", "dev": true, "requires": { - "base64-js": "^1.0.2", - "ieee754": "^1.1.4" + "base64-js": "^1.3.1", + "ieee754": "^1.1.13" } }, "buffer-alloc": { @@ -2343,20 +2406,12 @@ "integrity": "sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk=" }, "bufferutil": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.1.tgz", - "integrity": "sha512-xowrxvpxojqkagPcWRQVXZl0YXhRhAtBEIq3VoER1NH5Mw1n1o0ojdspp+GS2J//2gCVyrzQDApQ4unGF+QOoA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.2.tgz", + "integrity": "sha512-AtnG3W6M8B2n4xDQ5R+70EXvOpnXsFYg/AK2yTZd+HQ/oxAdz+GI+DvjmhBw3L0ole+LJ0ngqY4JMbDzkfNzhA==", "dev": true, "requires": { - "node-gyp-build": "~3.7.0" - }, - "dependencies": { - "node-gyp-build": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz", - "integrity": "sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w==", - "dev": true - } + "node-gyp-build": "^4.2.0" } }, "bytes": { @@ -2414,6 +2469,16 @@ } } }, + "call-bind": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.0.tgz", + "integrity": "sha512-AEXsYIyyDY3MCzbwdhzG3Jx1R0J2wetQyUynn6dYHAO+bg8l1k7jwZtRv4ryryFs7EP+NDlikJlVe59jr0cM2w==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.0" + } + }, "caller-callsite": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/caller-callsite/-/caller-callsite-2.0.0.tgz", @@ -3915,9 +3980,9 @@ "dev": true }, "eslint-plugin-react": { - "version": "7.21.4", - "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.21.4.tgz", - "integrity": "sha512-uHeQ8A0hg0ltNDXFu3qSfFqTNPXm1XithH6/SY318UX76CMj7Q599qWpgmMhVQyvhq36pm7qvoN3pb6/3jsTFg==", + "version": "7.21.5", + "resolved": "https://registry.npmjs.org/eslint-plugin-react/-/eslint-plugin-react-7.21.5.tgz", + "integrity": "sha512-8MaEggC2et0wSF6bUeywF7qQ46ER81irOdWS4QWxnnlAEsnzeBevk1sWh7fhpCghPpXb+8Ks7hvaft6L/xsR6g==", "dev": true, "requires": { "array-includes": "^3.1.1", @@ -3929,7 +3994,7 @@ "object.fromentries": "^2.0.2", "object.values": "^1.1.1", "prop-types": "^15.7.2", - "resolve": "^1.17.0", + "resolve": "^1.18.1", "string.prototype.matchall": "^4.0.2" }, "dependencies": { @@ -4573,9 +4638,9 @@ "dev": true }, "fastq": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.8.0.tgz", - "integrity": "sha512-SMIZoZdLh/fgofivvIkmknUXyPnvxRE3DhtZ5Me3Mrsk5gyPL42F0xr51TdRXskBxHfMp+07bcYzfsYEsSQA9Q==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.9.0.tgz", + "integrity": "sha512-i7FVWL8HhVY+CTkwFxkN2mk3h+787ixS5S63eb78diVRc1MCssarHq3W5cj0av7YDSwmaV928RNag+U1etRQ7w==", "dev": true, "requires": { "reusify": "^1.0.4" @@ -4822,9 +4887,9 @@ "dev": true }, "ganache-cli": { - "version": "6.12.0", - "resolved": "https://registry.npmjs.org/ganache-cli/-/ganache-cli-6.12.0.tgz", - "integrity": "sha512-WV354mOSCbVH+qR609ftpz/1zsZPRsHMaQ4jo9ioBQAkguYNVU5arfgIE0+0daU0Vl9WJ/OMhRyl0XRswd/j9A==", + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/ganache-cli/-/ganache-cli-6.12.1.tgz", + "integrity": "sha512-zoefZLQpQyEJH9jgtVYgM+ENFLAC9iwys07IDCsju2Ieq9KSTLH89RxSP4bhizXKV/h/+qaWpfyCBGWnBfqgIQ==", "dev": true, "requires": { "ethereumjs-util": "6.2.1", @@ -5596,6 +5661,17 @@ } } }, + "get-intrinsic": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.0.1.tgz", + "integrity": "sha512-ZnWP+AmS1VUaLgTRy47+zKtjTxz+0xMpx3I52i+aalBK1QP19ggLF3Db89KJX7kjfOfP2eoa01qc++GwPgufPg==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + } + }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -5798,9 +5874,9 @@ "dev": true }, "uglify-js": { - "version": "3.11.2", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.11.2.tgz", - "integrity": "sha512-G440NU6fewtnQftSgqRV1r2A5ChKbU1gqFCJ7I8S7MPpY/eZZfLGefaY6gUZYiWebMaO+txgiQ1ZyLDuNWJulg==", + "version": "3.11.5", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.11.5.tgz", + "integrity": "sha512-btvv/baMqe7HxP7zJSF7Uc16h1mSfuuSplT0/qdjxseesDU+yYzH33eHBH+eMdeRXwujXspaCTooWHQVVBh09w==", "dev": true, "optional": true }, @@ -6023,9 +6099,9 @@ } }, "ieee754": { - "version": "1.1.13", - "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", - "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", "dev": true }, "ignore": { @@ -6035,9 +6111,9 @@ "dev": true }, "import-fresh": { - "version": "3.2.1", - "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.1.tgz", - "integrity": "sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.2.2.tgz", + "integrity": "sha512-cTPNrlvJT6twpYy+YmKUKrTSjWFs3bjYjAhCwm+z4EOCubZxAuO+hHpRN64TqjEaYSHs7tJAE0w1CKMGmsG/lw==", "dev": true, "requires": { "parent-module": "^1.0.0", @@ -6194,6 +6270,15 @@ "integrity": "sha512-dnMqspv5nU3LoewK2N/y7KLtxtakvTuaCsU9FU50/QDmdbHNy/4/JuRtMHqRU22o3q+W89YQndQEeCVwK+3qrA==", "dev": true }, + "is-core-module": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.1.0.tgz", + "integrity": "sha512-YcV7BgVMRFRua2FqQzKtTDMz8iCuLEyGKjr70q8Zm1yy2qKcurbFEd79PAdHV77oL3NrAaOVQIbMmiHQCHB7ZA==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -6534,9 +6619,9 @@ } }, "jsonschema": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.3.0.tgz", - "integrity": "sha512-qg48ckmeeQNPyPAUVIb4Qgmg/U2Kgg5SuEyMs8Z72cnxsw5Ra088U/Foi6sMp/cs7sZ+LNrmvX0Ww+ohE2By0g==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/jsonschema/-/jsonschema-1.4.0.tgz", + "integrity": "sha512-/YgW6pRMr6M7C+4o8kS+B/2myEpHCrxO4PEWnqJNBFMjn7EWXqlQ4tGwL6xTHeRplwuZmcAncdvfOad1nT2yMw==", "dev": true }, "jsprim": { @@ -7300,37 +7385,15 @@ } }, "object.assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.1.tgz", - "integrity": "sha512-VT/cxmx5yaoHSOTSyrCygIDFco+RsibY2NM0a4RdEeY/4KgqezwFtK1yr3U67xYhqJSlASm2pKhLVzPj2lr4bA==", + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", "dev": true, "requires": { + "call-bind": "^1.0.0", "define-properties": "^1.1.3", - "es-abstract": "^1.18.0-next.0", "has-symbols": "^1.0.1", "object-keys": "^1.1.1" - }, - "dependencies": { - "es-abstract": { - "version": "1.18.0-next.1", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz", - "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.2", - "is-negative-zero": "^2.0.0", - "is-regex": "^1.1.1", - "object-inspect": "^1.8.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.1", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - } } }, "object.entries": { @@ -8267,9 +8330,9 @@ } }, "regenerate": { - "version": "1.4.1", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.1.tgz", - "integrity": "sha512-j2+C8+NtXQgEKWk49MMP5P/u2GhnahTtVkRIHr5R5lVRlbKvmQ+oS+A5aLKWp2ma5VkT8sh6v+v4hbH0YHR66A==", + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", + "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", "dev": true }, "regenerator-runtime": { @@ -8404,11 +8467,12 @@ } }, "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "version": "1.18.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.18.1.tgz", + "integrity": "sha512-lDfCPaMKfOJXjy0dPayzPdF1phampNWr3qFCjAu+rw/qbQmr5jWH5xN2hwh9QKfw9E5v4hwV7A+jrCmL8yjjqA==", "dev": true, "requires": { + "is-core-module": "^2.0.0", "path-parse": "^1.0.6" } }, @@ -8497,9 +8561,9 @@ "dev": true }, "run-parallel": { - "version": "1.1.9", - "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", - "integrity": "sha512-DEqnSRTDw/Tc3FXf49zedI638Z9onwUotBMiUFKmrO2sdFKIbXamXGQ3Axd4qgphxKB4kw/qP1w5kTxnfU1B9Q==", + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.10.tgz", + "integrity": "sha512-zb/1OuZ6flOlH6tQyMPUrE3x3Ulxjlo9WIVXR4yVYi4H9UXQaeIsPbLn2R3O3vQCnDKkAl2qHiuocKKX4Tz/Sw==", "dev": true }, "run-with-ganache": { @@ -9293,23 +9357,67 @@ } }, "string.prototype.trimend": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", - "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.2.tgz", + "integrity": "sha512-8oAG/hi14Z4nOVP0z6mdiVZ/wqjDtWSLygMigTzAb+7aPEDTleeFf+WrF+alzecxIRkckkJVn+dTlwzJXORATw==", "dev": true, "requires": { "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" + "es-abstract": "^1.18.0-next.1" + }, + "dependencies": { + "es-abstract": { + "version": "1.18.0-next.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz", + "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.2", + "is-negative-zero": "^2.0.0", + "is-regex": "^1.1.1", + "object-inspect": "^1.8.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.1", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + } } }, "string.prototype.trimstart": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", - "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.2.tgz", + "integrity": "sha512-7F6CdBTl5zyu30BJFdzSTlSlLPwODC23Od+iLoVH8X6+3fvDPPuBVVj9iaB1GOsSTSIgVfsfm27R2FGrAPznWg==", "dev": true, "requires": { "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" + "es-abstract": "^1.18.0-next.1" + }, + "dependencies": { + "es-abstract": { + "version": "1.18.0-next.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.18.0-next.1.tgz", + "integrity": "sha512-I4UGspA0wpZXWENrdA0uHbnhte683t3qT/1VFH9aX2dA5PPSf6QW5HHXf5HImaqPmjXaVeVk4RGWnaylmV7uAA==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.2", + "is-negative-zero": "^2.0.0", + "is-regex": "^1.1.1", + "object-inspect": "^1.8.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.1", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + } } }, "string_decoder": { @@ -9944,20 +10052,12 @@ "dev": true }, "utf-8-validate": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.2.tgz", - "integrity": "sha512-SwV++i2gTD5qh2XqaPzBnNX88N6HdyhQrNNRykvcS0QKvItV9u3vPEJr+X5Hhfb1JC0r0e1alL0iB09rY8+nmw==", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.3.tgz", + "integrity": "sha512-jtJM6fpGv8C1SoH4PtG22pGto6x+Y8uPprW0tw3//gGFhDDTiuksgradgFN6yRayDP4SyZZa6ZMGHLIa17+M8A==", "dev": true, "requires": { - "node-gyp-build": "~3.7.0" - }, - "dependencies": { - "node-gyp-build": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-3.7.0.tgz", - "integrity": "sha512-L/Eg02Epx6Si2NXmedx+Okg+4UHqmaf3TNcxd50SF9NQGcJaON3AtU++kax69XV7YWz4tUspqZSAsVofhFKG2w==", - "dev": true - } + "node-gyp-build": "^4.2.0" } }, "utf8": { @@ -10095,9 +10195,9 @@ }, "dependencies": { "@types/node": { - "version": "12.12.68", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.68.tgz", - "integrity": "sha512-3RW2s24ewB7F9dAHvgb9FRvNHn6nO9IK6Eaknbz7HTOe2a5GVne5XbUh5+YA+kcCn67glyHhClUUdFP73LWrgQ==", + "version": "12.19.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.4.tgz", + "integrity": "sha512-o3oj1bETk8kBwzz1WlO6JWL/AfAA3Vm6J1B3C9CsdxHYp7XgPiH7OEXPUbZTndHlRaIElrANkQfe6ZmfJb3H2w==", "dev": true }, "bignumber.js": { @@ -10544,9 +10644,9 @@ }, "dependencies": { "@types/node": { - "version": "10.17.40", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.40.tgz", - "integrity": "sha512-3hZT2z2/531A5pc8hYhn1gU5Qb1SIRSgMLQ6zuHA5xtt16lWAxUGprtr8lJuc9zNJMXEIIBWfSnzqBP/4mglpA==", + "version": "10.17.44", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.44.tgz", + "integrity": "sha512-vHPAyBX1ffLcy4fQHmDyIUMUb42gHZjPHU66nhvbMzAWJqHnySGZ6STwN3rwrnSd1FHB0DI/RWgGELgKSYRDmw==", "dev": true } } @@ -10566,9 +10666,9 @@ }, "dependencies": { "@types/node": { - "version": "12.12.68", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.68.tgz", - "integrity": "sha512-3RW2s24ewB7F9dAHvgb9FRvNHn6nO9IK6Eaknbz7HTOe2a5GVne5XbUh5+YA+kcCn67glyHhClUUdFP73LWrgQ==", + "version": "12.19.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.4.tgz", + "integrity": "sha512-o3oj1bETk8kBwzz1WlO6JWL/AfAA3Vm6J1B3C9CsdxHYp7XgPiH7OEXPUbZTndHlRaIElrANkQfe6ZmfJb3H2w==", "dev": true } } @@ -10664,9 +10764,9 @@ }, "dependencies": { "@types/node": { - "version": "10.17.40", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.40.tgz", - "integrity": "sha512-3hZT2z2/531A5pc8hYhn1gU5Qb1SIRSgMLQ6zuHA5xtt16lWAxUGprtr8lJuc9zNJMXEIIBWfSnzqBP/4mglpA==", + "version": "10.17.44", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.17.44.tgz", + "integrity": "sha512-vHPAyBX1ffLcy4fQHmDyIUMUb42gHZjPHU66nhvbMzAWJqHnySGZ6STwN3rwrnSd1FHB0DI/RWgGELgKSYRDmw==", "dev": true }, "elliptic": { @@ -10834,9 +10934,9 @@ }, "dependencies": { "@types/node": { - "version": "12.12.68", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.68.tgz", - "integrity": "sha512-3RW2s24ewB7F9dAHvgb9FRvNHn6nO9IK6Eaknbz7HTOe2a5GVne5XbUh5+YA+kcCn67glyHhClUUdFP73LWrgQ==", + "version": "12.19.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.4.tgz", + "integrity": "sha512-o3oj1bETk8kBwzz1WlO6JWL/AfAA3Vm6J1B3C9CsdxHYp7XgPiH7OEXPUbZTndHlRaIElrANkQfe6ZmfJb3H2w==", "dev": true } } diff --git a/package.json b/package.json index 743a2dbe..f3c46468 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.47", + "version": "0.0.1-rc.48", "description": "A platform for building DAOs", "files": [ "contracts/", diff --git a/test/genericschememulticall.js b/test/genericschememulticall.js index 8e48384a..233a3d93 100644 --- a/test/genericschememulticall.js +++ b/test/genericschememulticall.js @@ -7,12 +7,17 @@ const DAOTracker = artifacts.require("./DAOTracker.sol"); const ERC20Mock = artifacts.require("./ERC20Mock.sol"); const ActionMock = artifacts.require("./ActionMock.sol"); const DxDaoSchemeConstraints = artifacts.require("./DxDaoSchemeConstraints.sol"); +const SimpleSchemeConstraints = artifacts.require("./SimpleSchemeConstraints.sol"); export class GenericSchemeParams { constructor() { } } +const DXDAO_SCHEME_CONSTRAINT = 1; +const SIMPLE_SCHEME_CONSTRAINT = 2; + + const setupGenericSchemeParams = async function( genericScheme, accounts, @@ -46,7 +51,7 @@ const setup = async function (accounts, reputationAccount=0, genesisProtocol = false, tokenAddress=helpers.NULL_ADDRESS, - useSchemeConstraint = true) { + useSchemeConstraint = DXDAO_SCHEME_CONSTRAINT) { var testSetup = new helpers.TestSetup(); testSetup.standardTokenMock = await ERC20Mock.new(accounts[1],100); testSetup.genericSchemeMultiCall = await GenericSchemeMultiCall.new(); @@ -60,7 +65,7 @@ const setup = async function (accounts, testSetup.org = await helpers.setupOrganizationWithArrays(testSetup.daoCreator,[accounts[0],accounts[1],reputationAccount],[1000,1000,1000],testSetup.reputationArray); } var schemeConstraintsAddress; - if (useSchemeConstraint) { + if (useSchemeConstraint === DXDAO_SCHEME_CONSTRAINT) { testSetup.schemeConstraints = await DxDaoSchemeConstraints.new(); schemeConstraintsAddress = testSetup.schemeConstraints.address; //use accounts[4] as the avatar. @@ -71,9 +76,14 @@ const setup = async function (accounts, [1000], contractsWhiteList, testSetup.genericSchemeMultiCall.address); + } else if (useSchemeConstraint === SIMPLE_SCHEME_CONSTRAINT) { + testSetup.schemeConstraints = await SimpleSchemeConstraints.new(); + schemeConstraintsAddress = testSetup.schemeConstraints.address; + //use accounts[4] as the avatar. + await testSetup.schemeConstraints.initialize(contractsWhiteList,"descriptionHash"); } else { schemeConstraintsAddress = helpers.NULL_ADDRESS; - } + } testSetup.genericSchemeParams= await setupGenericSchemeParams(testSetup.genericSchemeMultiCall,accounts,genesisProtocol,tokenAddress,testSetup.org.avatar,schemeConstraintsAddress); var permissions = "0x00000010"; @@ -184,7 +194,7 @@ contract('GenericSchemeMultiCall', function(accounts) { } }); - it("execute proposeVote -positive decision - not whitelisted contract", async function() { + it("propose call - not whitelisted contract", async function() { var actionMock =await ActionMock.new(); var testSetup = await setup(accounts,[accounts[1]]); var callData = await createCallToActionMock(helpers.NULL_ADDRESS,actionMock); @@ -197,6 +207,22 @@ contract('GenericSchemeMultiCall', function(accounts) { } }); + it("propose call siplmeConstraint -positive decision - not whitelisted contract", async function() { + var actionMock =await ActionMock.new(); + var testSetup = await setup(accounts,[accounts[1]],0,false,helpers.NULL_ADDRESS,SIMPLE_SCHEME_CONSTRAINT); + var callData = await createCallToActionMock(helpers.NULL_ADDRESS,actionMock); + try { + await testSetup.genericSchemeMultiCall.proposeCalls( + [actionMock.address],[callData],[0],helpers.NULL_HASH); + assert(false, "contractToCall is not whitelisted"); + } catch(error) { + helpers.assertVMException(error); + } + await testSetup.genericSchemeMultiCall.proposeCalls( + [accounts[1]],[callData],[0],helpers.NULL_HASH); + + }); + it("execute proposeVote without return value-positive decision - check action", async function() { var actionMock =await ActionMock.new(); var testSetup = await setup(accounts,[actionMock.address]); @@ -431,7 +457,7 @@ contract('GenericSchemeMultiCall', function(accounts) { helpers.assertVMException(error); } }); - + it("can init with multiple contracts on whitelist", async function() { var actionMock =await ActionMock.new(); @@ -470,6 +496,48 @@ contract('GenericSchemeMultiCall', function(accounts) { }); + it("init SIMPLE_SCHEME_CONSTRAINT", async function() { + var simpleSchemeConstraints =await SimpleSchemeConstraints.new(); + await simpleSchemeConstraints.initialize( + [accounts[0],accounts[1],accounts[2],accounts[3]], + "descriptionHash" + ); + var contractsWhiteList = await simpleSchemeConstraints.getContractsWhiteList(); + assert.equal(contractsWhiteList[0],accounts[0]); + assert.equal(contractsWhiteList[1],accounts[1]); + assert.equal(contractsWhiteList[2],accounts[2]); + assert.equal(contractsWhiteList[3],accounts[3]); + + assert.equal(await simpleSchemeConstraints.descriptionHash(),"descriptionHash"); + + try { + await simpleSchemeConstraints.isAllowedToPropose( + [accounts[4]],[],[],helpers.NULL_ADDRESS + ); + assert(false, "cannot propose to call to non white list contract"); + } catch(error) { + helpers.assertVMException(error); + } + await simpleSchemeConstraints.isAllowedToPropose( + [accounts[3]],[],[],helpers.NULL_ADDRESS + ); + + try { + await simpleSchemeConstraints.isAllowedToCall( + [accounts[4]],[],[],helpers.NULL_ADDRESS + ); + assert(false, "cannot propose to call to non white list contract"); + } catch(error) { + helpers.assertVMException(error); + } + await simpleSchemeConstraints.isAllowedToCall( + [accounts[3]],[],[],helpers.NULL_ADDRESS + ); + + + }); + + it("cannot initialize contraints with zero period", async function() { var dxDaoSchemeConstraintsInit =await DxDaoSchemeConstraints.new(); try { @@ -534,6 +602,24 @@ contract('GenericSchemeMultiCall', function(accounts) { } }); + + it("cannot initialize SIMPLE_SCHEME_CONSTRAINT twice", async function() { + var simpleSchemeConstraints=await SimpleSchemeConstraints.new(); + await simpleSchemeConstraints.initialize( + [accounts[0]], + "descriptionHash" + ); + try { + await simpleSchemeConstraints.initialize( + [accounts[1]], + "descriptionHash" + ); + assert(false, "cannot initialize twice"); + } catch(error) { + helpers.assertVMException(error); + } + }); + it("execute proposeVote with multiple calls with votingMachine without whitelisted token", async function() { var actionMock =await ActionMock.new(); var standardTokenMock = await ERC20Mock.new(accounts[0],1000);