19
19
ABIStruct ,
20
20
ABIType ,
21
21
ABIValue ,
22
+ Arc56ReturnValueType ,
22
23
BoxABIValue ,
23
24
get_abi_decoded_value ,
24
25
get_abi_encoded_value ,
27
28
from algokit_utils .applications .app_spec .arc32 import Arc32Contract
28
29
from algokit_utils .applications .app_spec .arc56 import (
29
30
Arc56Contract ,
31
+ Method ,
30
32
PcOffsetMethod ,
31
33
ProgramSourceInfo ,
32
34
SourceInfo ,
@@ -941,29 +943,43 @@ def fund_app_account(self, params: FundAppAccountParams) -> SendSingleTransactio
941
943
lambda : self ._algorand .send .payment (self ._client .params .fund_app_account (params ))
942
944
)
943
945
944
- def opt_in (self , params : AppClientMethodCallWithSendParams ) -> SendAppTransactionResult [ABIReturn ]:
946
+ def opt_in (self , params : AppClientMethodCallWithSendParams ) -> SendAppTransactionResult [Arc56ReturnValueType ]:
945
947
return self ._client ._handle_call_errors (
946
- lambda : self ._algorand .send .app_call_method_call (self ._client .params .opt_in (params ))
948
+ lambda : self ._client ._process_method_call_return (
949
+ lambda : self ._algorand .send .app_call_method_call (self ._client .params .opt_in (params )),
950
+ self ._app_spec .get_arc56_method (params .method ),
951
+ )
947
952
)
948
953
949
- def delete (self , params : AppClientMethodCallWithSendParams ) -> SendAppTransactionResult [ABIReturn ]:
954
+ def delete (self , params : AppClientMethodCallWithSendParams ) -> SendAppTransactionResult [Arc56ReturnValueType ]:
950
955
return self ._client ._handle_call_errors (
951
- lambda : self ._algorand .send .app_delete_method_call (self ._client .params .delete (params ))
956
+ lambda : self ._client ._process_method_call_return (
957
+ lambda : self ._algorand .send .app_delete_method_call (self ._client .params .delete (params )),
958
+ self ._app_spec .get_arc56_method (params .method ),
959
+ )
952
960
)
953
961
954
962
def update (
955
963
self , params : AppClientMethodCallWithCompilationAndSendParams
956
- ) -> SendAppUpdateTransactionResult [ABIReturn ]:
957
- return self ._client ._handle_call_errors (
958
- lambda : self ._algorand .send .app_update_method_call (self ._client .params .update (params ))
964
+ ) -> SendAppUpdateTransactionResult [Arc56ReturnValueType ]:
965
+ result = self ._client ._handle_call_errors (
966
+ lambda : self ._client ._process_method_call_return (
967
+ lambda : self ._algorand .send .app_update_method_call (self ._client .params .update (params )),
968
+ self ._app_spec .get_arc56_method (params .method ),
969
+ )
959
970
)
971
+ assert isinstance (result , SendAppUpdateTransactionResult )
972
+ return result
960
973
961
- def close_out (self , params : AppClientMethodCallWithSendParams ) -> SendAppTransactionResult [ABIReturn ]:
974
+ def close_out (self , params : AppClientMethodCallWithSendParams ) -> SendAppTransactionResult [Arc56ReturnValueType ]:
962
975
return self ._client ._handle_call_errors (
963
- lambda : self ._algorand .send .app_call_method_call (self ._client .params .close_out (params ))
976
+ lambda : self ._client ._process_method_call_return (
977
+ lambda : self ._algorand .send .app_call_method_call (self ._client .params .close_out (params )),
978
+ self ._app_spec .get_arc56_method (params .method ),
979
+ )
964
980
)
965
981
966
- def call (self , params : AppClientMethodCallWithSendParams ) -> SendAppTransactionResult [ABIReturn ]:
982
+ def call (self , params : AppClientMethodCallWithSendParams ) -> SendAppTransactionResult [Arc56ReturnValueType ]:
967
983
is_read_only_call = (
968
984
params .on_complete == algosdk .transaction .OnComplete .NoOpOC or params .on_complete is None
969
985
) and self ._app_spec .get_arc56_method (params .method ).readonly
@@ -985,19 +1001,24 @@ def call(self, params: AppClientMethodCallWithSendParams) -> SendAppTransactionR
985
1001
)
986
1002
)
987
1003
988
- return SendAppTransactionResult [ABIReturn ](
1004
+ return SendAppTransactionResult [Arc56ReturnValueType ](
989
1005
tx_ids = simulate_response .tx_ids ,
990
1006
transactions = simulate_response .transactions ,
991
1007
transaction = simulate_response .transactions [- 1 ],
992
1008
confirmation = simulate_response .confirmations [- 1 ] if simulate_response .confirmations else b"" ,
993
1009
confirmations = simulate_response .confirmations ,
994
1010
group_id = simulate_response .group_id or "" ,
995
1011
returns = simulate_response .returns ,
996
- abi_return = simulate_response .returns [- 1 ],
1012
+ abi_return = simulate_response .returns [- 1 ].get_arc56_value (
1013
+ self ._app_spec .get_arc56_method (params .method ), self ._app_spec .structs
1014
+ ),
997
1015
)
998
1016
999
1017
return self ._client ._handle_call_errors (
1000
- lambda : self ._algorand .send .app_call_method_call (self ._client .params .call (params ))
1018
+ lambda : self ._client ._process_method_call_return (
1019
+ lambda : self ._algorand .send .app_call_method_call (self ._client .params .call (params )),
1020
+ self ._app_spec .get_arc56_method (params .method ),
1021
+ )
1001
1022
)
1002
1023
1003
1024
@@ -1570,8 +1591,8 @@ def _get_abi_args_with_default_values( # noqa: C901, PLR0912
1570
1591
self ._app_spec .structs ,
1571
1592
)
1572
1593
)
1573
- elif call_result .abi_return . value :
1574
- result .append (call_result .abi_return . value )
1594
+ elif call_result .abi_return :
1595
+ result .append (call_result .abi_return )
1575
1596
1576
1597
case "local" | "global" :
1577
1598
# Get state value
@@ -1624,3 +1645,21 @@ def _get_abi_params(self, params: dict[str, Any], on_complete: algosdk.transacti
1624
1645
"onComplete" : on_complete ,
1625
1646
"args" : args ,
1626
1647
}
1648
+
1649
+ def _process_method_call_return (
1650
+ self ,
1651
+ result : Callable [[], SendAppUpdateTransactionResult [ABIReturn ] | SendAppTransactionResult [ABIReturn ]],
1652
+ method : Method ,
1653
+ ) -> SendAppUpdateTransactionResult [Arc56ReturnValueType ] | SendAppTransactionResult [Arc56ReturnValueType ]:
1654
+ result_value = result ()
1655
+ abi_return = (
1656
+ result_value .abi_return .get_arc56_value (method , self ._app_spec .structs )
1657
+ if isinstance (result_value .abi_return , ABIReturn )
1658
+ else None
1659
+ )
1660
+
1661
+ if isinstance (result_value , SendAppUpdateTransactionResult ):
1662
+ return SendAppUpdateTransactionResult [Arc56ReturnValueType ](
1663
+ ** {** result_value .__dict__ , "abi_return" : abi_return }
1664
+ )
1665
+ return SendAppTransactionResult [Arc56ReturnValueType ](** {** result_value .__dict__ , "abi_return" : abi_return })
0 commit comments