Use uint32 for kreditsWithdrawn
Same as the properties and functions in the Contribution contract
This commit is contained in:
parent
e99184b83f
commit
5da710cc14
@ -22,7 +22,7 @@ contract Contributor is Initializable {
|
||||
uint8 hashFunction;
|
||||
uint8 hashSize;
|
||||
bool exists;
|
||||
uint256 kreditsWithdrawn;
|
||||
uint32 kreditsWithdrawn;
|
||||
}
|
||||
|
||||
mapping (address => uint32) public contributorIds;
|
||||
@ -160,8 +160,8 @@ contract Contributor is Initializable {
|
||||
Contributor storage c = contributors[id];
|
||||
|
||||
// TODO check if we need a failsafe for unconfirmed or malicious txs
|
||||
uint256 confirmedKredits = contributionContract.totalKreditsEarnedByContributor(id, true);
|
||||
uint256 amountWithdrawable = confirmedKredits - c.kreditsWithdrawn;
|
||||
uint32 confirmedKredits = contributionContract.totalKreditsEarnedByContributor(id, true);
|
||||
uint32 amountWithdrawable = confirmedKredits - c.kreditsWithdrawn;
|
||||
require (amountWithdrawable > 0, "No kredits available");
|
||||
|
||||
c.kreditsWithdrawn += amountWithdrawable;
|
||||
|
@ -95,10 +95,8 @@ describe("Contributor contract", async function () {
|
||||
expect(c['balance']).to.equal(0);
|
||||
await Contributor.connect(addr1).withdraw();
|
||||
c = await Contributor.getContributorById(2);
|
||||
// TODO Are we required to use Wei for ERC20 tokens?
|
||||
expect(c['balance'].toString()).to.equal("6500000000000000000000");
|
||||
// FIXME This is also a BigNumber (uint256), but stored at Wei reolution
|
||||
expect(c['kreditsWithdrawn'].toString()).to.equal('6500');
|
||||
expect(c['kreditsWithdrawn']).to.equal(6500);
|
||||
});
|
||||
|
||||
it("requires the withdrawable amount to be larger than 0", async function () {
|
||||
|
Loading…
x
Reference in New Issue
Block a user