Skip to content

Commit 4fe3efd

Browse files
authored
release candidate for v 0.0.1 (#573)
* use infra 11 * bump version to alpha.59 * use infra 0.0.1-rc.2 solc 5.0 * fix daocreator.js * solium * replace solium with solhint * update travis * add jobs to travis * Update package.json * update package-lock.json
1 parent 6f40ae2 commit 4fe3efd

File tree

72 files changed

+2723
-8990
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2723
-8990
lines changed

.solhint.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "default",
3+
"rules": {
4+
"indent": ["error", 4],
5+
6+
"compiler-fixed": false,
7+
"no-simple-event-func-name": false,
8+
"two-lines-top-level-separator": false
9+
}
10+
}

.soliumignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

.soliumrc.json

Lines changed: 0 additions & 23 deletions
This file was deleted.

.travis.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ dist: trusty
33
language: node_js
44

55
node_js:
6-
- "10.14.1"
6+
- "10.14.2"
77

88
before_install:
9-
- sudo apt-get update -qq
10-
- sudo apt-get install software-properties-common -y -qq
11-
- sudo add-apt-repository -y ppa:ethereum/ethereum
12-
- sudo add-apt-repository -y ppa:ethereum/ethereum-dev
13-
- sudo apt-get update -qq
14-
- sudo apt-get install geth -y -qq
159

1610
install:
1711
- npm ci
1812
- rm -rf build/ # remove any remaining artifacts from a previous build
1913
- truffle version
2014

21-
script:
22-
- npm run test
23-
- npm run lint
24-
- npm run solium
15+
jobs:
16+
include:
17+
- stage: tests
18+
name: "Unit tests"
19+
script: npm run test
20+
21+
- stage: tests
22+
name: "Solidity Lint"
23+
script: npm run solhint
24+
25+
- stage: tests
26+
name: "JS Lint"
27+
script: npm run lint
28+
29+
2530
notifications:
2631
slack: daostack:fGuaFPsiQiV5mgmzRcSzbYqw

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Available commands while developing:
5151
- `npm run build` - Compile all contracts to the `build/` folder.
5252
- `npm run test` - This will run ganache-cli, compile, migrate and run all tests.
5353
- `npm run lint` - Check all JavaScript code for style & good practices.
54-
- `npm run solium` - Check all Solidity code for style & good practices.
54+
- `npm run solhint` - Check all Solidity code for style & good practices.
5555
- `npm run docs:<update|build|deploy|preview>` - See [this](docs#contributing-to-arc-docs) for details.
5656

5757
### Docker

contracts/Migrations.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pragma solidity ^0.4.25;
1+
pragma solidity ^0.5.2;
22

33

44
contract Migrations {

contracts/controller/Avatar.sol

Lines changed: 22 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
pragma solidity ^0.4.25;
1+
pragma solidity ^0.5.2;
22

33
import "@daostack/infra/contracts/Reputation.sol";
44
import "./DAOToken.sol";
55
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
6-
import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol";
6+
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
77
import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";
88

99

1010
/**
1111
* @title An Avatar holds tokens, reputation and ether for a controller
1212
*/
1313
contract Avatar is Ownable {
14-
using SafeERC20 for StandardToken;
14+
using SafeERC20 for ERC20;
1515

1616
string public orgName;
1717
DAOToken public nativeToken;
@@ -21,15 +21,14 @@ contract Avatar is Ownable {
2121
event SendEther(uint256 _amountInWei, address indexed _to);
2222
event ExternalTokenTransfer(address indexed _externalToken, address indexed _to, uint256 _value);
2323
event ExternalTokenTransferFrom(address indexed _externalToken, address _from, address _to, uint256 _value);
24-
event ExternalTokenIncreaseApproval(StandardToken indexed _externalToken, address _spender, uint256 _addedValue);
25-
event ExternalTokenDecreaseApproval(StandardToken indexed _externalToken, address _spender, uint256 _subtractedValue);
24+
event ExternalTokenApproval(ERC20 indexed _externalToken, address _spender, uint256 _value);
2625
event ReceiveEther(address indexed _sender, uint256 _value);
2726

2827
/**
2928
* @dev the constructor takes organization name, native token and reputation system
3029
and creates an avatar for a controller
3130
*/
32-
constructor(string _orgName, DAOToken _nativeToken, Reputation _nativeReputation) public {
31+
constructor(string memory _orgName, DAOToken _nativeToken, Reputation _nativeReputation) public {
3332
orgName = _orgName;
3433
nativeToken = _nativeToken;
3534
nativeReputation = _nativeReputation;
@@ -38,7 +37,7 @@ contract Avatar is Ownable {
3837
/**
3938
* @dev enables an avatar to receive ethers
4039
*/
41-
function() public payable {
40+
function() external payable {
4241
emit ReceiveEther(msg.sender, msg.value);
4342
}
4443

@@ -48,20 +47,12 @@ contract Avatar is Ownable {
4847
* @param _data ABI-encoded contract call to call `_contract` address.
4948
* @return the return bytes of the called contract's function.
5049
*/
51-
function genericCall(address _contract,bytes _data) public onlyOwner {
52-
emit GenericCall(_contract,_data);
53-
// solium-disable-next-line security/no-low-level-calls
54-
bool result = _contract.call(_data);
55-
// solium-disable-next-line security/no-inline-assembly
56-
assembly {
57-
// Copy the returned data.
58-
returndatacopy(0, 0, returndatasize)
59-
60-
switch result
61-
// call returns 0 on error.
62-
case 0 { revert(0, returndatasize) }
63-
default { return(0, returndatasize) }
64-
}
50+
function genericCall(address _contract, bytes memory _data) public onlyOwner returns(bytes memory) {
51+
emit GenericCall(_contract, _data);
52+
// solhint-disable-next-line avoid-low-level-calls
53+
(bool success, bytes memory returnValue) = _contract.call(_data);
54+
require(success);
55+
return returnValue;
6556
}
6657

6758
/**
@@ -70,7 +61,7 @@ contract Avatar is Ownable {
7061
* @param _to send the ethers to this address
7162
* @return bool which represents success
7263
*/
73-
function sendEther(uint256 _amountInWei, address _to) public onlyOwner returns(bool) {
64+
function sendEther(uint256 _amountInWei, address payable _to) public onlyOwner returns(bool) {
7465
_to.transfer(_amountInWei);
7566
emit SendEther(_amountInWei, _to);
7667
return true;
@@ -83,11 +74,11 @@ contract Avatar is Ownable {
8374
* @param _value the amount of tokens to transfer
8475
* @return bool which represents success
8576
*/
86-
function externalTokenTransfer(StandardToken _externalToken, address _to, uint256 _value)
77+
function externalTokenTransfer(ERC20 _externalToken, address _to, uint256 _value)
8778
public onlyOwner returns(bool)
8879
{
8980
_externalToken.safeTransfer(_to, _value);
90-
emit ExternalTokenTransfer(_externalToken, _to, _value);
81+
emit ExternalTokenTransfer(address(_externalToken), _to, _value);
9182
return true;
9283
}
9384

@@ -100,47 +91,31 @@ contract Avatar is Ownable {
10091
* @return bool which represents success
10192
*/
10293
function externalTokenTransferFrom(
103-
StandardToken _externalToken,
94+
ERC20 _externalToken,
10495
address _from,
10596
address _to,
10697
uint256 _value
10798
)
10899
public onlyOwner returns(bool)
109100
{
110101
_externalToken.safeTransferFrom(_from, _to, _value);
111-
emit ExternalTokenTransferFrom(_externalToken, _from, _to, _value);
112-
return true;
113-
}
114-
115-
/**
116-
* @dev increase approval for the spender address to spend a specified amount of tokens
117-
* on behalf of msg.sender.
118-
* @param _externalToken the address of the Token Contract
119-
* @param _spender address
120-
* @param _addedValue the amount of ether (in Wei) which the approval is referring to.
121-
* @return bool which represents a success
122-
*/
123-
function externalTokenIncreaseApproval(StandardToken _externalToken, address _spender, uint256 _addedValue)
124-
public onlyOwner returns(bool)
125-
{
126-
require(_externalToken.increaseApproval(_spender, _addedValue),"increase approval must succeed");
127-
emit ExternalTokenIncreaseApproval(_externalToken, _spender, _addedValue);
102+
emit ExternalTokenTransferFrom(address(_externalToken), _from, _to, _value);
128103
return true;
129104
}
130105

131106
/**
132-
* @dev decrease approval for the spender address to spend a specified amount of tokens
107+
* @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
133108
* on behalf of msg.sender.
134109
* @param _externalToken the address of the Token Contract
135110
* @param _spender address
136-
* @param _subtractedValue the amount of ether (in Wei) which the approval is referring to.
111+
* @param _value the amount of ether (in Wei) which the approval is referring to.
137112
* @return bool which represents a success
138113
*/
139-
function externalTokenDecreaseApproval(StandardToken _externalToken, address _spender, uint256 _subtractedValue )
114+
function externalTokenApproval(ERC20 _externalToken, address _spender, uint256 _value)
140115
public onlyOwner returns(bool)
141116
{
142-
require(_externalToken.decreaseApproval(_spender, _subtractedValue),"decrease approval must succeed");
143-
emit ExternalTokenDecreaseApproval(_externalToken,_spender, _subtractedValue);
117+
require(_externalToken.approve(_spender, _value), "approve must succeed");
118+
emit ExternalTokenApproval(_externalToken, _spender, _value);
144119
return true;
145120
}
146121

0 commit comments

Comments
 (0)