flow-go icon indicating copy to clipboard operation
flow-go copied to clipboard

Allow emitEvent in script environment

Open bluesign opened this issue 3 years ago • 3 comments
trafficstars

Problem Definition

Currently script environment does not allow emit event. I understand it is kind of pointless to emit the events but I think it is too harsh to panic.

Context: I am coding a Safe Transaction Guard project ( using getAuthAccount and some cadence rewrite to basically detect changes in account state )

Proposed Solution

It would be nice to allow emit to run as a no-op instead of panic https://github.com/onflow/flow-go/blob/9652b94c903adc3839f0c11c31acd4c302aa5cef/fvm/scriptEnv.go#L534

cc: @janezpodhostnik

bluesign avatar Jul 17 '22 17:07 bluesign

Without this you are prevented from calling contract functions which emit events, so I totally agree.

Is there some way we can make sure that the developer knows that events are ignored in scripts? Is documentation around this enough?

janezpodhostnik avatar Jul 19 '22 15:07 janezpodhostnik

Oh this is very hard question to answer to be honest, but in general script environment doesn't mutate any state, but for sure it can be explained in more detail.

bluesign avatar Jul 21 '22 00:07 bluesign

Is there any chance to implement this before next spork ?

bluesign avatar Aug 02 '22 22:08 bluesign