Skip to content

Commit

Permalink
use buildler.dev . remove truffle (#731)
Browse files Browse the repository at this point in the history
* truffle 5.1.20

* add .gitattreibutes

* use buildler.dev . remove truffle

* travis fix

* Add mocha vscode support

Co-authored-by: benk10 <ben.kaufman10@gmail.com>
  • Loading branch information
orenyodfat and ben-kaufman authored Apr 6, 2020
1 parent f04d0d6 commit b8e9868
Show file tree
Hide file tree
Showing 54 changed files with 4,032 additions and 2,568 deletions.
Empty file removed .eslintignore
Empty file.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"no-undef": "off",
"eol-last": 2,
"eqeqeq": "error"
}
},
"ignorePatterns": ["cache/", "node_modules/"]
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sol linguist-language=Solidity
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ node_modules/
.node-xmlhttprequest-sync*
*.tgz
.vscode/
cache/
artifacts/
site/
yarn*
.DS_Store
report*
5 changes: 5 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"require": ["@nomiclabs/buidler/register"],
"timeout": 20000,
"recursive": "test"
}
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ dist: trusty
language: node_js

node_js:
- "10.16.3"
- "12.16.1"

before_install:

install:
- npm ci
- rm -rf build/ # remove any remaining artifacts from a previous build
- truffle version
- npx buidler --version
- npx buidler clean

jobs:
include:
- stage: tests
name: "Unit tests"
script: npm run test
script: npx buidler test

- stage: tests
name: "Solidity Lint"
script: npm run solhint
script: npx buidler check

- stage: tests
name: "JS Lint"
script: npm run lint
script: npx eslint .
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,7 @@ We take no responsibility for your implementation decisions and any security pro

## Getting Started

1. Please install [Truffle](https://github.com/ConsenSys/truffle) and initialize your project with `truffle init`.
```sh
npm install -g truffle
mkdir myproject && cd myproject
truffle init
```
1. Install [buidler](https://buidler.dev/getting-started/#quick-start) and initialize your project
2. Install the `@daostack/arc` package: `npm install @daostack/arc`.
- `.sol` Source code is found under `node_modules/@daostack/arc/contracts`
- `.json` Compiled contracts are found under `node_modules/@daostack/arc/build/contracts`
Expand Down
131 changes: 131 additions & 0 deletions buidler.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
usePlugin("@nomiclabs/buidler-truffle5");
usePlugin("@nomiclabs/buidler-solhint");

// This is a sample Buidler task. To learn how to create your own go to
// https://buidler.dev/guides/create-task.html
task("accounts", "Prints the list of accounts", async () => {
const accounts = await web3.eth.getAccounts();

for (const account of accounts) {
console.log(account);
}
});

module.exports = {
paths: {
artifacts: './build/contracts'
},
networks: {
buidlerevm: {
accounts: [
{
privateKey:
"0xc5e8f61d1ab959b397eecc0a37a6517b8e67a0e7cf1f4bce5591f3ed80199122",
balance: "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
},
{
privateKey:
"0xd49743deccbccc5dc7baa8e69e5be03298da8688a15dd202e20f15d5e0e9a9fb",
balance: "10000000000000000000000"
},
{
privateKey:
"0x23c601ae397441f3ef6f1075dcb0031ff17fb079837beadaf3c84d96c6f3e569",
balance: "10000000000000000000000"
},
{
privateKey:
"0xee9d129c1997549ee09c0757af5939b2483d80ad649a0eda68e8b0357ad11131",
balance: "10000000000000000000000"
},
{
privateKey:
"0x87630b2d1de0fbd5044eb6891b3d9d98c34c8d310c852f98550ba774480e47cc",
balance: "10000000000000000000000"
},
{
privateKey:
"0x275cc4a2bfd4f612625204a20a2280ab53a6da2d14860c47a9f5affe58ad86d4",
balance: "10000000000000000000000"
},
{
privateKey:
"0x7f307c41137d1ed409f0a7b028f6c7596f12734b1d289b58099b99d60a96efff",
balance: "10000000000000000000000"
},
{
privateKey:
"0x2a8aede924268f84156a00761de73998dac7bf703408754b776ff3f873bcec60",
balance: "10000000000000000000000"
},
{
privateKey:
"0x8b24fd94f1ce869d81a34b95351e7f97b2cd88a891d5c00abc33d0ec9501902e",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29085",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29086",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29087",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29088",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b29089",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908a",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908b",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908c",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908d",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908e",
balance: "10000000000000000000000"
},
{
privateKey:
"0x28d1bfbbafe9d1d4f5a11c3c16ab6bf9084de48d99fbac4058bdfa3c80b2908f",
balance: "10000000000000000000000"
}
]
}
},
solc: {
version: "0.5.16", // Fetch exact version from solc-bin (default: truffle's version)
optimizer: {
enabled: true,
runs: 200
}
}
};
12 changes: 6 additions & 6 deletions contracts/controller/Avatar.sol
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pragma solidity ^0.5.13;
pragma solidity ^0.5.16;

import "@daostack/infra-experimental/contracts/Reputation.sol";
import "./DAOToken.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/ownership/Ownable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "../libs/SafeERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";


Expand Down Expand Up @@ -32,7 +32,7 @@ contract Vault is Ownable {
* @title An Avatar holds tokens, reputation and ether for a controller
*/
contract Avatar is Initializable, Ownable {
using SafeERC20 for address;
using SafeERC20 for IERC20;

string public orgName;
DAOToken public nativeToken;
Expand Down Expand Up @@ -118,7 +118,7 @@ contract Avatar is Initializable, Ownable {
function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value)
external onlyOwner returns(bool)
{
address(_externalToken).safeTransfer(_to, _value);
_externalToken.safeTransfer(_to, _value);
emit ExternalTokenTransfer(address(_externalToken), _to, _value);
return true;
}
Expand All @@ -139,7 +139,7 @@ contract Avatar is Initializable, Ownable {
)
external onlyOwner returns(bool)
{
address(_externalToken).safeTransferFrom(_from, _to, _value);
_externalToken.safeTransferFrom(_from, _to, _value);
emit ExternalTokenTransferFrom(address(_externalToken), _from, _to, _value);
return true;
}
Expand All @@ -155,7 +155,7 @@ contract Avatar is Initializable, Ownable {
function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value)
external onlyOwner returns(bool)
{
address(_externalToken).safeApprove(_spender, _value);
_externalToken.safeApprove(_spender, _value);
emit ExternalTokenApproval(address(_externalToken), _spender, _value);
return true;
}
Expand Down
27 changes: 18 additions & 9 deletions contracts/controller/Controller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,32 +65,38 @@ contract Controller is Initializable {

// Modifiers:
modifier onlyRegisteredScheme() {
require(schemesPermissions[msg.sender]&bytes4(0x00000001) == bytes4(0x00000001));
require(schemesPermissions[msg.sender]&bytes4(0x00000001) == bytes4(0x00000001),
"sender is not registered scheme");
_;
}

modifier onlyRegisteringSchemes() {
require(schemesPermissions[msg.sender]&bytes4(0x00000002) == bytes4(0x00000002));
require(schemesPermissions[msg.sender]&bytes4(0x00000002) == bytes4(0x00000002),
"sender unautorized to register scheme");
_;
}

modifier onlyGlobalConstraintsScheme() {
require(schemesPermissions[msg.sender]&bytes4(0x00000004) == bytes4(0x00000004));
require(schemesPermissions[msg.sender]&bytes4(0x00000004) == bytes4(0x00000004),
"sender is not globalConstraint scheme");
_;
}

modifier onlyUpgradingScheme() {
require(schemesPermissions[msg.sender]&bytes4(0x00000008) == bytes4(0x00000008));
require(schemesPermissions[msg.sender]&bytes4(0x00000008) == bytes4(0x00000008),
"sender is not UpgradingScheme");
_;
}

modifier onlyGenericCallScheme() {
require(schemesPermissions[msg.sender]&bytes4(0x00000010) == bytes4(0x00000010));
require(schemesPermissions[msg.sender]&bytes4(0x00000010) == bytes4(0x00000010),
"sender is not a Generic Scheme");
_;
}

modifier onlyMetaDataScheme() {
require(schemesPermissions[msg.sender]&bytes4(0x00000010) == bytes4(0x00000010));
require(schemesPermissions[msg.sender]&bytes4(0x00000010) == bytes4(0x00000010),
"sender is not a MetaData Scheme");
_;
}

Expand Down Expand Up @@ -176,10 +182,12 @@ contract Controller is Initializable {
// Implementation is a bit messy. One must recall logic-circuits ^^

// produces non-zero if sender does not have all of the perms that are changing between old and new
require(bytes4(0x0000001f)&(_permissions^permissions)&(~schemesPermissions[msg.sender]) == bytes4(0));
require(bytes4(0x0000001f)&(_permissions^permissions)&(~schemesPermissions[msg.sender]) == bytes4(0),
"sender unautorize to register scheme");

// produces non-zero if sender does not have all of the perms in the old scheme
require(bytes4(0x0000001f)&(permissions&(~schemesPermissions[msg.sender])) == bytes4(0));
require(bytes4(0x0000001f)&(permissions&(~schemesPermissions[msg.sender])) == bytes4(0),
"sender unautorize to register scheme");

// Add or change the scheme:
schemesPermissions[_scheme] = _permissions|bytes4(0x00000001);
Expand All @@ -203,7 +211,8 @@ contract Controller is Initializable {
return false;
}
// Check the unregistering scheme has enough permissions:
require(bytes4(0x0000001f)&(schemesPermissions[_scheme]&(~schemesPermissions[msg.sender])) == bytes4(0));
require(bytes4(0x0000001f)&(schemesPermissions[_scheme]&(~schemesPermissions[msg.sender])) == bytes4(0),
"sender unautorized to unregister scheme");

// Unregister:
emit UnregisterScheme(msg.sender, _scheme);
Expand Down
5 changes: 3 additions & 2 deletions contracts/controller/DAOToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ contract DAOToken is Initializable, Ownable, ERC20, ERC20Burnable {
* @param _amount The amount of tokens to mint.
*/
function mint(address _to, uint256 _amount) public onlyOwner returns (bool) {
if (cap > 0)
require(totalSupply().add(_amount) <= cap);
if (cap > 0) {
require(totalSupply().add(_amount) <= cap, "override cap");
}
_mint(_to, _amount);
return true;
}
Expand Down
Loading

0 comments on commit b8e9868

Please sign in to comment.