Skip to content

transferAll and transferAllFrom#187

Merged
aalavandhan merged 5 commits intomasterfrom
transfer-all
Feb 3, 2021
Merged

transferAll and transferAllFrom#187
aalavandhan merged 5 commits intomasterfrom
transfer-all

Conversation

@aalavandhan
Copy link
Copy Markdown
Member

@aalavandhan aalavandhan commented Jan 12, 2021

Fixes #184

Added transferAll and transferAllFrom to the token

Copy link
Copy Markdown
Member

@brandoniles brandoniles left a comment

Choose a reason for hiding this comment

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

LGTM

transferAllFrom... yea or nay?

* @param to The address to transfer to.
* @return True on success, false otherwise.
*/
function transferAll(address to) public validRecipient(to) returns (bool) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

public -> external?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👍


uint256 gonValue = _gonBalances[msg.sender];
uint256 value = gonValue.div(_gonsPerFragment);
_gonBalances[msg.sender] = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if it's better to delete _gonBalances[msg.sender] instead. Any differences on storage?

Thinking both short term, like cost of operation, and long term, like in the case of storage rent. I assume they're the same...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

👍

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

They are the same.

@aalavandhan aalavandhan changed the title added transfer all method to token transferAll and transferAllFrom Jan 15, 2021

_allowedFragments[from][msg.sender] = _allowedFragments[from][msg.sender].sub(value);

_gonBalances[from] = _gonBalances[from].sub(gonValue);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To keep consistent with transferAll, delete _gonBalances[msg.sender]; ?

Copy link
Copy Markdown
Member Author

@aalavandhan aalavandhan Jan 15, 2021

Choose a reason for hiding this comment

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

delete _gonBalances[from]

Right! 👍

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah right. You're version's much better :)

@aalavandhan
Copy link
Copy Markdown
Member Author

will wait for @ahnaguib to review this one too

Copy link
Copy Markdown
Member

@brandoniles brandoniles left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Ahmed Naguib Aly <[email protected]>
Copy link
Copy Markdown
Contributor

@ahnaguib ahnaguib left a comment

Choose a reason for hiding this comment

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

LGTM

@aalavandhan aalavandhan merged commit ed86918 into master Feb 3, 2021
@aalavandhan aalavandhan deleted the transfer-all branch February 3, 2021 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a transferAll function

3 participants