Skip to content

VIP: Modify event declaration syntax to resemble that of struct #1864

@iamdefinitelyahuman

Description

@iamdefinitelyahuman

Simple Summary

Change this:

Transfer: event({_from: indexed(address), _to: indexed(address), _value: uint256})

to this:

event Transfer:
    _from: indexed(address)
    _to: indexed(address)
    _value: uint256

Motivation

The current approach to declaring an event reads as though there is a variable being created, with it's type defined from the result of a call to an event function. This is misleading because:

  1. The created event is not a variable. You cannot assign to it during declaration, or reference it except as a callable member of log.
  2. event, though appearing to be a function, is not a function. And type annotations are not typically declared as the result of a function call.
  3. The reliance on the ordering of dictionary keys inside event is not a standard python behavior until version 3.7. Declaring the fields in this way does not intuitively read as though they are sequenced.

By instead using the struct-style declaration, we make it more clear that this not a simple variable, and that the members inside are sequenced.

Backwards Compatibility

This will be a rather large breaking change, we should definitely discuss it at length. If it is approved, it probably belongs in the 1.0rc release.

Copyright

Copyright and related rights waived via CC0

Metadata

Metadata

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions