diff --git a/Cargo.lock b/Cargo.lock index 202e456e..406c50cc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -257,7 +257,7 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "candid" -version = "0.10.2" +version = "0.10.3" dependencies = [ "anyhow", "bincode", @@ -293,7 +293,7 @@ dependencies = [ [[package]] name = "candid_parser" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anyhow", "arbitrary", diff --git a/Changelog.md b/Changelog.md index 66168338..ea541850 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,21 @@ # Changelog +## 2023-01-30 + +### Candid 0.10.3 + +* Fix parser when converting `vec { number }` into `blob` type. + +### candid_parser 0.1.3 + +* Add Typescript binding for init args. + +### Candid UI + +* Fix HTTP header. +* Fix agent routing when running in remote environments. + ## 2023-01-03 ### Candid 0.10.2 diff --git a/rust/candid/Cargo.toml b/rust/candid/Cargo.toml index 7bff5a0e..35874dc9 100644 --- a/rust/candid/Cargo.toml +++ b/rust/candid/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "candid" -version = "0.10.2" +version = "0.10.3" edition = "2021" rust-version.workspace = true authors = ["DFINITY Team"] diff --git a/rust/candid/src/types/value.rs b/rust/candid/src/types/value.rs index 839b5a81..f622a29b 100644 --- a/rust/candid/src/types/value.rs +++ b/rust/candid/src/types/value.rs @@ -192,17 +192,22 @@ impl IDLValue { (_, TypeInner::Opt(_)) if !from_parser => IDLValue::None, (IDLValue::Blob(blob), ty) if ty.is_blob(env) => IDLValue::Blob(blob.to_vec()), (IDLValue::Vec(vec), ty) if ty.is_blob(env) => { - let blob = vec - .iter() - .filter_map(|x| match *x { - IDLValue::Nat8(n) => Some(n), - _ => None, - }) - .collect(); + let mut blob = Vec::with_capacity(vec.len()); + for e in vec.iter() { + match e { + IDLValue::Nat8(n) => blob.push(*n), + IDLValue::Number(n) => blob.push(n.parse::()?), + _ => { + return Err(Error::msg(format!( + "type mismatch: {e} cannot be of type nat8" + ))) + } + } + } IDLValue::Blob(blob) } (IDLValue::Vec(vec), TypeInner::Vec(ty)) => { - let mut res = Vec::new(); + let mut res = Vec::with_capacity(vec.len()); for e in vec.iter() { let v = e.annotate_type(from_parser, env, ty)?; res.push(v); diff --git a/rust/candid_parser/Cargo.toml b/rust/candid_parser/Cargo.toml index 8c7578c8..82e898b2 100644 --- a/rust/candid_parser/Cargo.toml +++ b/rust/candid_parser/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "candid_parser" -version = "0.1.2" +version = "0.1.3" edition = "2021" rust-version.workspace = true authors = ["DFINITY Team"]