44from typing import Any
55
66from multiversx_sdk import (
7+ Action ,
8+ ActionFullInfo ,
9+ AddBoardMember ,
10+ AddProposer ,
711 Address ,
812 AddressComputer ,
13+ CallActionData ,
14+ ChangeQuorum ,
15+ EsdtTokenPayment ,
16+ EsdtTransferExecuteData ,
917 MultisigController ,
1018 ProxyNetworkProvider ,
19+ RemoveUser ,
20+ SCDeployFromSource ,
21+ SCUpgradeFromSource ,
22+ SendAsyncCall ,
23+ SendTransferExecuteEgld ,
24+ SendTransferExecuteEsdt ,
1125 Token ,
1226 TokenComputer ,
1327 TokenTransfer ,
@@ -2068,7 +2082,6 @@ def is_quorum_reached(args: Any):
20682082
20692083
20702084def get_pending_actions_full_info (args : Any ):
2071- # TODO: needs fix
20722085 validate_proxy_argument (args )
20732086
20742087 abi = Abi .load (Path (args .abi ))
@@ -2078,9 +2091,10 @@ def get_pending_actions_full_info(args: Any):
20782091 contract = Address .new_from_bech32 (args .contract )
20792092
20802093 controller = MultisigController (chain_id , proxy , abi )
2081- values = controller .get_pending_actions_full_info (contract )
2094+ actions = controller .get_pending_actions_full_info (contract )
20822095
2083- print (values )
2096+ output = [_convert_action_full_info_to_dict (action ) for action in actions ]
2097+ utils .dump_out_json (output )
20842098
20852099
20862100def get_user_role (args : Any ):
@@ -2140,7 +2154,6 @@ def get_all_proposers(args: Any):
21402154
21412155
21422156def get_action_data (args : Any ):
2143- # TODO: needs fix
21442157 validate_proxy_argument (args )
21452158
21462159 abi = Abi .load (Path (args .abi ))
@@ -2152,8 +2165,8 @@ def get_action_data(args: Any):
21522165 contract = Address .new_from_bech32 (args .contract )
21532166 action = args .action
21542167
2155- value = controller .get_action_data (contract = contract , action_id = action )
2156- print ( value )
2168+ action_data = controller .get_action_data (contract = contract , action_id = action )
2169+ utils . dump_out_json ( _convert_action_to_dict ( action_data ) )
21572170
21582171
21592172def get_action_signers (args : Any ):
@@ -2254,3 +2267,145 @@ def _send_or_simulate(tx: Transaction, contract_address: Address, args: Any):
22542267 output_builder = cli_shared .send_or_simulate (tx , args , dump_output = False )
22552268 output_builder .set_contract_address (contract_address )
22562269 utils .dump_out_json (output_builder .build (), outfile = args .outfile )
2270+
2271+
2272+ def _convert_action_to_dict (action : Action ) -> dict [str , Any ]:
2273+ if isinstance (action , AddBoardMember ):
2274+ return _convert_add_board_member_to_dict (action )
2275+ elif isinstance (action , AddProposer ):
2276+ return _convert_add_proposer_to_dict (action )
2277+ elif isinstance (action , RemoveUser ):
2278+ return _convert_remove_user_to_dict (action )
2279+ elif isinstance (action , ChangeQuorum ):
2280+ return _convert_change_quorum_to_dict (action )
2281+ elif isinstance (action , SendTransferExecuteEgld ):
2282+ return _convert_send_transfer_execute_egld_to_dict (action )
2283+ elif isinstance (action , SendTransferExecuteEsdt ):
2284+ return _convert_send_transfer_execute_esdt_to_dict (action )
2285+ elif isinstance (action , SendAsyncCall ):
2286+ return _convert_send_async_call_to_dict (action )
2287+ elif isinstance (action , SCDeployFromSource ):
2288+ return _convert_sc_deploy_from_source_to_dict (action )
2289+ elif isinstance (action , SCUpgradeFromSource ):
2290+ return _convert_sc_upgrade_from_source_to_dict (action )
2291+ else :
2292+ raise Exception (f"Unknown action type: { type (action )} " )
2293+
2294+
2295+ def _convert_add_board_member_to_dict (action : AddBoardMember ) -> dict [str , Any ]:
2296+ return {
2297+ "type" : "AddBoardMember" ,
2298+ "discriminant" : action .discriminant ,
2299+ "address" : action .address .to_bech32 (),
2300+ }
2301+
2302+
2303+ def _convert_add_proposer_to_dict (action : AddProposer ) -> dict [str , Any ]:
2304+ return {
2305+ "type" : "AddProposer" ,
2306+ "discriminant" : action .discriminant ,
2307+ "address" : action .address .to_bech32 (),
2308+ }
2309+
2310+
2311+ def _convert_remove_user_to_dict (action : RemoveUser ) -> dict [str , Any ]:
2312+ return {
2313+ "type" : "RemoveUser" ,
2314+ "discriminant" : action .discriminant ,
2315+ "address" : action .address .to_bech32 (),
2316+ }
2317+
2318+
2319+ def _convert_change_quorum_to_dict (action : ChangeQuorum ) -> dict [str , Any ]:
2320+ return {
2321+ "type" : "ChangeQuorum" ,
2322+ "discriminant" : action .discriminant ,
2323+ "quorum" : action .quorum ,
2324+ }
2325+
2326+
2327+ def _convert_send_transfer_execute_egld_to_dict (action : SendTransferExecuteEgld ) -> dict [str , Any ]:
2328+ return {
2329+ "type" : "SendTransferExecuteEgld" ,
2330+ "discriminant" : action .discriminant ,
2331+ "callActionData" : _convert_call_action_data_to_dict (action .data ),
2332+ }
2333+
2334+
2335+ def _convert_call_action_data_to_dict (call_action_data : CallActionData ) -> dict [str , Any ]:
2336+ return {
2337+ "to" : call_action_data .to .to_bech32 (),
2338+ "egldAmount" : call_action_data .egld_amount ,
2339+ "optGasLimit" : call_action_data .opt_gas_limit ,
2340+ "endpointName" : call_action_data .endpoint_name ,
2341+ "arguments" : [arg .hex () for arg in call_action_data .arguments ],
2342+ }
2343+
2344+
2345+ def _convert_send_transfer_execute_esdt_to_dict (action : SendTransferExecuteEsdt ) -> dict [str , Any ]:
2346+ return {
2347+ "type" : "SendTransferExecuteEsdt" ,
2348+ "discriminant" : action .discriminant ,
2349+ "esdtTransferExecuteData" : _convert_esdt_transfer_execute_data_to_dict (action .data ),
2350+ }
2351+
2352+
2353+ def _convert_esdt_transfer_execute_data_to_dict (call_action_data : EsdtTransferExecuteData ) -> dict [str , Any ]:
2354+ return {
2355+ "to" : call_action_data .to .to_bech32 (),
2356+ "tokens" : _convert_tokens_to_dict (call_action_data .tokens ),
2357+ "optGasLimit" : call_action_data .opt_gas_limit ,
2358+ "endpointName" : call_action_data .endpoint_name ,
2359+ "arguments" : [arg .hex () for arg in call_action_data .arguments ],
2360+ }
2361+
2362+
2363+ def _convert_tokens_to_dict (tokens : list [EsdtTokenPayment ]) -> list [dict [str , Any ]]:
2364+ return [
2365+ {
2366+ "tokenIdentifier" : token .fields [0 ].get_payload (),
2367+ "tokenNonce" : token .fields [1 ].get_payload (),
2368+ "amount" : token .fields [2 ].get_payload (),
2369+ }
2370+ for token in tokens
2371+ ]
2372+
2373+
2374+ def _convert_send_async_call_to_dict (action : SendAsyncCall ) -> dict [str , Any ]:
2375+ return {
2376+ "type" : "SendAsyncCall" ,
2377+ "discriminant" : action .discriminant ,
2378+ "callActionData" : _convert_call_action_data_to_dict (action .data ),
2379+ }
2380+
2381+
2382+ def _convert_sc_deploy_from_source_to_dict (action : SCDeployFromSource ) -> dict [str , Any ]:
2383+ return {
2384+ "type" : "SCDeployFromSource" ,
2385+ "discriminant" : action .discriminant ,
2386+ "amount" : action .amount ,
2387+ "source" : action .source .to_bech32 (),
2388+ "codeMetadata" : action .code_metadata .hex (),
2389+ "arguments" : [arg .hex () for arg in action .arguments ],
2390+ }
2391+
2392+
2393+ def _convert_sc_upgrade_from_source_to_dict (action : SCUpgradeFromSource ) -> dict [str , Any ]:
2394+ return {
2395+ "type" : "SCDeployFromSource" ,
2396+ "discriminant" : action .discriminant ,
2397+ "scAddress" : action .sc_address .to_bech32 (),
2398+ "amount" : action .amount ,
2399+ "source" : action .source .to_bech32 (),
2400+ "codeMetadata" : action .code_metadata .hex (),
2401+ "arguments" : [arg .hex () for arg in action .arguments ],
2402+ }
2403+
2404+
2405+ def _convert_action_full_info_to_dict (action : ActionFullInfo ) -> dict [str , Any ]:
2406+ return {
2407+ "actionId" : action .action_id ,
2408+ "groupId" : action .group_id ,
2409+ "actionData" : _convert_action_to_dict (action .action_data ),
2410+ "signers" : [signer .to_bech32 () for signer in action .signers ],
2411+ }
0 commit comments