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

Support generating TypeScript/JavaScript clients using ccd-js-gen #140

Merged
merged 14 commits into from
Dec 12, 2023

Conversation

Bargsteen
Copy link
Contributor

@Bargsteen Bargsteen commented Nov 28, 2023

Purpose

Integrates our ccd-js-gen tool in our VS Code extension, so that js/ts clients can be generated from smart contract modules.
Closes #138.

As discussed in standup, I could not use ccd-js-gen as a library because it is an ES module, which VS Code does not support. ES modules are supported in Electron 28+ (electron/electron#37535), but VS Code is still on v25.

We tested the new commands on Windows, and the generator command did not work. After some debugging, we found out that it is because of a badly generated ps1/cmd file that is used as the executable.
Should be fixed by Concordium/concordium-node-sdk-js#315, but I have not tested the complete fix on Windows.

Changes

  • Add commands:
    • To get the version of the ccd-js-gen executable
    • To generate js/ts clients from a wasm module
  • Add a task for generating js/ts clients
  • Add settings
    • Custom ccd-js-gen executable
    • Additional arguments for ccd-js-gen
  • Refactorings
    • Move task types to a new file tasks.ts as they are needed for both ccd-js-gen and cargo concordium
    • Move helper functions for calling executables into the file executable-wrapper-helpers.ts

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

- Also adds a command for getting the version of the ccd-js-gen executable
- ccd-js-gen is not used as a library because it is an ES module, which
- VS Code does not support yet. VS Code uses Electron v25, and support
- for ES modules is added in v28.
Refactors a number of helper functions for making well-typed executable
wrappers into the file `executable-wrapper-helpers.ts`.
Adds tests for the ccd-js-gen settings and refactors the tests a bit by
creating a `prepareTest()` function.
@Bargsteen Bargsteen requested review from limemloh and removed request for limemloh November 28, 2023 14:03
@Bargsteen Bargsteen changed the title Kb/integrate ccd js gen Support generating TypeScript/JavaScript clients using ccd-js-gen Nov 29, 2023
Copy link
Contributor

@abizjak abizjak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I do not understand how the ccd-gen-js is embedded as a binary.

Also, what runtime will the ccd-js-gen run with?

@Bargsteen
Copy link
Contributor Author

Looks good, but I do not understand how the ccd-gen-js is embedded as a binary.

Also, what runtime will the ccd-js-gen run with?

The executable comes from adding the package to the project in package.json.
It is a simple script:

#!/usr/bin/env -S node --no-warnings
import { main } from '../lib/src/cli.js';
main();

which uses the node as runtime.
Good point about that, so we need to ensure or require that users have Node available.

@Bargsteen Bargsteen force-pushed the kb/integrate-ccd-js-gen branch from e9e8b67 to 2bdda6b Compare November 29, 2023 13:15
@Bargsteen Bargsteen force-pushed the kb/integrate-ccd-js-gen branch from 7b31b9d to ba4f015 Compare November 30, 2023 09:36
VSCode uses the CommandPrompt shell by default, so we must use the .cmd
file. I also changed it, so the version command also uses the CommandPrompt.
Copy link
Contributor

@limemloh limemloh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, with only some minor comments.

@Bargsteen Bargsteen merged commit 1c6fc81 into main Dec 12, 2023
5 checks passed
@Bargsteen Bargsteen deleted the kb/integrate-ccd-js-gen branch December 12, 2023 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VSCode command for generating smart contract clients
3 participants