Convert Candid to JSON

I will put some work into examples. With a bit of luck I will encounter any issues you are seeing and be able to iron them out.

1 Like

awesome, thank you for looking into this!

@bitdivine btw I am also getting issues using ic_agent package in rust. This is how I setup the call to made for read_state_canister_metadata

let metadata: Vec<u8> = ic_agent::agent::Agent::read_state_canister_metadata(
    &AgentBuilder::default().build().unwrap(),
    data.canister,  
    &"candid:service".to_string() // Not sure if this is the correct one
).await.unwrap();

I had to include getrandom = { version = "0.2", features = ["js"] } but after deploying I am getting 2 errors

error[E0004]: non-exhaustive patterns: `Some(_)` not covered
   --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/ic-agent-0.29.0/src/agent/mod.rs:558:19
    |
558 |             match retry_policy.next_backoff() {
    |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^ pattern `Some(_)` not covered
    |
note: `std::option::Option<std::time::Duration>` defined here
   --> /.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:571:5
    |
563 | pub enum Option<T> {
    | ------------------
...
571 |     Some(#[stable(feature = "rust1", since = "1.0.0")] T),
    |     ^^^^ not covered
    = note: the matched value is of type `std::option::Option<std::time::Duration>`
help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown
    |
578 ~                 None => return Err(AgentError::TimeoutWaitingForResponse()),
579 ~                 Some(_) => todo!(),
    |

error[E0308]: mismatched types
  --> /.cargo/registry/src/index.crates.io-6f17d22bba15001f/ic-agent-0.29.0/src/agent/http_transport/reqwest_transport.rs:36:47
   |
36 |     pub fn create<U: Into<String>>(url: U) -> Result<Self, AgentError> {
   |            ------                             ^^^^^^^^^^^^^^^^^^^^^^^^ expected `Result<ReqwestTransport, AgentError>`, found `()`
   |            |
   |            implicitly returns `()` as its body has no tail or `return` expression
   |
   = note:   expected enum `Result<ReqwestTransport, AgentError>`
           found unit type `()`
2 Likes

Also getting non-exhaustive patterns: Some(_) not covered from ic-agent 0.29.0

1 Like

I am experiencing the same issue with ic-agent.

Hello all. Iā€™m really sorry, Iā€™ve not been able to make any progress on this. I am working like crazy on several things and Iā€™m not getting enough sleep, let alone a few hours to address this. Maybe Iā€™ll get a breather over Christmas and I can look into this then.

hey bumping this, did anybody fix the non-exhaustive pattern error?

Ignore this - turns out we were using the canister builder when it was the wrong packageā€¦ should have just used the management canister interface.

Recent updates on idl2json: There are now releases for candid 9 (idl2json version 0.9.3) and candid 10 (idl2json version 0.10.1). It seems a good idea to keep the major and minor versions in sync with candid. That should be fine as long as idl2json is fairly stable. If idl2json needs breaking changes that link will break so no promises! :slight_smile: