Skip to content

Commit

Permalink
WIP : arc factory (#678)
Browse files Browse the repository at this point in the history
* none universal contracts

* lint

* compilation

* fix controller test

* add daoFactory

* controller : remove fallback function

* bring back daotracker for now

* fix Avatar proxy creation.

* remove controller parameters

* fix forwarder

* use   "@openzeppelin/contracts-ethereum-package": "2.3.0",

* add daofactory test

* infra rc.16

* remove UniversalSchemeMock

* tests

* tests

* naming

* simplify global constraint

* conmetics

* package name arc-expiremental

use infra-expiremental

* infra package-experimental spelling

* remove none needed imports

* set avatar as proxy admin

* Controller: emit RegisterScheme(msg.sender, initialScheme) at initilize function
  • Loading branch information
orenyodfat authored Nov 5, 2019
1 parent 03c4350 commit 79278b2
Show file tree
Hide file tree
Showing 74 changed files with 6,111 additions and 4,352 deletions.
48 changes: 27 additions & 21 deletions contracts/controller/Avatar.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
pragma solidity ^0.5.11;

import "@daostack/infra/contracts/Reputation.sol";
import "@daostack/infra-experimental/contracts/Reputation.sol";
import "./DAOToken.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
import "openzeppelin-solidity/contracts/token/ERC20/IERC20.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/upgrades/contracts/Initializable.sol";

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

string public orgName;
Expand All @@ -26,20 +26,26 @@ contract Avatar is Ownable {
event MetaData(string _metaData);

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

/**
* @dev enables an avatar to receive ethers
* @dev initialize takes organization name, native token and reputation system
and creates an avatar for a controller
*/
function() external payable {
emit ReceiveEther(msg.sender, msg.value);
function initialize(string calldata _orgName,
DAOToken _nativeToken,
Reputation _nativeReputation,
address _owner)
external
initializer {
orgName = _orgName;
nativeToken = _nativeToken;
nativeReputation = _nativeReputation;
Ownable.initialize(_owner);
}

/**
Expand All @@ -50,8 +56,8 @@ contract Avatar is Ownable {
* @return bool success or fail
* bytes - the return bytes of the called contract's function.
*/
function genericCall(address _contract, bytes memory _data, uint256 _value)
public
function genericCall(address _contract, bytes calldata _data, uint256 _value)
external
onlyOwner
returns(bool success, bytes memory returnValue) {
// solhint-disable-next-line avoid-call-value
Expand All @@ -65,7 +71,7 @@ contract Avatar is Ownable {
* @param _to send the ethers to this address
* @return bool which represents success
*/
function sendEther(uint256 _amountInWei, address payable _to) public onlyOwner returns(bool) {
function sendEther(uint256 _amountInWei, address payable _to) external onlyOwner returns(bool) {
_to.transfer(_amountInWei);
emit SendEther(_amountInWei, _to);
return true;
Expand All @@ -79,7 +85,7 @@ contract Avatar is Ownable {
* @return bool which represents success
*/
function externalTokenTransfer(IERC20 _externalToken, address _to, uint256 _value)
public onlyOwner returns(bool)
external onlyOwner returns(bool)
{
address(_externalToken).safeTransfer(_to, _value);
emit ExternalTokenTransfer(address(_externalToken), _to, _value);
Expand All @@ -100,7 +106,7 @@ contract Avatar is Ownable {
address _to,
uint256 _value
)
public onlyOwner returns(bool)
external onlyOwner returns(bool)
{
address(_externalToken).safeTransferFrom(_from, _to, _value);
emit ExternalTokenTransferFrom(address(_externalToken), _from, _to, _value);
Expand All @@ -116,7 +122,7 @@ contract Avatar is Ownable {
* @return bool which represents a success
*/
function externalTokenApproval(IERC20 _externalToken, address _spender, uint256 _value)
public onlyOwner returns(bool)
external onlyOwner returns(bool)
{
address(_externalToken).safeApprove(_spender, _value);
emit ExternalTokenApproval(address(_externalToken), _spender, _value);
Expand All @@ -128,7 +134,7 @@ contract Avatar is Ownable {
* @param _metaData a string representing a hash of the meta data
* @return bool which represents a success
*/
function metaData(string memory _metaData) public onlyOwner returns(bool) {
function metaData(string calldata _metaData) external onlyOwner returns(bool) {
emit MetaData(_metaData);
return true;
}
Expand Down
Loading

0 comments on commit 79278b2

Please sign in to comment.