CORIONplatform / solidity

GNU General Public License v3.0
12 stars 9 forks source link

Using booleans to denote Ether/Token operation is an anti-pattern #81

Open pyskell opened 7 years ago

pyskell commented 7 years ago

In the contract code there are places such as the following:

function sell(bool token, uint256 value, bool instant, uint256 rate) external{} // exchange.sol
function payout(uint256 amount, bool eth) external {} // exchange.sol

In the first case token is true for Tokens and false for Ether, in the second case eth is true for Ether and false for Tokens. This will likely lead to mixups between the two when people are interacting with the contract.

Use an enum such as enum CoinType {token, ether} instead to keep the arguments consistent and apparent to anyone using the contract.

iFA88 commented 7 years ago

Exchange is under development, but thank you for reporting!