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

Use schema information when generating client #275

Merged
merged 15 commits into from
Oct 12, 2023

Conversation

limemloh
Copy link
Collaborator

@limemloh limemloh commented Sep 28, 2023

Purpose

Should be merged after #270.
Closes #254

Generate smart contract clients, which uses schema information to take structured parameters and provides function for parsing events, return values and error messages.

Example

An example of a wCCD client can be seen by running (from ./examples):

yarn run-example ./ccd-js-gen/wCCD/generate.ts --endpoint http://node.testnet.concordium.com:20000

The generated clients can be found in examples/ccd-js-gen/wCCD/lib/

Changes

  • Introduce a ContractEvent type wrapper and update API to use it.

@limemloh limemloh requested a review from soerenbf September 28, 2023 09:31
@limemloh limemloh force-pushed the ccd-js-gen-schema-param branch from 1ea78cd to d99f0c7 Compare September 29, 2023 07:27
@limemloh limemloh changed the title Use schema for parameter when generating client Use schema information when generating client Sep 29, 2023
@limemloh limemloh requested a review from abizjak October 2, 2023 08:10
@limemloh limemloh mentioned this pull request Oct 2, 2023
5 tasks
@limemloh limemloh force-pushed the ccd-js-gen-schema-param branch from 55a0dfa to 1e3d043 Compare October 2, 2023 11:02
@limemloh limemloh changed the base branch from api-strict-types to release/10 October 2, 2023 12:25
@limemloh limemloh force-pushed the ccd-js-gen-schema-param branch from 4cb8573 to ac9f4ec Compare October 2, 2023 17:48
packages/common/src/types/Duration.ts Outdated Show resolved Hide resolved
packages/common/src/types/Duration.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/tsconfig.json Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
@limemloh limemloh requested a review from soerenbf October 5, 2023 09:02
Copy link
Collaborator

@soerenbf soerenbf left a comment

Choose a reason for hiding this comment

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

LGTM! :)

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.

The readme in examples should be updated as well.

But also, there are as far as I see no tests of the generated code. That's not so problematic for the initial development since it's being tested on the fly, but it is a problem for maintenance.

I would expect some tests that would check at least a few example modules used as sources and then checking the correct functions are present in the generated module, that the generated TS modules actually type-check, and ideally also that the types are sensible, but this would probably require a bit more work.

As it is now it's too hard to make sure that the generated code is sensible unless I've missed something.

examples/ccd-js-gen/wCCD/client-events.ts Outdated Show resolved Hide resolved
packages/sdk/src/types/ContractName.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/cli.ts Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
packages/ccd-js-gen/src/lib.ts Outdated Show resolved Hide resolved
@limemloh limemloh requested a review from abizjak October 12, 2023 05:58
@limemloh limemloh force-pushed the ccd-js-gen-schema-param branch 2 times, most recently from cc4f167 to 0c86233 Compare October 12, 2023 06:56
@limemloh limemloh force-pushed the ccd-js-gen-schema-param branch from 0c86233 to d340b75 Compare October 12, 2023 08:48
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.

We agreed to implement tests in the followup PR.

Looks good otherwise.

@limemloh limemloh merged commit 5285fa1 into release/10 Oct 12, 2023
10 checks passed
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.

3 participants