Vault app #145

Closed
haythem96 wants to merge 10 commits from features/app-vault into master
Showing only changes of commit 3028718de8 - Show all commits

View File

@@ -20,10 +20,15 @@ interface IToken {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
using SafeERC20 for ERC20;
bytes32 public constant TRANSFER_ROLE = keccak256("TRANSFER_ROLE");
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
string private constant ERROR_NOT_DEPOSITABLE = "VAULT_NOT_DEPOSITABLE";
string private constant ERROR_DEPOSIT_VALUE_ZERO = "VAULT_DEPOSIT_VALUE_ZERO";
string private constant ERROR_VALUE_MISMATCH = "VAULT_VALUE_MISMATCH";
string private constant ERROR_TOKEN_TRANSFER_FROM_REVERTED = "VAULT_TOKEN_TRANSFER_FROM_REVERT";
string private constant ERROR_TRANSFER_VALUE_ZERO = "VAULT_TRANSFER_VALUE_ZERO";
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
string private constant ERROR_SEND_REVERTED = "VAULT_SEND_REVERTED";
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
string private constant ERROR_TOKEN_TRANSFER_REVERTED = "VAULT_TOKEN_TRANSFER_REVERTED";
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
uint256 private _snapshotTotalSupply;
@@ -34,6 +39,7 @@ contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
bytes32[4] public appIds;
event VaultDeposit(address indexed token, address indexed sender, uint256 amount);
event VaultTransfer(address indexed token, address indexed to, uint256 amount);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
function () external payable isInitialized {
_deposit(ETH, msg.value);
@@ -50,25 +56,18 @@ contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
setDepositable(true);
}
function getTokenContract() public view returns (address) {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
function getContract(uint8 appId) public view returns (address) {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
IKernel k = IKernel(kernel());
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
return k.getApp(KERNEL_APP_ADDR_NAMESPACE, appIds[uint8(Apps.Token)]);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
function getContributorContract() public view returns (address) {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
IKernel k = IKernel(kernel());
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
return k.getApp(KERNEL_APP_ADDR_NAMESPACE, appIds[uint8(Apps.Contributor)]);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
return k.getApp(KERNEL_APP_ADDR_NAMESPACE, appIds[appId]);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}
function getContributorAddressById(uint32 contributorId) public view returns (address) {
address contributor = getContributorContract();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
address contributor = getContract(uint8(Apps.Contributor));
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
return IContributor(contributor).getContributorAddressById(contributorId);
}
function getContributorsAddresses() internal view returns (address[]) {
address contributor = getContributorContract();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
address contributor = getContract(uint8(Apps.Contributor));
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
uint32 contributorsCount = IContributor(contributor).contributorsCount();
address[] memory contributorsAddresses = new address[](contributorsCount);
@@ -82,12 +81,12 @@ contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}
function balanceOf(address owner) public view returns (uint256) {
address token = getTokenContract();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
address token = getContract(uint8(Apps.Token));
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
return IToken(token).balanceOf(owner);
}
function totalSupply() public view returns (uint256) {
address token = getTokenContract();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
address token = getContract(uint8(Apps.Token));
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
return IToken(token).totalSupply();
}
@@ -121,35 +120,39 @@ contract Vault is EtherTokenConstant, AragonApp, DepositableStorage {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
require(_value > 0, ERROR_DEPOSIT_VALUE_ZERO);
if (_token == ETH) {
// Deposit is implicit in this case
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
require(msg.value == _value, ERROR_VALUE_MISMATCH);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
createSnapshot();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
emit VaultDeposit(_token, msg.sender, _value);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
// Deposit is implicit in this case
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
require(msg.value == _value, ERROR_VALUE_MISMATCH);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
} else {
require(
ERC20(_token).safeTransferFrom(msg.sender, address(this), _value),
ERROR_TOKEN_TRANSFER_FROM_REVERTED
);
}
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
emit VaultDeposit(_token, msg.sender, _value);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
/**
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
* @notice Transfer `_value` `_token` from the Vault to `_to`
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
* @param _token Address of the token being transferred
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
* @param _to Address of the recipient of tokens
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
* @param _value Amount of tokens being transferred
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
*/
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
/* solium-disable-next-line function-order */
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
function transfer(address _token, address _to, uint256 _value)
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
external
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
authP(TRANSFER_ROLE, arr(_token, _to, _value))
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
{
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
require(_value > 0, ERROR_TRANSFER_VALUE_ZERO);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
function createSnapshot() internal {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
updateSnapshotTotalSupply();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
updateSnapshotBalances();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
function updateSnapshotTotalSupply() internal {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
_snapshotTotalSupply = totalSupply();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
function updateSnapshotBalances() internal {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
address[] memory contributorsAddresses = getContributorsAddresses();
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
for(uint32 i = 0; i < contributorsAddresses.length; i++) {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
_snapshotBalances[contributorsAddresses[i]] = balanceOf(contributorsAddresses[i]);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
if (_token == ETH) {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
require(_to.send(_value), ERROR_SEND_REVERTED);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
} else {
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
require(ERC20(_token).safeTransfer(_to, _value), ERROR_TOKEN_TRANSFER_REVERTED);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
emit VaultTransfer(_token, _to, _value);
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}
haythem96 commented 2019-07-26 15:31:11 +00:00 (Migrated from github.com)
Review

@bumi we should burn the tokens here for the contributor that withdraw, right ?

@bumi we should burn the tokens here for the contributor that withdraw, right ?
}