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

Updates: 0 address transfer prevention and emit keyword #135

Closed
wants to merge 9 commits into from
Closed
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
4 changes: 2 additions & 2 deletions contracts/eip20/EIP20Factory.sol
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./EIP20.sol"; import "./SafeEIP20.sol";


pragma solidity ^0.4.21; pragma solidity ^0.4.21;


Expand Down Expand Up @@ -37,7 +37,7 @@ contract EIP20Factory {
public public
returns (address) { returns (address) {


EIP20 newToken = (new EIP20(_initialAmount, _name, _decimals, _symbol)); SafeEIP20 newToken = (new SafeEIP20(_initialAmount, _name, _decimals, _symbol));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we want to undo this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skmgoldin I had the impression that we were going to revert the factory back to EIP20.

Copy link

@Muhammad-Altabba Muhammad-Altabba Oct 23, 2018

Choose a reason for hiding this comment

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

Since we all agree that: it is part of the best practices to prevent transferring to 0x0 and the contract-address, why not apply this best practice every where? In other words, what is the harm of using the SafeEIP20 in the factory?
(The link to the best-practices I am referring: https://github.com/ConsenSys/smart-contract-best-practices/blob/master/docs/tokens.md).
Thanks,

created[msg.sender].push(address(newToken)); created[msg.sender].push(address(newToken));
isEIP20[address(newToken)] = true; isEIP20[address(newToken)] = true;
//the factory will own the created tokens. You must transfer them. //the factory will own the created tokens. You must transfer them.
Expand Down
38 changes: 38 additions & 0 deletions contracts/eip20/SafeEIP20.sol
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Implements EIP20 token that prevent transferring to the 0x0 address, and the contract address, according to Token Implementation Best Practices.
Reference: https://consensys.github.io/smart-contract-best-practices/tokens/
.*/


pragma solidity ^0.4.18;

import "./EIP20.sol";


contract SafeEIP20 is EIP20 {

modifier validDestination(address _to) {
require(_to != address(0x0)); // If the user did not enter a value for _to, it will equal to "zero"
require(_to != address(this)); // address(this) is the Contract Address
_;
}

function SafeEIP20(
uint256 _initialAmount,
string _tokenName,
uint8 _decimalUnits,
string _tokenSymbol
)
public
EIP20(_initialAmount, _tokenName, _decimalUnits, _tokenSymbol)
{
}

function transfer(address _to, uint256 _value) public validDestination(_to) returns (bool success) {
return super.transfer(_to, _value);
}

function transferFrom(address _from, address _to, uint256 _value) public validDestination(_to) returns (bool success) {
return super.transferFrom(_from, _to, _value);
}
}
Loading