mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2026-03-01 04:28:51 +00:00
Create contract manifest during compilation #396
Labels
No labels
I1
I2
I3
I4
S1
S2
S3
S4
U0
U1
U2
U3
U3
U4
blocked
bug
bug
cli
compiler
config
config
consensus
dependencies
discussion
documentation
enhancement
epic
feature
go
good first issue
help wanted
neotest
network
oracle
performance
question
rpc
security
smartcontract
task
task
task
test
vm
wallet
windows
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
nspcc-dev/neo-go#396
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @fyrchik on GitHub (Jun 9, 2020).
While some of the contract features cannot be determined from the contract source (e.g.
IsPayable) most of them can. Method and Event descriptions should be generated automatically.I think it is also worth supporting Permissions/Groups (via magic comments?), so that manifest can be completely generated from source.
@AnnaShaleva commented on GitHub (Jun 26, 2020):
Perhaps, we can define Permissions/Groups right into configuration
.yamlfile, like it was done before for contract author, email and etc. Usage of this file is required for.manifest.jsongeneration, so why not to add some more configurable fields to it?@roman-khimov ?
@gsmachado commented on GitHub (Jan 11, 2021):
I support this. 👍 💯
@roman-khimov as we discussed in the other issue, I would keep generating the YAMLs. However, I would check if the YAML can be automagically generated somehow (as you suggested).
A short-term approach, in my opinion, would be:
contract.gousing theneo-go contract compile, it reads comment's tags and not only generates the NEF, but also the YAML fileneo-go contract compileThe only disadvantage with this approach is that the
neo-gowould need to parse and validate comment, which can be ugly. But I believe you guys can re-use the tools used in swag.The best (long-term) approach would be to automagically generate the YAML from analyzing the script. But this is a second step after generating from comments (as I mentioned above).
@roman-khimov commented on GitHub (Jan 12, 2021):
If we're to get all metadata from the source code we probably no longer need YAMLs then, compiler could just emit NEF and manifest. But
this still is a problem.
If we're to get back to the list of things specified there:
Can't be derived from the code, it's either needs to be specified in the comment or some magic variable (like
var _contract_name = "Name"with_contract_namebeing a reserved identifier)Also can't be derived directly.
#1596
Unfortunately, even this is problematic. We can analyze
runtime.Notify()argument types, but is the type we have there is the intended one? Do we want to emit "Tranfser" if that's what is written in the source code? How do we mapinterface{}into event type? What if event name is a variable? So some declaration is still needed even there.@lock9 commented on GitHub (Nov 17, 2023):
Hello.
What if there is a method that returns the configuration object?
It doesn't need annotations. The compiler could identify the method by the return type. For example, if it returns the NeoMetadataStruct, you know that this method will generate the configuration.
Something like this (I'm not a go dev):
I'm not sure if this is what I was proposing in the other issue. It's not that I want it to be automatic, I just want it to use a single file instead
@roman-khimov commented on GitHub (Nov 18, 2023):
Magic variables were considered previously, they can help to some extent, but I'm not sure it'd be a big improvement if they just have the same data, it could be a magic
then. Is it better than a separate YAML?
At the same time we have some mechanism for event guessing now (implemented as a part of #3008), the hardest part other than that is likely method safeness (permissions can technically be guessed in a way similar to events). But we've also got overloads (https://github.com/nspcc-dev/neo-go/blob/master/docs/compiler.md#Overloads).
@lock9 commented on GitHub (Nov 21, 2023):
For some use cases, it's better than a separate file. However, I can see that it may become an issue once it gets bigger.
It would be better if it were typed 😅
Edit: This could be replaced with a type, like a "NEP11TransferEvent"
Edit 2:, if the user declares it NEP-11 or NEP-xx compliant, the safe methods and events can be 'guessed' (enforced?)
It could be like this:
@amlwwalker commented on GitHub (Feb 5, 2024):
this looks cool. Any progress on this @roman-khimov ? be nice to not have to have a seperate yaml file!
@roman-khimov commented on GitHub (Feb 5, 2024):
Not on the roadmap at the moment (https://github.com/nspcc-dev/neo-go/milestone/76). Patches are welcome. Can be done step by step, btw, starting with simple attributes (name/url/standards).