Closed bodily11 closed 2 years ago
Yeah, beautiful. That is the one that I found as well. Although "time" is the only path that I could get to work. I kept getting CBOR decode issues if I tried any other paths. Are other paths other than "time" supported? Like canister_ranges? Or subnet information?
Canister info and subnet informatoin are supported. Text in paths must be blob and principal in the paths must be bytes-form, e.g
cert = ag.read_state_raw("gvbup-jyaaa-aaaah-qcdwa-cai", [["subnet".encode(), Principal.from_str("w4asl-4nmyj-qnr7c-6cqq4-tkwmt-o26di-iupkq-vx4kt-asbrx-jzuxh-4ae").bytes, "canister_ranges".encode()]])
ret = lookup(["subnet".encode(), Principal.from_str("w4asl-4nmyj-qnr7c-6cqq4-tkwmt-o26di-iupkq-vx4kt-asbrx-jzuxh-4ae").bytes, "canister_ranges".encode()], cert)
print(cbor2.loads(ret))
Actually, read_state_raw
is too low level. Maybe we can absract it into easy-to-use function later.
You can look into the code in test_readstate.py
and try ur own code to check whether get correct result.
Making query and update calls are great, but sometimes I want to make system calls, which requires read_state syntax as can be seen here: https://smartcontracts.org/docs/interface-spec/index.html#http-read-state
Is this interface implemented in the Python agent? I know the JavaScript agent tests supported some read_state calls, but the documentation around it still wasn't very good.
Thanks!