-
Notifications
You must be signed in to change notification settings - Fork 1
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
CLI Tooling: Import/export tool. #7
Comments
One may wonder:
These are valid and natural questions. We could write a Candid serialization/deserialization implementation in Motoko, that converts from Blob into Candid AST and back. This route seems even better (more useful) but also seemed like more work, in the short term, than insisting that the user do the parsing into and from an AST. Then, I thought, perhaps the local Candid tools could do that extra step, since the canister may want to accept and store the AST directly (like in my case, here). |
This is actually the "shortcut", see https://github.com/dfinity/motoko/blob/master/test/run/idl.mo. The real solution is generics in Candid :) |
|
I don't know if that's possible in a strongly typed language like Motoko. As you mentioned, we need the type information as an input to deserialization. The deserialization expects two types: the wire type (comes from the message) and the expected type. With only the wire type, it's like using the candid value untyped. |
Actually, when you receive the message, the sender should know the candid type. You can ask the sender to get the type by calling the |
I think for now, the easiest thing is to finish the tool that I am creating to send the AST over the wire, with full field names. See #10 for a draft PR. I realize that the wire format is inefficient, but that's not the main issue right now. Later, Candid Spaces can offer a more efficient |
I finished and merged #10 It creates a simple tool Now, with a bit more polish, |
Related: dfinity/candid#245 I still don't quite see the exact requirement here. Does one of the ideas listed above fits your need? Feel free to add more ideas there. |
Simple CLI tool for importing and exporting data from a Candid Spaces canister.
The Rust crate may provide almost enough.
But, we need to "re-encode" and "re-decode" the Candid data as a Candid AST, as the API accepts and emits these ASTs, as to be generic and multi-purpose.
That is to say,
for importing into the canister with the tool (from a local machine), we want to read ordinary Candid data as human readable text or in serialized binary form, and then represent and import this data as Candid value AST, sent to the canister (see
put
).for exporting, we want to reverse the process, converting a Candid value AST into either ordinary text or serialized binary form (see
getFullImage
andgetSubImage
, which respond with the same data types accepted byput
).Perhaps this is best done as a feature added to either the Candid tools, or
ic-repl
, since those are the tools that already exist?Thoughts @chenyan-dfinity?
The text was updated successfully, but these errors were encountered: