Comments (11)
@fubuloubu Here's the format I'm currently implementing for event logging.
MyLog: __log__({arg1: num, arg2: indexed(address)})
def example():
MyLog(1, 0x1d805bC00b8fa3c96aE6C8FA97B2FD24B19a9801)
from vyper.
Does the inside of the log need to be a structure?
from vyper.
I'd prefer it not being a structure but this :
MyLog: __log__(arg1: num, arg2: indexed(address))
Isn't valid python3.6
syntax.
from vyper.
Hmm, I guess that makes sense. It's norither a function call not a structure, so it wouldn't parse
Two questions:
- Is
__log__
a Python object/function? - Does
MyLog
name get represented in the output Bytecode (for searching purposes), or is it more of a type declaration e.g. this log call matches these types?
from vyper.
- No,
__log__
is just a clear way to differentiate events from globals in contracts. MyLog
is for type declaration (to be called later) though it will be used for searching in that it will be included in the keccak which will be used to create theevent_id
in thetopics
(topics are the part of an event that can be searched for).
from vyper.
Can it be a type then? e.g. MyLog: log({arg1: num, arg2: indexed(address)})
Actually, I'm using it more like public
here... Could it work like public
? (And create the right logger
function behind the scenes?)
Further, if set as a type like that, you could set individual entries e.g. self.MyLog.arg1 = foo
and self.MyLog.arg2 = bar
and have it commit after all entries are set in a given contract method? (e.g. write at the end of the method)
Random thoughts...
from vyper.
MyLog: log({arg1: num, arg2: indexed(address)})
works, though I think using log
instead of __log__
could make it harder to read as __log__
is more obvious.
We could make it so that individual entries can be set, though I don't think we should because then someone reading the code will have to do more work to figure out what's being logged.
I think both your ideas would improve writability at the detriment to readabi
from vyper.
I also prefer __log__
over log
. It looks a bit out of place, but that further accentuates the difference, giving the reader feedback that it's something to look at.
I spent a bit trying to see if the syntax used by Python's typing
module would work (e.g. MyLog: Log[num, indexed[address]]
), but that looks a bit strange.
from vyper.
@JackieXu MyLog: Log[num, indexed[address]]
I like this syntax, the issue is that it doesn't allow for the event inputs to be named which is important for readability.
from vyper.
Closing this issue now that the functionality has been added.
from vyper.
Nice! That's a major one!
from vyper.
Related Issues (20)
- multiple eval of `sqrt()` argument
- double eval of the slice start/length args
- incorrect topic logging in raw_log for non-literal expressions
- double eval of raw_args in create_from_blueprint HOT 1
- Disallow `optimize` and `evm-version` `pragma`'s in `.vyi` files
- meta: venom IR roadmap HOT 1
- HashMap index checks when the subscript is folded
- Compilation errors due to not folded convert value
- CompilerPanic for concat on empty(Bytes)
- CodegenPanic for slice on empty(Bytes)
- Mistyped Loop Iterable
- Overriding Storage Allocator Does Not Handle Stateful Modules
- Ambiguous Imports
- Constants Cannot Be Imported From .vyi Files
- External Call Kwargs Allowed for Call to __init__
- Imprecise Duplicate Import Check
- Incorrect error messages during compilation
- overriding allocator does not set global lock position causing crash in codegen HOT 2
- meta: tracker for overriding storage allocator bugs HOT 2
- compiler panic on indexing empty literal arrays
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vyper.