Add getContributorById

Similiar to directly accessing the contributors mapping this method also
returns the balance of the contributor.
This commit is contained in:
2018-04-07 20:10:55 +02:00
parent 7d52161014
commit baa26a85bb
2 changed files with 16 additions and 1 deletions

View File

@@ -1,5 +1,7 @@
pragma solidity ^0.4.18;
// import basic ERC20 details to be able to call balanceOf
import 'zeppelin-solidity/contracts/token/ERC20/ERC20Basic.sol';
import './upgradeable/Upgradeable.sol';
contract Contributors is Upgradeable {
@@ -105,4 +107,17 @@ contract Contributors is Upgradeable {
uint id = contributorIds[_address];
return contributors[id];
}
function getContributorById(uint _id) view returns (address account, bytes32 profileHash, uint8 hashFunction, uint8 hashSize, bool isCore, bool exists, uint balance ) {
Contributor c = contributors[_id];
account = c.account;
profileHash = c.profileHash;
hashFunction = c.hashFunction;
hashSize = c.hashSize;
isCore = c.isCore;
exists = c.exists;
ERC20Basic token = ERC20Basic(registry.getProxyFor('Token'));
balance = token.balanceOf(account);
}
}