Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.5.13;
pragma solidity ^0.5.16;


contract Migrations {
Expand Down
38 changes: 34 additions & 4 deletions contracts/controller/Avatar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,27 @@ import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.so
import "../libs/SafeERC20.sol";
import "@openzeppelin/upgrades/contracts/Initializable.sol";


//Proxy contracts cannot recive eth via fallback function.
//For now , we will use this vault to overcome that
contract Vault is Ownable {
event ReceiveEther(address indexed _sender, uint256 _value);

/**
* @dev enables this contract to receive ethers
*/
function() external payable {
emit ReceiveEther(msg.sender, msg.value);
}

function sendEther(uint256 _amountInWei, address payable _to) external onlyOwner returns(bool) {
// solhint-disable-next-line avoid-call-value
(bool success, ) = _to.call.value(_amountInWei)("");
require(success, "sendEther failed.");
}
}


/**
* @title An Avatar holds tokens, reputation and ether for a controller
*/
Expand All @@ -16,20 +37,24 @@ contract Avatar is Initializable, Ownable {
string public orgName;
DAOToken public nativeToken;
Reputation public nativeReputation;
Vault public vault;

event GenericCall(address indexed _contract, bytes _data, uint _value, bool _success);
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 ExternalTokenApproval(address indexed _externalToken, address _spender, uint256 _value);
event ReceiveEther(address indexed _sender, uint256 _value);
event MetaData(string _metaData);

/**
* @dev enables an avatar to receive ethers
*/
function() external payable {
emit ReceiveEther(msg.sender, msg.value);
if (msg.sender != address(vault)) {
// solhint-disable-next-line avoid-call-value
(bool success, ) = address(vault).call.value(msg.value)("");
require(success, "sendEther failed.");
}
}

/**
Expand All @@ -46,6 +71,8 @@ contract Avatar is Initializable, Ownable {
nativeToken = _nativeToken;
nativeReputation = _nativeReputation;
Ownable.initialize(_owner);
vault = new Vault();
vault.initialize(address(this));
}

/**
Expand All @@ -60,7 +87,10 @@ contract Avatar is Initializable, Ownable {
external
onlyOwner
returns(bool success, bytes memory returnValue) {
// solhint-disable-next-line avoid-call-value
if (_value > 0) {
vault.sendEther(_value, address(this));
}
// solhint-disable-next-line avoid-call-value
(success, returnValue) = _contract.call.value(_value)(_data);
emit GenericCall(_contract, _data, _value, success);
}
Expand All @@ -72,7 +102,7 @@ contract Avatar is Initializable, Ownable {
* @return bool which represents success
*/
function sendEther(uint256 _amountInWei, address payable _to) external onlyOwner returns(bool) {
_to.transfer(_amountInWei);
vault.sendEther(_amountInWei, _to);
emit SendEther(_amountInWei, _to);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion contracts/controller/Controller.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.13;
pragma solidity ^0.5.16;

import "./Avatar.sol";
import "../globalConstraints/GlobalConstraintInterface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/controller/DAOToken.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.13;
pragma solidity ^0.5.16;

import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Burnable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/globalConstraints/GlobalConstraintInterface.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.13;
pragma solidity ^0.5.16;


contract GlobalConstraintInterface {
Expand Down
2 changes: 1 addition & 1 deletion contracts/globalConstraints/TokenCapGC.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.13;
pragma solidity ^0.5.16;

import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
import "./GlobalConstraintInterface.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/libs/SafeERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ REFERENCE & RELATED READING
- https://gist.github.com/BrendanChou/88a2eeb80947ff00bcf58ffdafeaeb61

*/
pragma solidity ^0.5.13;
pragma solidity ^0.5.16;

import "@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
Expand Down
2 changes: 1 addition & 1 deletion contracts/schemes/Agreement.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.13;
pragma solidity ^0.5.16;

/**
* @title A scheme for conduct ERC20 Tokens auction for reputation
Expand Down
2 changes: 1 addition & 1 deletion contracts/schemes/Auction4Reputation.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pragma solidity ^0.5.13;
pragma solidity ^0.5.16;

import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
import "../controller/Controller.sol";
Expand Down
Loading