Skip to content

Commit

Permalink
release candidate for v 0.0.1 (#573)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
orenyodfat authored Dec 27, 2018
1 parent 6f40ae2 commit 4fe3efd
Show file tree
Hide file tree
Showing 72 changed files with 2,723 additions and 8,990 deletions.
10 changes: 10 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "default",
"rules": {
"indent": ["error", 4],

"compiler-fixed": false,
"no-simple-event-func-name": false,
"two-lines-top-level-separator": false
}
}
2 changes: 0 additions & 2 deletions .soliumignore

This file was deleted.

23 changes: 0 additions & 23 deletions .soliumrc.json

This file was deleted.

27 changes: 16 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ dist: trusty
language: node_js

node_js:
- "10.14.1"
- "10.14.2"

before_install:
- sudo apt-get update -qq
- sudo apt-get install software-properties-common -y -qq
- sudo add-apt-repository -y ppa:ethereum/ethereum
- sudo add-apt-repository -y ppa:ethereum/ethereum-dev
- sudo apt-get update -qq
- sudo apt-get install geth -y -qq

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

script:
- npm run test
- npm run lint
- npm run solium
jobs:
include:
- stage: tests
name: "Unit tests"
script: npm run test

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

- stage: tests
name: "JS Lint"
script: npm run lint


notifications:
slack: daostack:fGuaFPsiQiV5mgmzRcSzbYqw
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Available commands while developing:
- `npm run build` - Compile all contracts to the `build/` folder.
- `npm run test` - This will run ganache-cli, compile, migrate and run all tests.
- `npm run lint` - Check all JavaScript code for style & good practices.
- `npm run solium` - Check all Solidity code for style & good practices.
- `npm run solhint` - Check all Solidity code for style & good practices.
- `npm run docs:<update|build|deploy|preview>` - See [this](docs#contributing-to-arc-docs) for details.

### Docker
Expand Down
2 changes: 1 addition & 1 deletion contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.4.25;
pragma solidity ^0.5.2;


contract Migrations {
Expand Down
69 changes: 22 additions & 47 deletions contracts/controller/Avatar.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
pragma solidity ^0.4.25;
pragma solidity ^0.5.2;

import "@daostack/infra/contracts/Reputation.sol";
import "./DAOToken.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol";
import "openzeppelin-solidity/contracts/token/ERC20/ERC20.sol";
import "openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol";


/**
* @title An Avatar holds tokens, reputation and ether for a controller
*/
contract Avatar is Ownable {
using SafeERC20 for StandardToken;
using SafeERC20 for ERC20;

string public orgName;
DAOToken public nativeToken;
Expand All @@ -21,15 +21,14 @@ contract Avatar is Ownable {
event SendEther(uint256 _amountInWei, address indexed _to);
event ExternalTokenTransfer(address indexed _externalToken, address indexed _to, uint256 _value);
event ExternalTokenTransferFrom(address indexed _externalToken, address _from, address _to, uint256 _value);
event ExternalTokenIncreaseApproval(StandardToken indexed _externalToken, address _spender, uint256 _addedValue);
event ExternalTokenDecreaseApproval(StandardToken indexed _externalToken, address _spender, uint256 _subtractedValue);
event ExternalTokenApproval(ERC20 indexed _externalToken, address _spender, uint256 _value);
event ReceiveEther(address indexed _sender, uint256 _value);

/**
* @dev the constructor takes organization name, native token and reputation system
and creates an avatar for a controller
*/
constructor(string _orgName, DAOToken _nativeToken, Reputation _nativeReputation) public {
constructor(string memory _orgName, DAOToken _nativeToken, Reputation _nativeReputation) public {
orgName = _orgName;
nativeToken = _nativeToken;
nativeReputation = _nativeReputation;
Expand All @@ -38,7 +37,7 @@ contract Avatar is Ownable {
/**
* @dev enables an avatar to receive ethers
*/
function() public payable {
function() external payable {
emit ReceiveEther(msg.sender, msg.value);
}

Expand All @@ -48,20 +47,12 @@ contract Avatar is Ownable {
* @param _data ABI-encoded contract call to call `_contract` address.
* @return the return bytes of the called contract's function.
*/
function genericCall(address _contract,bytes _data) public onlyOwner {
emit GenericCall(_contract,_data);
// solium-disable-next-line security/no-low-level-calls
bool result = _contract.call(_data);
// solium-disable-next-line security/no-inline-assembly
assembly {
// Copy the returned data.
returndatacopy(0, 0, returndatasize)

switch result
// call returns 0 on error.
case 0 { revert(0, returndatasize) }
default { return(0, returndatasize) }
}
function genericCall(address _contract, bytes memory _data) public onlyOwner returns(bytes memory) {
emit GenericCall(_contract, _data);
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returnValue) = _contract.call(_data);
require(success);
return returnValue;
}

/**
Expand All @@ -70,7 +61,7 @@ contract Avatar is Ownable {
* @param _to send the ethers to this address
* @return bool which represents success
*/
function sendEther(uint256 _amountInWei, address _to) public onlyOwner returns(bool) {
function sendEther(uint256 _amountInWei, address payable _to) public onlyOwner returns(bool) {
_to.transfer(_amountInWei);
emit SendEther(_amountInWei, _to);
return true;
Expand All @@ -83,11 +74,11 @@ contract Avatar is Ownable {
* @param _value the amount of tokens to transfer
* @return bool which represents success
*/
function externalTokenTransfer(StandardToken _externalToken, address _to, uint256 _value)
function externalTokenTransfer(ERC20 _externalToken, address _to, uint256 _value)
public onlyOwner returns(bool)
{
_externalToken.safeTransfer(_to, _value);
emit ExternalTokenTransfer(_externalToken, _to, _value);
emit ExternalTokenTransfer(address(_externalToken), _to, _value);
return true;
}

Expand All @@ -100,47 +91,31 @@ contract Avatar is Ownable {
* @return bool which represents success
*/
function externalTokenTransferFrom(
StandardToken _externalToken,
ERC20 _externalToken,
address _from,
address _to,
uint256 _value
)
public onlyOwner returns(bool)
{
_externalToken.safeTransferFrom(_from, _to, _value);
emit ExternalTokenTransferFrom(_externalToken, _from, _to, _value);
return true;
}

/**
* @dev increase approval for the spender address to spend a specified amount of tokens
* on behalf of msg.sender.
* @param _externalToken the address of the Token Contract
* @param _spender address
* @param _addedValue the amount of ether (in Wei) which the approval is referring to.
* @return bool which represents a success
*/
function externalTokenIncreaseApproval(StandardToken _externalToken, address _spender, uint256 _addedValue)
public onlyOwner returns(bool)
{
require(_externalToken.increaseApproval(_spender, _addedValue),"increase approval must succeed");
emit ExternalTokenIncreaseApproval(_externalToken, _spender, _addedValue);
emit ExternalTokenTransferFrom(address(_externalToken), _from, _to, _value);
return true;
}

/**
* @dev decrease approval for the spender address to spend a specified amount of tokens
* @dev externalTokenApproval approve the spender address to spend a specified amount of tokens
* on behalf of msg.sender.
* @param _externalToken the address of the Token Contract
* @param _spender address
* @param _subtractedValue the amount of ether (in Wei) which the approval is referring to.
* @param _value the amount of ether (in Wei) which the approval is referring to.
* @return bool which represents a success
*/
function externalTokenDecreaseApproval(StandardToken _externalToken, address _spender, uint256 _subtractedValue )
function externalTokenApproval(ERC20 _externalToken, address _spender, uint256 _value)
public onlyOwner returns(bool)
{
require(_externalToken.decreaseApproval(_spender, _subtractedValue),"decrease approval must succeed");
emit ExternalTokenDecreaseApproval(_externalToken,_spender, _subtractedValue);
require(_externalToken.approve(_spender, _value), "approve must succeed");
emit ExternalTokenApproval(_externalToken, _spender, _value);
return true;
}

Expand Down
Loading

0 comments on commit 4fe3efd

Please sign in to comment.