-
Notifications
You must be signed in to change notification settings - Fork 166
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
FLIP: Contract Import Improvements #892
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/onflow/flow-docs/A1dFpzd2KM7qKpLq1p1PY1t6uYuP |
…-03-23-contract-imports-syntax.md
Removed PR by mistake so I'm pasting this from the previous PR #881 Few related questions/ideas mostly related to cadence
Response: Yeah, I think there are a bunch of problems still needing to be solved but the nice thing about it is that we can do that as we learn more about it, it's not restricting any syntax at this point. Versioning is something that at this point I wouldn't like to solve as you mentioned is still a bit tricky and it might require some other solutions to come along. I don't want to do too much with this proposal so it's actually doable soon. dynamic import: ( import from variable to a variable ) name service: this would be nice to have but also competing with existing community projects Thank you for your input :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, this is going to make tooling much better!
Co-authored-by: Bastian Müller <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>
Co-authored-by: Bastian Müller <[email protected]>
|
||
The source files should be accompanied by a configuration/dependency resolution file, defining locations of contracts addresses on a specific network. Including this file is beneficial so developers exploring contract source files in public repositories can understand which contracts this Cadence code imports. Think of this as go.mod, package.json or any other implementation of this idea where source code that imports something needs to define what that is in the supporting "configuration" file. | ||
|
||
Example flow.json for the above syntax: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, maybe point out this is only an example how a tool like the CLI may use the syntax proposed this standard, and the behaviour of the tools is not part of this proposal
Have you consider supporting aliasing? The name of a contract is not unique across the chain and in the future I am pretty sure there will be more contracts that are called common names. Right now it is not possible to import two So something like
for instance. Also have you considered the short for of just using Flow.json will have the inforamtion about that if it is not namespace. So if the contract part of flow.json contains
So sort of say that if you do not specify a from then from is implied. This might crash with things like Crypto? |
I see @bjartek that's a valid flag for sure, the only thing I'm not quite sure about is that it feels to me like this could/should be supported by Cadence natively. What do you think also cc @turbolent |
I guess the core need here is the ability to migrate state to a new version of a contract. |
Support for aliasing in imports has been requested before in onflow/cadence#1171. @bjartek Great point that this is currently not possible, but is unrelated to what this FLIP is proposing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So it seems like this FLIP is only really for the syntax of how the import placeholders should work? It isn't about how they are actually replaced by apps or the CLI, right?
It isn't clear to me what the standard format for the namespaces should be. Should a specification for how we should construct the namespaced placeholders be a part of this?
@joshuahannan The part about further defining the syntax is something that I'm interested in but at the same time it's really hard to define one (even the example I mentioned has some problems) so if you have some better examples for such a syntax I would love to hear it. My idea for this FLIP is to keep it simple intentionally so we could address the most important DX improvements soon:
|
You really nicely laid out the goals of this proposal, and I think it succeeds in addressing these goals, so +1 from me. |
Yeah, that makes sense. I'm fine with this then. 👍 |
This is a FLIP PR proposing a new cadence contract import syntax.
For contributor use:
master
branchFiles changed
in the Github PR explorer