Skip to content
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

Generate FLIX using Cadence comment header block #7

Open
12 tasks
bthaile opened this issue Aug 10, 2023 · 1 comment
Open
12 tasks

Generate FLIX using Cadence comment header block #7

bthaile opened this issue Aug 10, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@bthaile
Copy link
Contributor

bthaile commented Aug 10, 2023

Given a cadence file generate flix json, generate version 1.1.0

Cadence comment block and language support

  • Support Cadence doc FLIP
    • Support "@..." properties - Inside a Cadence transaction or script in comment
    • Support additional language json description file - As a separate JSON file, optional file
    • Error handling, @message title is required to generate template from Cadence
      • If only @message title is available, generate template.
      • Only one tx or script in one .cdc file

1.1.0 considerations

Generation considerations

  • Support passing in destination folder to generate method in flix-kit, default destination is template directory from exe dir.
  • Support user passing in flow.json for contract addresses for tx and scripts dependences.
  • Support emulator network for local development

Template naming

  • Name template file based on @message title property using all lower case and _ for spaces. If title is not given then use hash of cadence. (not a hard requirement, a place to start)

Note: The two FLIPS identified in this task are still in development, they can change based on development.

Future Plans:
watch process to auto generate templates as cadence developer changes their cadence files them templates would get auto-generated

flixkit folder structure for binding generation
├── main.go
├── binding/
│ ├── generator.go
│ └── javascript/
│ └── generator.go
│ └── templates/
│ └── js_template.tpl
└── ...

typescript would get it's own folder as well.

@bthaile bthaile added the enhancement New feature or request label Aug 10, 2023
@bthaile bthaile changed the title [Improvement] Generate flix Generate flix json Aug 10, 2023
@chasefleming
Copy link
Member

chasefleming commented Aug 22, 2023

Generation of a FLIX from a Cadence file like a good use case for this library. A couple notes/question:

  • Passing in a file or folder to generate FLIX from is probably better handled by the CLI and then the CLI passes the file to this library for generation. Some of that is already happening for parsing flix with this library in CLI from a local file: https://github.com/onflow/flow-cli/blob/aead0144a7d722868c9cba50fecea667db2a3b6e/internal/super/flix.go#L123

  • Re passing flow.json: the CLI is already handling all the parsing of the flow.json, so I would say if you did that it should be the parsed struct that is passed in so it doesn't have to be parsed again. Although, it may mean maintaining types for flow.json in both repos or sharing them which may slow down development. It might be better just to pass some mapping of a simple struct type once you can pull the addresses from CLI and pass the mapping into this library.

  • Can you explain the emulator piece a bit more? Need more info on that one to digest it.

@bthaile bthaile changed the title Generate flix json Generate FLIX using Cadence comment header block Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants