onflow / onflow/flow-cli

Automatically add core contracts to flowkit

Open
#1,275 1 comment 0 reactions 1 assignee View on GitHub

@chasefleming is already working on this.

Since Nov 21, 2023.

Feature Feedback
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 currentconfig.Contract type. Since there would not be source file path in the config.Contract definition. Packages using flowkit may need a way to resolve the source code & this may mean flowkit needs to export this code from flow-go and 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.