Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add zero-address checks to Ticket and ControlledToken #306

Merged
merged 2 commits into from
Jul 12, 2021
Merged
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
1 change: 1 addition & 0 deletions contracts/token/ControlledToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ contract ControlledToken is ERC20PermitUpgradeable, ControlledTokenInterface {
virtual
initializer
{
require(address(_controller) != address(0), "ControlledToken/controller-not-zero");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the isContract helper from Open Zeppelin and add some unit tests. Same remark for Ticket.
https://docs.openzeppelin.com/contracts/2.x/api/utils#Address-isContract-address-

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isContract is expensive and doesn't offer much better protection than a simple non-zero check

__ERC20_init(_name, _symbol);
__ERC20Permit_init("PoolTogether ControlledToken");
controller = _controller;
Expand Down
2 changes: 1 addition & 1 deletion contracts/token/Ticket.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ contract Ticket is ControlledToken, TicketInterface {
override
initializer
{
require(address(_controller) != address(0), "Ticket/controller-not-zero");
ControlledToken.initialize(_name, _symbol, _decimals, _controller);
sortitionSumTrees.createTree(TREE_KEY, MAX_TREE_LEAVES);

emit Initialized(
_name,
_symbol,
Expand Down