refactor HasNoTokens.sol to extract reclaimToken#348
Merged
frangio merged 2 commits intoOpenZeppelin:masterfrom Aug 24, 2017
Merged
refactor HasNoTokens.sol to extract reclaimToken#348frangio merged 2 commits intoOpenZeppelin:masterfrom
frangio merged 2 commits intoOpenZeppelin:masterfrom
Conversation
Contributor
|
Love this, but I'm not 100% convinced with the name |
frangio
requested changes
Aug 9, 2017
Contributor
frangio
left a comment
There was a problem hiding this comment.
Great idea!
I agree the name is not ideal, but we can keep it if we have nothing better.
| * @param tokenAddr address The address of the token contract | ||
| */ | ||
| function reclaimToken(address tokenAddr) external onlyOwner { | ||
| ERC20Basic tokenInst = ERC20Basic(tokenAddr); |
Contributor
There was a problem hiding this comment.
You can avoid this cast by defining the function to take an ERC20Basic instance: reclaimToken(ERC20Basic token). (I also think token is a better variable name than tokenInst.)
| let token = null; | ||
| let canReclaimToken = null; | ||
|
|
||
| beforeEach(async () => { |
Contributor
There was a problem hiding this comment.
Please use a function expression instead of an arrow function here. (See https://mochajs.org/#arrow-functions)
Contributor
Author
|
The cast was already there. Didn't touch the code.
This is not used in the test.
Le mer. 9 août 2017 18:40, Francisco Giordano <notifications@github.com> a
écrit :
… ***@***.**** requested changes on this pull request.
Great idea!
I agree the name is not ideal, but we can keep it if we have nothing
better.
------------------------------
In contracts/ownership/CanReclaimToken.sol
<#348 (comment)>
:
> +import "../token/ERC20Basic.sol";
+
+/**
+ * @title Contracts that should be able to recover tokens
+ * @author SylTi
+ * @dev This allow a contract to recover any ERC20 token received in a contract by transfering the balance to the contract owner.
+ * This will prevent any accidental loss of tokens.
+ */
+contract CanReclaimToken is Ownable {
+
+ /**
+ * @dev Reclaim all ERC20Basic compatible tokens
+ * @param tokenAddr address The address of the token contract
+ */
+ function reclaimToken(address tokenAddr) external onlyOwner {
+ ERC20Basic tokenInst = ERC20Basic(tokenAddr);
You can avoid this cast by defining the function to take an ERC20Basic
instance: reclaimToken(ERC20Basic token). (I also think token is a better
variable name than tokenInst.)
------------------------------
In test/CanReclaimToken.js
<#348 (comment)>
:
> @@ -0,0 +1,35 @@
+'use strict';
+import expectThrow from './helpers/expectThrow';
+import toPromise from './helpers/toPromise';
+const CanReclaimToken = artifacts.require('../contracts/ownership/CanReclaimToken.sol');
+const BasicTokenMock = artifacts.require("./helpers/BasicTokenMock.sol");
+
+contract('CanReclaimToken', function(accounts) {
+ let token = null;
+ let canReclaimToken = null;
+
+ beforeEach(async () => {
Please use a function expression instead of an arrow function here. (See
https://mochajs.org/#arrow-functions)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#348 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABsFfNHCepZiUg_kk1RX0ESgCFGmcocCks5sWeD9gaJpZM4OsULr>
.
|
ea7839f to
51906ba
Compare
frangio
approved these changes
Aug 24, 2017
Contributor
|
Merging this but it may be superceded by the more general |
ProphetDaniel
pushed a commit
to classicdelta/Smart-Contracts
that referenced
this pull request
Mar 9, 2018
refactor HasNoTokens.sol to extract reclaimToken
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By splitting reclaimToken of HasNoTokens.sol, it can be used on a contract that can receive a specific type of token, or receive them only a certain way (through transferFrom for example) but want to be able to reclaim all others. inheriting from a HasNoTokens on that type of contract seems counter-intuitive?