Skip to content

Commit

Permalink
address security warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Diemand <codieplusplus@apax.net>
  • Loading branch information
CodiePP committed Nov 18, 2024
1 parent 56bec71 commit ddab1ed
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
20 changes: 10 additions & 10 deletions bca-token-solidity/contracts/BCA_ERC20_nf.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ contract BCAServiceToken is ERC20, AccessControl {

/**
* @dev Constructor that sets up roles and gives the deployer the default admin role.
* @param name The name of the token.
* @param symbol The symbol of the token.
* @param minter The address that will be granted the minter role.
* @param burner The address that will be granted the burner role.
* @param setName The name of the token.
* @param setSymbol The symbol of the token.
* @param setMinter The address that will be granted the minter role.
* @param setBurner The address that will be granted the burner role.
*/
constructor(string memory name, string memory symbol, address minter, address burner)
ERC20(name, symbol)
constructor(string memory setName, string memory setSymbol, address setMinter, address setBurner)
ERC20(setName, setSymbol)
{
serviceAddress = msg.sender;
minterAddress = minter;
burnerAddress = burner;
minterAddress = setMinter;
burnerAddress = setBurner;
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(MINTER_ROLE, minter);
_grantRole(BURNER_ROLE, burner);
_grantRole(MINTER_ROLE, setMinter);
_grantRole(BURNER_ROLE, setBurner);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion bca-token-solidity/contracts/BCA_Funding24.sol
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ contract BCAServiceFunding24 is IFunding24, Ownable {
"Insufficient allowance from owner"
);

// set new state
lastDepositTime = block.timestamp;

// Transfer tokens from owner to this contract
token.safeTransferFrom(owner(), address(this), dailyAmount);

// Set allowance for the target contract
token.approve(targetContract, dailyAmount);

try IServiceInstance(targetContract).makeDeposit(dailyAmount) {
lastDepositTime = block.timestamp;
emit DepositMade(targetContract, dailyAmount, block.timestamp);
} catch Error(string memory reason) {
revert(reason);
Expand Down
18 changes: 14 additions & 4 deletions bca-token-solidity/contracts/BCA_ServiceInstance.sol
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,14 @@ contract BCAServiceInstance is IServiceInstance, ReentrancyGuard {
revert InsufficientBalance(balance);
}

tokToken.transfer(msg.sender, amount);
// set new state
deposit -= amount;
emit Withdrawn(msg.sender, amount);

if (tokToken.transfer(msg.sender, amount)) {
emit Withdrawn(msg.sender, amount);
} else {
revert("transfer failed");
}

// stop service?
if (balance - amount <= dayPrice / 24 / 3600) {
Expand All @@ -153,8 +158,13 @@ contract BCAServiceInstance is IServiceInstance, ReentrancyGuard {
_stop(msg.sender);
}

tokToken.transfer(msg.sender, amount);
// set new state
retracted += amount;
emit Retracted(msg.sender, amount);

if (tokToken.transfer(msg.sender, amount)) {
emit Retracted(msg.sender, amount);
} else {
revert("transfer failed");
}
}
}

0 comments on commit ddab1ed

Please sign in to comment.