From d9540bb1b0ecd1a9b4ffad3e44bbb442639ffc7e Mon Sep 17 00:00:00 2001 From: Haythem Sellami Date: Tue, 9 Jul 2019 22:42:29 +0100 Subject: [PATCH] get contributor & token contract; contributor&token interface --- apps/vault/contracts/Vault.sol | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/apps/vault/contracts/Vault.sol b/apps/vault/contracts/Vault.sol index 2f61b0c..1b7b91f 100644 --- a/apps/vault/contracts/Vault.sol +++ b/apps/vault/contracts/Vault.sol @@ -1,11 +1,19 @@ pragma solidity ^0.4.24; import "@aragon/os/contracts/apps/AragonApp.sol"; +import "@aragon/os/contracts/kernel/IKernel.sol"; import "@aragon/os/contracts/common/DepositableStorage.sol"; import "@aragon/os/contracts/common/EtherTokenConstant.sol"; import "@aragon/os/contracts/common/SafeERC20.sol"; import "@aragon/os/contracts/lib/token/ERC20.sol"; +interface IContributor { +} + +interface IToken { + function balanceOf(address owner) public view returns (uint256); +} + contract Vault is EtherTokenConstant, AragonApp, DepositableStorage { using SafeERC20 for ERC20; @@ -14,6 +22,14 @@ contract Vault is EtherTokenConstant, AragonApp, DepositableStorage { string private constant ERROR_VALUE_MISMATCH = "VAULT_VALUE_MISMATCH"; string private constant ERROR_TOKEN_TRANSFER_FROM_REVERTED = "VAULT_TOKEN_TRANSFER_FROM_REVERT"; + uint256 private _snapshotTotalSupply; + + mapping (address => uint256) private _snapshotBalances; + + // ensure alphabetic order + enum Apps { Contribution, Contributor, Proposal, Token } + bytes32[4] public appIds; + event VaultDeposit(address indexed token, address indexed sender, uint256 amount); function () external payable isInitialized { @@ -24,11 +40,25 @@ contract Vault is EtherTokenConstant, AragonApp, DepositableStorage { * @notice Initialize Vault app * @dev As an AragonApp it needs to be initialized in order for roles (`auth` and `authP`) to work */ - function initialize() external onlyInit { + function initialize(bytes32[4] _appIds) external onlyInit { initialized(); + + appIds = _appIds; setDepositable(true); } + function getTokenContract() public view returns (address) { + IKernel k = IKernel(kernel()); + + return k.getApp(KERNEL_APP_ADDR_NAMESPACE, appIds[uint8(Apps.Token)]); + } + + function getContributorContract() public view returns (address) { + IKernel k = IKernel(kernel()); + + return k.getApp(KERNEL_APP_ADDR_NAMESPACE, appIds[uint8(Apps.Contributor)]); + } + /** * @notice Deposit `_value` `_token` to the vault * @param _token Address of the token being transferred