Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# HR_Project_Web3Bridge
# PayTroix_Project_Web3Bridge

This repository contains the smart contracts and related scripts for the HR_Project_Web3Bridge, a blockchain-based solution for managing organizations and contracts. The project leverages [Foundry](https://book.getfoundry.sh/) for development, testing, and deployment of Solidity smart contracts.

Expand Down
9 changes: 9 additions & 0 deletions src/contracts/OrganizationContract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ contract OrganizationContract {
uint256 repaidAmount = recipient.advanceCollected;
recipient.advanceCollected = 0;
delete advanceRequests[_recipient];
advanceRequests[_recipient].repaid = true;
emit AdvanceRepaid(_recipient, repaidAmount);
}

Expand Down Expand Up @@ -262,6 +263,7 @@ contract OrganizationContract {
returns (bool)
{
_onlyOwner();
if (_recipients.length == 0 || _netAmounts.length == 0) revert CustomErrors.InvalidInput();
if (_recipients.length != _netAmounts.length) revert CustomErrors.InvalidInput();
if (_tokenAddress == address(0)) revert CustomErrors.InvalidAddress();
if (!isTokenSupported(_tokenAddress)) revert CustomErrors.TokenNotSupported();
Expand Down Expand Up @@ -360,6 +362,8 @@ contract OrganizationContract {
Structs.Recipient storage recipient = recipients[_address];
recipient.name = _name;
recipient.updatedAt = block.timestamp;

emit RecipientUpdated(recipient.recipientId, _address, _name);
}

/**
Expand Down Expand Up @@ -409,6 +413,7 @@ contract OrganizationContract {
*/
function setDefaultAdvanceLimit(uint256 _limit) public {
_onlyOwner();
if (_limit > type(uint256).max / 2) revert CustomErrors.InvalidAmount();
defaultAdvanceLimit = _limit;
emit DefaultAdvanceLimitSet(_limit);
}
Expand All @@ -422,6 +427,10 @@ contract OrganizationContract {
_onlyOwner();
if (_recipient == address(0)) revert CustomErrors.InvalidAddress();
if (recipients[_recipient].recipientId == 0) revert CustomErrors.RecipientNotFound();

// Check if limit exceeds salary
if (_limit >= recipients[_recipient].salaryAmount) revert CustomErrors.InvalidAmount();

recipientAdvanceLimit[_recipient] = _limit;
emit AdvanceLimitSet(_recipient, _limit);
}
Expand Down
Loading