-
Notifications
You must be signed in to change notification settings - Fork 101
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
Fix: ban notify from contract developer #845
Conversation
@shargon @cschuchardt88 @roman-khimov @vncoelho @superboyiii please check |
You can't write any meaningful contract with this PR merged. I'm not sure what's the problem really, just have a proper manifest (how you create it is a separate matter) for your contract and that's it. |
What problem are you specifying? user can still call Notify via event, existing contract will still work. The only thing that I banned is directly calling Notify without defining an event...... cause it will fail the execution for sure anyway. Well, this actually only affects the C# compiler,,,, the core remains the same. |
But is not possible to call a dynamic event |
Current core only accept events that are defined as |
@Jim8y, maybe I just don't know enough about C# devpack, if |
But current public delegate void OnSayHelloDelegate(string message);
[DisplayName("SayHello1")]
public static event OnSayHelloDelegate OnSayHello;
[DisplayName("SayHello2")]
public static event Action<string> SayHello; but if you already defined them this way, using |
I mean that maybe you want to emit a event with a dynamic name, who knows.. I think we should not remove notify because if you want to call it by syscall you will be able to do it, so in reality you are not banning it, you are making it difficult |
@shargon |
But currently the core allow to call notify with a event that is not present in the manifest.... |
And old contracts will still work fine. You'll just have to do it with |
We do |
Do you remember last update or so we removed this functionally. Because of NEP-14
|
It is not an issue of allowing user to call it or not, if i did not get you wrong, your so called
|
@shargon We dont, new logic since the hardfork. Just check the issue and code please https://github.com/neo-project/neo/blob/c78ac5adbd790b1fc60d3ea9abc87cf3eee74a6e/src/Neo/SmartContract/ApplicationEngine.Runtime.cs#L352 |
Yes, you are right... |
Depends on your definition of "dynamic". If it's "I want to emit anything regardless of manifest" then yes. How is it related to |
@roman-khimov Edit: |
@roman-khimov truth is even shargon and i did not know this, are you expecting developers to use it correctly? how would you feel to use an interface that accepts arbitrary input without emiting any errors during compile but actually will fail the execution without saying why? you love that? when you think it is better for neo, have you considered the developers? a group of people have no clue how to develop in c# and can not find assistence from anywhere? |
Maybe should we should add |
Very general question is, how would developer know they can not do this if they don't already know they can not do this? |
@cschuchardt88, @Jim8y, I see it in a different way. Under the hood it's all Let's try to approach it from a different angle, how can I make a |
Have some mercy to the neo contract developer, dont make it even harder to write neo contract. make every interface clear and easy to use please. Yes, indeed people can still use it via bytecode (only experienced can do that, i guess will only be few of us), but not via the devpack, devpack should compile contract that works, instead of compile contract without showing error but not work. If there is another Hackthon for the neo core, who is there to answer questions how to use Notify, and who is there to help them debug? Are we going to tell them, you can use this, but xxxx, you can use that, but xxxx..... Either ban it directly such that contract developers can not use it at all, or register event to the manifest with whatever names developer pass in. Dont just leave it there like this. |
This won't work at public static void HelloWorld(string eventName, string name)
{
Runtime.Notify(eventName, new[] { $"Hello, {name}" });
} Which leaves us at the same problem to begin with. |
Have you tried it in that pr? This syntax will not pass the compile as it is not a constant string. When I say |
Which PR? but i think below will give you Runtime.Notify($"{eventName}", new[] { $"Hello, {name}" }); |
#846 This one |
I am fine with banning it, in fact its directly use has been a burden after events. |
* master: fix error message (neo-project#854) Updated Templates (neo-project#853) Fix: ban notify from contract developer (neo-project#845)
Closes #843