ic-py icon indicating copy to clipboard operation
ic-py copied to clipboard

Relatively new composite queries candid format is not supported in IC-PY

Open bodily11 opened this issue 1 year ago • 6 comments

Is IC-PY still being maintained? Is there a way to get new composite query functionality added to the candid parsing?

Also interested in putting in a plug for https://github.com/rocklabs-io/ic-py/issues/63. If you use a variable to define a candid value and include it inline (meaning within parentheses in a function) then the candid parser fails.

Thanks.

bodily11 avatar May 17 '24 15:05 bodily11

Added the composite query parsing in #112

For #63 I dont really understand. Could you give me an example and the error occur?

Myse1f avatar May 18 '24 05:05 Myse1f

A good example for #63 is:

authn_method_confirm: (IdentityNumber, confirmation_code: text) -> (variant {Ok; Err: AuthnMethodConfirmationError;});

See how "confirmation_code" is defined inline? This is from the Internet Identity canister: rdmx6-jaaaa-aaaaa-aaadq-cai.

If I delete "confirmation_code:" then it parses correctly, but can't handle what I'm calling inline naming/variable definitions.

bodily11 avatar May 18 '24 06:05 bodily11

#113 is relevant here as well. I tried to pull the candid for the II canister, but got an error that it didn't have the tmp_hack call anymore. So I copy/pasted the candid locally, but then got the #63 error. So I deleted the inline parameter names, and then I was finally able to parse the candid.

bodily11 avatar May 18 '24 06:05 bodily11

From the official Candid spec, I don't see such grammar to define func arguments inline. Seems the candid from II is manually documented. I suggest to modify the candid to match the grammar.

Myse1f avatar May 18 '24 06:05 Myse1f

Interesting. Ok, I'll dig a bit more on this.

bodily11 avatar May 18 '24 07:05 bodily11

I cannot reproduce this locally. I tried the following did file

type Balances = vec record {
    0: text;
    1: nat64;
};
service : {
  authn_method_confirm: (Balances, confirmation_code: text) -> (variant {Ok; Err: text});
}

didc parsed it correctly. Are you using the latest candid parser?

chenyan-dfinity avatar May 21 '24 05:05 chenyan-dfinity