I am using call_raw
for an Intercanister Call which return a Vec<u8>
. This vec I am passing through the IDLArgs::from_bytes
function that return a valid Candid
response.
let encoded: <Vec<u8>> = call_raw(data.canister, &data.method, bytes, 0).await.unwrap();
let decoded: IDLArgs = IDLArgs::from_bytes(&encoded).unwrap();
let output: String = decoded.to_string();
The output I am returning to my front-end is ofcourse the Candid
response as a string. What I want it to be is a valid JSON
that I can use in my back-end in further flows and return it to my front-end.
So I came across a package which does this idl2json
, but I am getting errors with it that I cant figure out.
here is what I am doing as the the examples in the repo
let idl_value: IDLValue = Decode!(&encoded[..], IDLValue).expect("Failed to parse buffer");
let to_string: String = serde_json::to_string(&idl2json(&idl_value, &Idl2JsonOptions::default()))
This gives me an error
mismatched types 'IDLValue' and 'candid::parser::value::IDLValue' have similar names, but are actually distinct types
I can see that the idl2json
is using IDLValue
from use candid::parser::value::IDLValue;
, but there is no such thing available.
Would appreciate some help or guidance.