8000 feat(didc-js): encode and validate specific types and service args by olaszakos · Pull Request #602 · dfinity/candid · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

feat(didc-js): encode and validate specific types and service args #602

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

Merged
merged 6 commits into from
Apr 30, 2025

Conversation

olaszakos
Copy link
Contributor

Overview
This PR extends the didc-js wasm module with capability to encode values of specific types, and values for the service arguments, with the purpose of also validating them against those types. This is useful for JS clients where the user is expected to produce valid candid value for a particular type.

Requirements

  • the encode function can receive type information other than service_method such as a type name or instruction to use the service argument types

Considered Solutions
I did not find any other solution.

Recommended Solution
Since encode already has this functionality to encode (and validate) service method arguments, this seems like a good place to extend the functionality.

Considerations

@olaszakos olaszakos requested a review from a team as a code owner April 8, 2025 12:43
@olaszakos olaszakos marked this pull request as draft April 8, 2025 14:22
@olaszakos olaszakos marked this pull request as ready for review April 17, 2025 10:32
Copy link
@christoph-dfinity christoph-dfinity left a comment

Choose a reason for hiding this comment

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

As discussed the general approach here looks reasonable. Just have a couple suggestions/requests regarding the Rust code.

I tried to run the tests in tools/didc-js after installing pnpm, but am getting the following error. Do you know what I'm doing wrong here?

EDIT: Seems like the sequence is pnpm run build && pnpm run test

Copy link
@christoph-dfinity christoph-dfinity 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 to me!

@christoph-dfinity christoph-dfinity merged commit de5cf53 into dfinity:master Apr 30, 2025
8 of 9 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.

2 participants
0