Skip to content

Commit e1ff546

Browse files
committed
Added check for builder fee redeemed
1 parent cd3032a commit e1ff546

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

contracts/HouseformManager.sol

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ contract HouseformManager is Ownable, ReentrancyGuard {
2929
Project[] public projects;
3030
// The mapping from builder to projects to easily retrieve them
3131
mapping(address => uint[]) public builderToProjects;
32+
// Used to check if builder fee has been already redeemed
33+
mapping(uint => bool) public projectToFeeRedeemed;
3234

3335
event ProjectCreated(
3436
uint _projectId,
@@ -259,6 +261,8 @@ contract HouseformManager is Ownable, ReentrancyGuard {
259261
) external projectExists(_projectId) onlyBuilder(_projectId) buildingCompleted(_projectId) nonReentrant {
260262
Project storage project = projects[_projectId];
261263

264+
// Check fee not redeemed yet
265+
require(!projectToFeeRedeemed[_projectId], 'Builder fee already redeemed');
262266
// Require that there was a profit otherwise nothing goes to the builder
263267
require(project.saleAmount - project.goalAmount > 0, 'No profit no party');
264268

@@ -273,6 +277,8 @@ contract HouseformManager is Ownable, ReentrancyGuard {
273277

274278
// Update data
275279
project.currentAmount -= amountToRedeem;
280+
// Save that fee has been redeemed to avoid doing it multiple times
281+
projectToFeeRedeemed[_projectId] = true;
276282

277283
// Emit event
278284
emit FeeRedeemed(msg.sender, _projectId, amountToRedeem);

0 commit comments

Comments
 (0)