Skip to content

Commit 013b36f

Browse files
author
mircial
committed
Update
1 parent 8bcbe72 commit 013b36f

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

ic/agent.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def getType(method:str):
2828
elif method == 'balanceOf':
2929
return Types.Nat
3030
elif method == 'transfer':
31-
return Types.Tuple(Types.Variant)
31+
return Types.Nat
3232
else:
3333
pass
3434

@@ -90,7 +90,8 @@ def update_raw(self, canister_id, method_name, arg):
9090
print('update.req_id:', req_id.hex())
9191
# poll req_id status to get result
9292
result = self.poll(canister_id, req_id)
93-
return result
93+
method_type = getType(method_name)
94+
return decode(method_type, result)
9495

9596
def read_state_raw(self, canister_id, paths):
9697
req = {

test_agent.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
print('balanceOf:', ret)
2828

2929
# transfer 100 tokens to blackhole
30-
# ret = ag.update_raw(
31-
# "gvbup-jyaaa-aaaah-qcdwa-cai",
32-
# "transfer",
33-
# encode([
34-
# {'type': Types.Principal, 'value': 'aaaaa-aa'},
35-
# {'type': Types.Nat, 'value': 10000000000}
36-
# ])
37-
# )
38-
# print('result: ', ret)
30+
ret = ag.update_raw(
31+
"gvbup-jyaaa-aaaah-qcdwa-cai",
32+
"transfer",
33+
encode([
34+
{'type': Types.Principal, 'value': 'aaaaa-aa'},
35+
{'type': Types.Nat, 'value': 10000000000}
36+
])
37+
)
38+
print('result: ', ret)

0 commit comments

Comments
 (0)