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

Do not generate conversion code for event parameter those type doesn't match the one provided in the contract config

Open AnnaShaleva opened this issue 2 years ago • 3 comments

See https://github.com/nspcc-dev/neo-go/pull/3008#discussion_r1209546459.

AnnaShaleva avatar May 31 '23 13:05 AnnaShaleva

Within the scope of this issue we also need to add RealType comparison for the set of emitted events if --guessed-evettypes option is used.

AnnaShaleva avatar May 31 '23 13:05 AnnaShaleva

@roman-khimov, I did some digging and I still doubt that we need this issue to be implemented. Initially there was a requirement of enforced type casting for events parameters: https://github.com/nspcc-dev/neo-go/issues/2713. The issue was inspired by ABI match requirement for emitted notifications.

Back to our discussion:

"s", 5 can't be the same as "s", "s" You'll get binary 5 in the ByteString instead of (likely expected) the string "5"

It's a contraversal statement. IMO, the user that calls runtime.Notify("Name", 5) and writes ByteArray in the contract config would probably expect the unchanged binary representation of 5, not the string.

I'd suggest to consider another solution of this problem: we may stil emit conversion code for such cases and store the real type of the parameter. During events check we can warn a user about events mismatch in some compilation log. If it is done intentionally, then OK, the result will be converted. If not, then the user will fix either the contract config or the code.

AnnaShaleva avatar May 31 '23 15:05 AnnaShaleva