Add balances to getContributorById call
This commit is contained in:
parent
59135bf312
commit
c248725cc1
@ -6,6 +6,10 @@ import "@aragon/os/contracts/kernel/IKernel.sol";
|
|||||||
interface ITokenBalance {
|
interface ITokenBalance {
|
||||||
function balanceOf(address contributorAccount) public view returns (uint256);
|
function balanceOf(address contributorAccount) public view returns (uint256);
|
||||||
}
|
}
|
||||||
|
interface IContributionBalance {
|
||||||
|
function contributorTotalCount(uint32 contributorId, bool confirmedOnly) public view returns (uint256 count);
|
||||||
|
function balanceOf(address owner) public view returns (uint256);
|
||||||
|
}
|
||||||
|
|
||||||
contract Contributor is AragonApp {
|
contract Contributor is AragonApp {
|
||||||
bytes32 public constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;
|
bytes32 public constant KERNEL_APP_ADDR_NAMESPACE = 0xd6f028ca0e8edb4a8c9757ca4fdccab25fa1e0317da1188108f7d2dee14902fb;
|
||||||
@ -43,6 +47,12 @@ contract Contributor is AragonApp {
|
|||||||
return k.getApp(KERNEL_APP_ADDR_NAMESPACE, appIds[uint8(Apps.Token)]);
|
return k.getApp(KERNEL_APP_ADDR_NAMESPACE, appIds[uint8(Apps.Token)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getContributionContract() public view returns (address) {
|
||||||
|
IKernel k = IKernel(kernel());
|
||||||
|
|
||||||
|
return k.getApp(KERNEL_APP_ADDR_NAMESPACE, appIds[uint8(Apps.Contribution)]);
|
||||||
|
}
|
||||||
|
|
||||||
function coreContributorsCount() view public returns (uint32) {
|
function coreContributorsCount() view public returns (uint32) {
|
||||||
uint32 count = 0;
|
uint32 count = 0;
|
||||||
for (uint32 i = 1; i <= contributorsCount; i++) {
|
for (uint32 i = 1; i <= contributorsCount; i++) {
|
||||||
@ -118,7 +128,7 @@ contract Contributor is AragonApp {
|
|||||||
return contributors[id];
|
return contributors[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getContributorById(uint32 _id) public view returns (uint32 id, address account, bytes32 hashDigest, uint8 hashFunction, uint8 hashSize, bool isCore, uint256 balance, bool exists ) {
|
function getContributorById(uint32 _id) public view returns (uint32 id, address account, bytes32 hashDigest, uint8 hashFunction, uint8 hashSize, bool isCore, uint256 balance, uint256 contributionBalance, uint256 contributionsCount, bool exists ) {
|
||||||
id = _id;
|
id = _id;
|
||||||
Contributor storage c = contributors[_id];
|
Contributor storage c = contributors[_id];
|
||||||
account = c.account;
|
account = c.account;
|
||||||
@ -128,6 +138,9 @@ contract Contributor is AragonApp {
|
|||||||
isCore = isCoreTeam(id);
|
isCore = isCoreTeam(id);
|
||||||
address token = getTokenContract();
|
address token = getTokenContract();
|
||||||
balance = ITokenBalance(token).balanceOf(c.account);
|
balance = ITokenBalance(token).balanceOf(c.account);
|
||||||
|
address contribution = getContributionContract();
|
||||||
|
contributionBalance = IContributionBalance(contribution).contributorTotalCount(_id, true);
|
||||||
|
contributionsCount = IContributionBalance(contribution).balanceOf(c.account);
|
||||||
exists = c.exists;
|
exists = c.exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user