-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add unused import pass #3
base: main
Are you sure you want to change the base?
Conversation
# @dev Implementation of ERC-20 token standard. | ||
# @author Takayuki Jimba (@yudetamago) | ||
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep only relevant code in those examples, as you did everywhere else. Starting by all those comments, and I'll suggest other removals.
# @dev Implementation of ERC-20 token standard. | |
# @author Takayuki Jimba (@yudetamago) | |
# https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is from vyper's examples so I prefer leaving it as it is.
|
||
|
||
@external | ||
def mint(_to: address, _value: uint256): | ||
""" | ||
@dev Mint an amount of the token and assigns it to an account. | ||
This encapsulates the modification of balances such that the | ||
proper events are emitted. | ||
@param _to The account that will receive the created tokens. | ||
@param _value The amount that will be created. | ||
""" | ||
assert msg.sender == self.minter | ||
assert _to != empty(address) | ||
self.totalSupply += _value | ||
self.balanceOf[_to] += _value | ||
log Transfer(empty(address), _to, _value) | ||
|
||
|
||
@internal | ||
def _burn(_to: address, _value: uint256): | ||
""" | ||
@dev Internal function that burns an amount of the token of a given | ||
account. | ||
@param _to The account whose tokens will be burned. | ||
@param _value The amount that will be burned. | ||
""" | ||
assert _to != empty(address) | ||
self.totalSupply -= _value | ||
self.balanceOf[_to] -= _value | ||
log Transfer(_to, empty(address), _value) | ||
|
||
|
||
@external | ||
def burn(_value: uint256): | ||
""" | ||
@dev Burn an amount of the token of msg.sender. | ||
@param _value The amount that will be burned. | ||
""" | ||
self._burn(msg.sender, _value) | ||
|
||
|
||
@external | ||
def burnFrom(_to: address, _value: uint256): | ||
""" | ||
@dev Burn an amount of the token from a given account. | ||
@param _to The account whose tokens will be burned. | ||
@param _value The amount that will be burned. | ||
""" | ||
self.allowance[_to][msg.sender] -= _value | ||
self._burn(_to, _value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@external | |
def mint(_to: address, _value: uint256): | |
""" | |
@dev Mint an amount of the token and assigns it to an account. | |
This encapsulates the modification of balances such that the | |
proper events are emitted. | |
@param _to The account that will receive the created tokens. | |
@param _value The amount that will be created. | |
""" | |
assert msg.sender == self.minter | |
assert _to != empty(address) | |
self.totalSupply += _value | |
self.balanceOf[_to] += _value | |
log Transfer(empty(address), _to, _value) | |
@internal | |
def _burn(_to: address, _value: uint256): | |
""" | |
@dev Internal function that burns an amount of the token of a given | |
account. | |
@param _to The account whose tokens will be burned. | |
@param _value The amount that will be burned. | |
""" | |
assert _to != empty(address) | |
self.totalSupply -= _value | |
self.balanceOf[_to] -= _value | |
log Transfer(_to, empty(address), _value) | |
@external | |
def burn(_value: uint256): | |
""" | |
@dev Burn an amount of the token of msg.sender. | |
@param _value The amount that will be burned. | |
""" | |
self._burn(msg.sender, _value) | |
@external | |
def burnFrom(_to: address, _value: uint256): | |
""" | |
@dev Burn an amount of the token from a given account. | |
@param _to The account whose tokens will be burned. | |
@param _value The amount that will be burned. | |
""" | |
self.allowance[_to][msg.sender] -= _value | |
self._burn(_to, _value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above.
# Check for `implements` | ||
is_implemented = ( | ||
len( | ||
ast.get_descendants( | ||
vy_ast.AnnAssign, | ||
{"target.id": "implements", "annotation.id": interface_name}, | ||
) | ||
) | ||
> 0 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the "implements: interface" check (+ a more pythonic way of checking for a non empty list):
# Check for `implements` | |
is_implemented = ( | |
len( | |
ast.get_descendants( | |
vy_ast.AnnAssign, | |
{"target.id": "implements", "annotation.id": interface_name}, | |
) | |
) | |
> 0 | |
) | |
# Check for `implements` | |
is_implemented = bool( | |
ast.get_descendants(vy_ast.nodes.ImplementsDecl, {"annotation.id": interface_name}) | |
) |
) | ||
|
||
# Check for usage as `Interface(address).function()` | ||
is_used = len(ast.get_descendants(vy_ast.Call, {"func.id": interface_name})) > 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_used = len(ast.get_descendants(vy_ast.Call, {"func.id": interface_name})) > 0 | |
is_used = bool(ast.get_descendants(vy_ast.Call, {"func.id": interface_name})) |
I'll have a second patch to improve performances in all analysis files, but will open a separate PR for that. |
No description provided.