Closed Astrapolis-peasant closed 2 years ago
Currently, variant is represented by:
None: [] (Empty list),
Some: [xxx] (list with one item)
Thus you need to use canister.xxx({"a": []})
Hi, I tried canister.xxx({"a": []})
. It gives the same error. I checked the source code. Enum variant is parsed as
{'a': None, 'b': None}
. So when
def _buildTypeTableImpl(self, typeTable: TypeTable):
for _, v in self._fields.items():
v.buildTypeTable(typeTable)
This error triggers
Can you provide ur code to produce this error. By the way, what's the version of ic-py you used.
I cloned the main
repository and install it locally.
To reproduce,
Having a candid type like
type Side =
variant {
buy;
sell;
};
order: (Side, nat, nat, text) -> (opt Order);
Then pass it in with canister
canister = Canister(agent=agent, canister_id="rrkah-fqaaa-aaaaa-aaaaq-cai", candid=testdid)
Currently, variant is represented by:
None: [] (Empty list), Some: [xxx] (list with one item)
Thus you need to use
canister.xxx({"a": []})
Sry, I got it wrong. Option
is used in this way.
I will look into this issue.
Thanks for the report. Try to fix it in #49.
You can switch to that branch and use canister.xxx({"a": None})
to test whether the result is correct.
for variant type like
use
canister.xxx({"a": None})
returnsAttributeError: 'NoneType' object has no attribute 'buildTypeTable'