rocklabs-io / ic-py

Python Agent Library for the DFINITY Internet Computer
MIT License
128 stars 27 forks source link

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

Open bodily11 opened 4 months ago

bodily11 commented 4 months ago

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.

Myse1f commented 4 months ago

Added the composite query parsing in #112

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

bodily11 commented 4 months ago

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 commented 4 months ago

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.

Myse1f commented 4 months ago

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.

bodily11 commented 4 months ago

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

chenyan-dfinity commented 4 months ago

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?