Omniscia Bware Labs Audit

BwareTokenVault Code Style Findings

BwareTokenVault Code Style Findings

BTV-01C: Constants to Enum

TypeSeverityLocation
Code StyleInformationalBwareTokenVault.sol:L456-L460

Description:

The linked variables are sequentially increasing and declared as uint8.

Example:

ico/contracts/BwareTokenVault.sol
456// Configuration groups for existing unlocking strategies
457uint8 public constant _team_ = 1;
458uint8 public constant _advisors_ = 2;
459uint8 public constant _investors_ = 3;
460uint8 public constant _others_ = 4;

Recommendation:

They can be declared as a single enum in a more intuitive and readable manner which we advise to be done so.

Alleviation:

The constants were properly replaced by a LockingGroups enum greatly increasing the legibility of the codebase.

BTV-02C: Inefficient Evaluation of isContract

TypeSeverityLocation
Gas OptimizationInformationalBwareTokenVault.sol:L210-L219

Description:

The isContract evaluation used by the contract was deemed inefficient by OpenZeppelin in PR#2311.

Example:

ico/contracts/BwareTokenVault.sol
210function isContract(address account) internal view returns (bool) {
211 // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
212 // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
213 // for accounts without code, i.e. `keccak256('')`
214 bytes32 codehash;
215 bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
216 // solhint-disable-next-line no-inline-assembly
217 assembly { codehash := extcodehash(account) }
218 return (codehash != accountHash && codehash != 0x0);
219}

Recommendation:

We advise that the original implementation using extcodesize is utilized here instead.

Alleviation:

The original implementation was indeed set to the codebase.