more re-entrancy protections, fixed small bug

This commit is contained in:
mbeylin 2017-10-06 13:52:47 -04:00
parent 8a5ea978af
commit 237d32359d
1 changed files with 13 additions and 10 deletions

View File

@ -382,7 +382,7 @@ contract StandardBounties {
bounties[_bountyId].balance -= bounties[_bountyId].fulfillmentAmount;
if (bounties[_bountyId].paysTokens){
tokenContracts[_bountyId].transfer(fulfillments[_bountyId][_fulfillmentId].fulfiller, bounties[_bountyId].fulfillmentAmount);
require(tokenContracts[_bountyId].transfer(fulfillments[_bountyId][_fulfillmentId].fulfiller, bounties[_bountyId].fulfillmentAmount));
} else {
fulfillments[_bountyId][_fulfillmentId].fulfiller.transfer(bounties[_bountyId].fulfillmentAmount);
}
@ -401,12 +401,13 @@ contract StandardBounties {
transitionToState(_bountyId, BountyStages.Dead);
uint difference = bounties[_bountyId].balance - bounties[_bountyId].owedAmount;
bounties[_bountyId].balance = bounties[_bountyId].owedAmount;
if (difference != 0){
if (bounties[_bountyId].paysTokens){
tokenContracts[_bountyId].transfer(bounties[_bountyId].issuer, difference);
require(tokenContracts[_bountyId].transfer(bounties[_bountyId].issuer, difference));
} else {
bounties[_bountyId].issuer.transfer(difference);
}
}
BountyKilled(_bountyId);
}
@ -507,17 +508,19 @@ contract StandardBounties {
onlyIssuer(_bountyId)
isAtStage(_bountyId, BountyStages.Draft)
{
HumanStandardToken oldToken = tokenContracts[_bountyId];
bool oldPaysTokens = bounties[_bountyId].paysTokens;
bounties[_bountyId].paysTokens = _newPaysTokens;
tokenContracts[_bountyId] = HumanStandardToken(_newTokenContract);
if (bounties[_bountyId].balance > 0){
uint oldBalance = bounties[_bountyId].balance;
bounties[_bountyId].balance = 0;
if (bounties[_bountyId].paysTokens){
require(tokenContracts[_bountyId].transfer(bounties[_bountyId].issuer, oldBalance));
if (oldPaysTokens){
require(oldToken.transfer(bounties[_bountyId].issuer, oldBalance));
} else {
bounties[_bountyId].issuer.transfer(oldBalance);
}
}
bounties[_bountyId].paysTokens = _newPaysTokens;
tokenContracts[_bountyId] = HumanStandardToken(_newTokenContract);
BountyChanged(_bountyId);
}