Is there a tool that allows me to pop in a did interface file and then generates a Motoko interface file for interacting with that actor?
A basic example would take something like
// .did file
service : {
ping: () -> (text);
}
and generate
// Interface.mo
module {
public type Interface = actor {
ping : shared () -> async (Text);
}
}
Extra credit: If I could point this tool at any canister on main net and it would both pull down the did file and generate the Interface.mo file for it, ideally in the directory that I execute the command in.
Over the past few weeks several times I’ve gone through the process of:
Identify canister I need to interact with
Look up a did file for that canister on the candid UI/ICP dashboard
Copy over just the APIs I need into a Motoko Interface file
This process could be sped up a ton if I could just run
% didc bind snsSwapInterfaceDuplicate.did -t mo
thread 'main' panicked at 'float32 not supported in Motoko', rust/candid/src/bindings/motoko.rs:103:20
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
It looks like there’s an issue with the didc command where it isn’t mapping float32 to Float? Maybe that’s why a Motoko interface file isn’t appearing for this canister?
Right, the underlying code is exactly the same. The problem is that Motoko doesn’t support float32 in Candid, so it cannot generate binding for that canister. It would be good to contact the author of that canister to update the interface. Otherwise, people cannot call that canister from Motoko.