Skip to content

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

@pyskell

Description

@pyskell

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions