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

feat[lang]: use keyword arguments for event instantiation #4257

Merged
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
24c202c
remove outdated comment
z80dev Sep 23, 2024
bc8c530
Implement instantiating events with kwargs
z80dev Sep 23, 2024
422abd6
fix: set parent nodes on generated kw nodes
z80dev Sep 24, 2024
bf5b548
fix: fail on missing event fields
z80dev Sep 24, 2024
acbcc77
update unit tests to use kwargs for events
z80dev Sep 24, 2024
473ca21
make sure mixed arg types fails a test
z80dev Sep 24, 2024
4ee73ee
fix affected unit tests
z80dev Sep 24, 2024
61b17a7
fix: lint
z80dev Sep 24, 2024
d78dd0c
fix: flake8
z80dev Sep 24, 2024
6c7b91d
mypy fix
z80dev Sep 24, 2024
8e62578
fix: lint again
z80dev Sep 24, 2024
4a4df37
add test ensuring positional event args still work
z80dev Sep 24, 2024
7474f16
fix: remove unnecessary line
z80dev Sep 25, 2024
4320ebc
improve testing around kwargs in dedicated tests
z80dev Sep 26, 2024
e18d169
Merge branch 'master' into events-kwargs-constructor-refactor
z80dev Sep 26, 2024
7d58cc2
fix: lint
z80dev Sep 26, 2024
4969586
remove AST conversion
z80dev Sep 26, 2024
ce50fb1
fix: lint
z80dev Sep 26, 2024
e2a88c6
Move code with effects to straight-line code section
z80dev Sep 30, 2024
b44e202
Move kwarg validation to helper fn
z80dev Sep 30, 2024
81a700c
fix: missing validation on events
z80dev Sep 30, 2024
f931053
fix: lint
z80dev Sep 30, 2024
58f369b
fix: move copy into helper fn
z80dev Oct 1, 2024
7609e20
Merge branch 'master' into events-kwargs-constructor-refactor
z80dev Oct 1, 2024
a1a5dcb
Tighten type constraint on validate_kwargs
z80dev Oct 1, 2024
5927a80
fix: lint
z80dev Oct 1, 2024
9c5cf95
clean up validate_kwargs function
charles-cooper Oct 4, 2024
ea609e5
fix order of checks
charles-cooper Oct 5, 2024
6ebbc79
fix mypy
charles-cooper Oct 5, 2024
6fec363
Merge branch 'master' into events-kwargs-constructor-refactor
charles-cooper Oct 5, 2024
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
10 changes: 5 additions & 5 deletions tests/functional/builtins/codegen/test_empty.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,11 @@ def test_empty_array_in_event_logging(get_contract, get_logs):
@external
def foo():
log MyLog(
b'hellohellohellohellohellohellohellohellohello',
empty(int128[2][3]),
314159,
b'helphelphelphelphelphelphelphelphelphelphelp',
empty(uint256[3])
arg1=b'hellohellohellohellohellohellohellohellohello',
arg2=empty(int128[2][3]),
arg3=314159,
arg4=b'helphelphelphelphelphelphelphelphelphelphelp',
arg5=empty(uint256[3])
)
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_basic_default(env, get_logs, get_contract):
@external
@payable
def __default__():
log Sent(msg.sender)
log Sent(sender=msg.sender)
"""
c = get_contract(code)
env.set_balance(env.deployer, 10**18)
Expand All @@ -46,13 +46,13 @@ def test_basic_default_default_param_function(env, get_logs, get_contract):
@external
@payable
def fooBar(a: int128 = 12345) -> int128:
log Sent(empty(address))
log Sent(sender=empty(address))
return a

@external
@payable
def __default__():
log Sent(msg.sender)
log Sent(sender=msg.sender)
"""
c = get_contract(code)
env.set_balance(env.deployer, 10**18)
Expand All @@ -69,7 +69,7 @@ def test_basic_default_not_payable(env, tx_failed, get_contract):

@external
def __default__():
log Sent(msg.sender)
log Sent(sender=msg.sender)
"""
c = get_contract(code)
env.set_balance(env.deployer, 10**17)
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_always_public_2(assert_compile_failed, get_contract):
sender: indexed(address)

def __default__():
log Sent(msg.sender)
log Sent(sender=msg.sender)
"""
assert_compile_failed(lambda: get_contract(code))

Expand All @@ -119,12 +119,12 @@ def test_zero_method_id(env, get_logs, get_contract, tx_failed):
@payable
# function selector: 0x00000000
def blockHashAskewLimitary(v: uint256) -> uint256:
log Sent(2)
log Sent(sig=2)
return 7

@external
def __default__():
log Sent(1)
log Sent(sig=1)
"""
c = get_contract(code)

Expand Down Expand Up @@ -165,12 +165,12 @@ def test_another_zero_method_id(env, get_logs, get_contract, tx_failed):
@payable
# function selector: 0x00000000
def wycpnbqcyf() -> uint256:
log Sent(2)
log Sent(sig=2)
return 7

@external
def __default__():
log Sent(1)
log Sent(sig=1)
"""
c = get_contract(code)

Expand Down Expand Up @@ -205,12 +205,12 @@ def test_partial_selector_match_trailing_zeroes(env, get_logs, get_contract):
@payable
# function selector: 0xd88e0b00
def fow() -> uint256:
log Sent(2)
log Sent(sig=2)
return 7

@external
def __default__():
log Sent(1)
log Sent(sig=1)
"""
c = get_contract(code)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ def i_am_me() -> bool:
@external
@nonpayable
def whoami() -> address:
log Addr(self._whoami())
log Addr(addr=self._whoami())
return self._whoami()
"""

Expand Down
Loading
Loading