-
-
Notifications
You must be signed in to change notification settings - Fork 836
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat[ux]: improve hint for events kwarg upgrade (#4275)
follow-on commit to ebe3c0c. the hint in ebe3c0c is not specific to the user's source code, and it's a bit laborious for the user to match the call-site to the event def. this commit auto-generates the new call expression for the user to use. additionally, it migrates the example contracts in the `examples/` directory so that they stop emitting warnings. --------- Co-authored-by: cyberthirst <[email protected]>
- Loading branch information
1 parent
c75a2da
commit bb45f50
Showing
9 changed files
with
91 additions
and
43 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import warnings | ||
|
||
from vyper.compiler import compile_code | ||
|
||
|
||
def test_event_kwarg_hint(): | ||
code = """ | ||
from ethereum.ercs import IERC20 | ||
def foo(): | ||
log IERC20.Transfer(msg.sender, msg.sender, 123) | ||
""" | ||
|
||
with warnings.catch_warnings(record=True) as w: | ||
assert compile_code(code) is not None | ||
|
||
expected = "Instantiating events with positional arguments is deprecated " | ||
expected += "as of v0.4.1 and will be disallowed in a future release. " | ||
expected += "Use kwargs instead e.g.:\n" | ||
expected += "```\nlog IERC20.Transfer(sender=msg.sender, receiver=msg.sender, value=123)\n```" | ||
|
||
assert len(w) == 1, [s.message for s in w] | ||
assert str(w[0].message).startswith(expected) | ||
|
||
|
||
def test_event_hint_single_char_argument(): | ||
code = """ | ||
from ethereum.ercs import IERC20 | ||
def foo(): | ||
log IERC20.Transfer(msg.sender, msg.sender, 1) | ||
""" | ||
|
||
with warnings.catch_warnings(record=True) as w: | ||
assert compile_code(code) is not None | ||
|
||
expected = "Instantiating events with positional arguments is deprecated " | ||
expected += "as of v0.4.1 and will be disallowed in a future release. " | ||
expected += "Use kwargs instead e.g.:\n" | ||
expected += "```\nlog IERC20.Transfer(sender=msg.sender, receiver=msg.sender, value=1)\n```" | ||
|
||
assert len(w) == 1, [s.message for s in w] | ||
assert str(w[0].message).startswith(expected) |
Oops, something went wrong.