rocklabs-io / ic-py

Python Agent Library for the DFINITY Internet Computer
MIT License
127 stars 26 forks source link

Missing 2 required positional arguments #9

Closed bodily11 closed 2 years ago

bodily11 commented 2 years ago

What are the current limitations of this wonderful WIP Python Agent? I am eager to get things working but am running into a few issues with some canister calls.

This is the error I keep getting TypeError: getType() missing 2 required positional arguments: 'table' and 't'

When I run

from ic.client import Client
from ic.identity import Identity
from ic.agent import Agent
from ic.candid import encode, decode

iden = Identity()
client = Client(url = "https://ic0.app")
agent = Agent(iden, client)

result = agent.query_raw("hbi4x-wqaaa-aaaaj-aad7a-cai", "getRegistryCount", encode([]))

It works. The getRegistryCount method works.

However, if I change the last line to: result = agent.query_raw("hbi4x-wqaaa-aaaaj-aad7a-cai", "getRegistry", encode([])) just get the registry rather than the count, it appears it has an issue returning a vec or something like that.

I'm assuming this is all known, I'm just exploring what I can and can't do right now. (again, eager to use it as it becomes available)

bodily11 commented 2 years ago

Full error in case you wanted it

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/var/folders/yg/mzpfyl291vx30knxqlx43d2r0000gn/T/ipykernel_62982/1139556732.py in <module>
----> 1 result = agent.query_raw("e3izy-jiaaa-aaaah-qacbq-cai", "transactions", encode([]))

/opt/anaconda3/lib/python3.9/site-packages/ic/agent.py in query_raw(self, canister_id, method_name, arg)
     72         result = self.query_endpoint(canister_id, data)
     73         if result['status'] == 'replied':
---> 74             arg = decode(result['reply']['arg'])
     75             return arg
     76         elif result['status'] == 'rejected':

/opt/anaconda3/lib/python3.9/site-packages/ic/candid.py in decode(data, retTypes)
   1139 
   1140     for i, entry in enumerate(rawTable):
-> 1141         t = buildType(rawTable, table, entry)
   1142         table[i].fill(t)
   1143 

/opt/anaconda3/lib/python3.9/site-packages/ic/candid.py in buildType(rawTable, table, entry)
   1045         if ty >= len(rawTable):
   1046             raise "type index out of range"
-> 1047         t = getType(entry[1])
   1048         if t == None:
   1049             t = table[t]

TypeError: getType() missing 2 required positional arguments: 'table' and 't'
ccyanxyz commented 2 years ago

Thanks for your support! There might still be some issues with vec decoding, we'll take a look and fix this ASAP.

ccyanxyz commented 2 years ago

Fixed on main branch now.