Automatically add core contracts to flowkit
@chasefleming is already working on this.
Since Nov 21, 2023.
- Dominant language
- Go
- Stars
- 209
- Forks
- 87
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 3
Description
Issue To Be Solved
Since core contracts are guaranteed to be available by the FVM, it would be useful to have these automatically be recognized by flowkit/added to the state.
For packages depending on flowkit & using the state to resolve imports (i.e. Flow CLI, Cadence Language Server), they would be able to resolve these contracts via the new import syntax (i.e. import "MetadataViews")
(Optional): Suggest A Solution
Add the contracts with their aliases to Contracts() in the flowkit state by default.
Pros
- don't have to declare existence/address of contract guaranteed to be deployed
- smaller flow.json files
- quicker development
- other packages depending on flowkit do not need to make this consideration in their code constantly (not super easy to do currently & bug prone)
Cons (most of the cons are related to potentially obfuscating the underlying source code)
- Potential namespace clashes if the user wishes to use own contracts which share the name of core contracts (user contract could take precedence here?)
- Difficult to resolve source code of core contracts with current
config.Contracttype. Since there would not besourcefile path in theconfig.Contractdefinition. Packages using flowkit may need a way to resolve the source code & this may mean flowkit needs to export this code fromflow-goand expose it somehow - Harder for developers to inspect source code for these contracts when developing & trying to understand the code they are referencing. Likely need good support in the Cadence Language Server for "go to definition" so that developers can quickly discover the underlying code.
This may also be solved/greatly simplified by contract manager and this issue could become obsolete (see https://github.com/onflow/flow-cli/issues/929)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.