-
Notifications
You must be signed in to change notification settings - Fork 0
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
Yaml2json types #95
Yaml2json types #95
Conversation
@@ -67,8 +84,8 @@ impl Yaml2Candid { | |||
/// * YAML types do not match the IDL types. | |||
/// * `type_name` is not defined in the converter's `.did` file. | |||
pub fn convert(&self, typ: &IDLType, data: &YamlValue) -> anyhow::Result<IDLValue> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the match includes just the Candid type, so that the compiler will complain if there are any unsupported Candid types.
Below many types that were previously unsupported have been added.
|
||
/// Converts YAML to Candid using a given did file. | ||
pub struct Yaml2Candid { | ||
/// The types that the converter supports, defined in an IDLProg interface definition. | ||
pub prog: IDLProg, | ||
} | ||
impl Default for Yaml2Candid { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple default constructor needed for tests. Included here as it may have more uses.
num-bigint = { workspace = true } | ||
|
||
[dev-dependencies] | ||
pretty_assertions = "1.4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provides a pretty diff in assert_eq!()
errors. This makes debugging much easier.
@@ -16,3 +16,4 @@ version = "0.10.1" | |||
[workspace.dependencies] | |||
candid = { version = "0.10.8" } | |||
candid_parser = { version = "0.1.0" } | |||
num-bigint = { version = "0.4.5" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed when converting BigNum types.
@@ -1,60 +1,60 @@ | |||
record { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the .did file, many fields below are optional. I believe that, strictly speaking, they should therefore be opt
even if parsers might accept either.
Motivation
yaml2candid
is very incomplete and still in some places buggy. Specifically, it does not support many Candid types and the opt test vectors (and implementation that was guided by those test vectors) are wrong.Changes
yaml2json
type match so that the compiler will complain when not all types are matched.opt
in the candid.Tests
TODO in future