dfinity / ic-repl

Apache License 2.0
70 stars 10 forks source link

how to convert text variable to principal #61

Closed lauyoume closed 1 year ago

lauyoume commented 1 year ago
let idtext = call canister.get_pid_text();
// principal idtext;
// how to convert idtext to a principal variable
chenyan2002 commented 1 year ago

I would argue that it's not a good interface. Why cannot the canister return the principal directly?

lauyoume commented 1 year ago

I would argue that it's not a good interface. Why cannot the canister return the principal directly?

Yes, It is not a good design, it just an example to describe the problem aha~ It could change the design to solve this problem.

chenyan2002 commented 1 year ago

Right. I'm a bit hesitated to support this, as this may encourage bad API design. You can basically asking to convert text to any candid type. There is probably a limit on how much we can support to avoid bad API.