Skip to content

Commit dc9044e

Browse files
authored
experimental : add competition and contributionrewardext (#714)
* solc 0.5.16 add competition... * update package-lock.json * fix test * lint * genericScheme test use daofactory * upgradeScheme use daofactory * bump v to 0.1.1-rc.4
1 parent 75245d5 commit dc9044e

Some content is hidden

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

60 files changed

+3731
-654
lines changed

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.5.13;
1+
pragma solidity ^0.5.16;
22

33

44
contract Migrations {

contracts/controller/Avatar.sol

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,27 @@ import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.so
77
import "../libs/SafeERC20.sol";
88
import "@openzeppelin/upgrades/contracts/Initializable.sol";
99

10+
11+
//Proxy contracts cannot recive eth via fallback function.
12+
//For now , we will use this vault to overcome that
13+
contract Vault is Ownable {
14+
event ReceiveEther(address indexed _sender, uint256 _value);
15+
16+
/**
17+
* @dev enables this contract to receive ethers
18+
*/
19+
function() external payable {
20+
emit ReceiveEther(msg.sender, msg.value);
21+
}
22+
23+
function sendEther(uint256 _amountInWei, address payable _to) external onlyOwner returns(bool) {
24+
// solhint-disable-next-line avoid-call-value
25+
(bool success, ) = _to.call.value(_amountInWei)("");
26+
require(success, "sendEther failed.");
27+
}
28+
}
29+
30+
1031
/**
1132
* @title An Avatar holds tokens, reputation and ether for a controller
1233
*/
@@ -16,20 +37,24 @@ contract Avatar is Initializable, Ownable {
1637
string public orgName;
1738
DAOToken public nativeToken;
1839
Reputation public nativeReputation;
40+
Vault public vault;
1941

2042
event GenericCall(address indexed _contract, bytes _data, uint _value, bool _success);
2143
event SendEther(uint256 _amountInWei, address indexed _to);
2244
event ExternalTokenTransfer(address indexed _externalToken, address indexed _to, uint256 _value);
2345
event ExternalTokenTransferFrom(address indexed _externalToken, address _from, address _to, uint256 _value);
2446
event ExternalTokenApproval(address indexed _externalToken, address _spender, uint256 _value);
25-
event ReceiveEther(address indexed _sender, uint256 _value);
2647
event MetaData(string _metaData);
2748

2849
/**
2950
* @dev enables an avatar to receive ethers
3051
*/
3152
function() external payable {
32-
emit ReceiveEther(msg.sender, msg.value);
53+
if (msg.sender != address(vault)) {
54+
// solhint-disable-next-line avoid-call-value
55+
(bool success, ) = address(vault).call.value(msg.value)("");
56+
require(success, "sendEther failed.");
57+
}
3358
}
3459

3560
/**
@@ -46,6 +71,8 @@ contract Avatar is Initializable, Ownable {
4671
nativeToken = _nativeToken;
4772
nativeReputation = _nativeReputation;
4873
Ownable.initialize(_owner);
74+
vault = new Vault();
75+
vault.initialize(address(this));
4976
}
5077

5178
/**
@@ -60,7 +87,10 @@ contract Avatar is Initializable, Ownable {
6087
external
6188
onlyOwner
6289
returns(bool success, bytes memory returnValue) {
63-
// solhint-disable-next-line avoid-call-value
90+
if (_value > 0) {
91+
vault.sendEther(_value, address(this));
92+
}
93+
// solhint-disable-next-line avoid-call-value
6494
(success, returnValue) = _contract.call.value(_value)(_data);
6595
emit GenericCall(_contract, _data, _value, success);
6696
}
@@ -72,7 +102,7 @@ contract Avatar is Initializable, Ownable {
72102
* @return bool which represents success
73103
*/
74104
function sendEther(uint256 _amountInWei, address payable _to) external onlyOwner returns(bool) {
75-
_to.transfer(_amountInWei);
105+
vault.sendEther(_amountInWei, _to);
76106
emit SendEther(_amountInWei, _to);
77107
return true;
78108
}

contracts/controller/Controller.sol

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

33
import "./Avatar.sol";
44
import "../globalConstraints/GlobalConstraintInterface.sol";

contracts/controller/DAOToken.sol

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

33
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Burnable.sol";
44
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";

contracts/globalConstraints/GlobalConstraintInterface.sol

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

33

44
contract GlobalConstraintInterface {

contracts/globalConstraints/TokenCapGC.sol

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

33
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";
44
import "./GlobalConstraintInterface.sol";

contracts/libs/SafeERC20.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ REFERENCE & RELATED READING
1212
- https://gist.github.com/BrendanChou/88a2eeb80947ff00bcf58ffdafeaeb61
1313
1414
*/
15-
pragma solidity ^0.5.13;
15+
pragma solidity ^0.5.16;
1616

1717
import "@openzeppelin/contracts-ethereum-package/contracts/utils/Address.sol";
1818
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/IERC20.sol";

contracts/schemes/Agreement.sol

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

33
/**
44
* @title A scheme for conduct ERC20 Tokens auction for reputation

contracts/schemes/Auction4Reputation.sol

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

33
import "@openzeppelin/contracts-ethereum-package/contracts/math/SafeMath.sol";
44
import "../controller/Controller.sol";

0 commit comments

Comments
 (0)