Concordium / concordium-smart-contract-tools

Tools for building, deploying, and interacting with smart contracts
Apache License 2.0
2 stars 8 forks source link

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

Closed Bargsteen closed 9 months ago

Bargsteen commented 10 months ago

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 https://github.com/Concordium/concordium-smart-contract-tools/issues/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+ (https://github.com/electron/electron/pull/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 https://github.com/Concordium/concordium-node-sdk-js/pull/315, but I have not tested the complete fix on Windows.

Changes

Checklist

Bargsteen commented 10 months ago

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.