rocklabs-io / ic-py

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

Inline candid definitions aren't recognized #63

Open bodily11 opened 2 years ago

bodily11 commented 2 years ago

I have noticed that your candid parser doesn't parse types/values in candid if they are defined inline. So I have had to pull candid files and manually edit (pull out all inline definitions to define them normally) because they aren't pick up by the candid parser.

This is an enhancement that would be awesome to see.

Myse1f commented 2 years ago

What do you mean 'defined inline'? Any examples?

SuddenlyHazel commented 2 years ago

I'm hitting this issue now too. I think what @bodily11 was referring to is the following. Take for instance

type Balances = vec record {
    0: text;
    1: nat64;
};

The parser won't accept it unless you break out the nested record like so

type BalanceTuple = record {
    0: text;
    1: nat64;
};

type Balances = vec BalanceTuple;
SuddenlyHazel commented 2 years ago

Actually, I think nested definitions might be okay. But, the numbered tuple format isn't


// Doesn't work
type BalanceTuple = record {
    0: text;
    1: nat64;
};

// Works 
type BalanceTuple = record {
    text;
    nat64;
};