diff --git a/algosdk/atomic_transaction_composer.py b/algosdk/atomic_transaction_composer.py index 24d325aa..4df0985b 100644 --- a/algosdk/atomic_transaction_composer.py +++ b/algosdk/atomic_transaction_composer.py @@ -315,6 +315,7 @@ def __init__( tx_ids: List[str], results: List[SimulateABIResult], eval_overrides: Optional[SimulateEvalOverrides] = None, + exec_trace_config: Optional[models.SimulateTraceConfig] = None, ) -> None: self.version = version self.failure_message = failure_message @@ -323,6 +324,7 @@ def __init__( self.tx_ids = tx_ids self.abi_results = results self.eval_overrides = eval_overrides + self.exec_trace_config = exec_trace_config class AtomicTransactionComposer: @@ -796,8 +798,6 @@ def simulate( # build up data structure with fields we'd want sim_results = [] for idx, result in enumerate(method_results): - sim_txn: Dict[str, Any] = txn_group["txn-results"][idx] - sim_results.append( SimulateABIResult( tx_id=result.tx_id, @@ -809,6 +809,14 @@ def simulate( ) ) + exec_trace_config: Optional[models.SimulateTraceConfig] = ( + None + if "exec-trace-config" not in simulation_result + else models.SimulateTraceConfig.undictify( + simulation_result["exec-trace-config"] + ) + ) + return SimulateAtomicTransactionResponse( version=simulation_result.get("version", 0), failure_message=txn_group.get("failure-message", ""), @@ -819,6 +827,7 @@ def simulate( eval_overrides=SimulateEvalOverrides.from_simulation_result( simulation_result ), + exec_trace_config=exec_trace_config, ) def execute( diff --git a/algosdk/v2client/models/__init__.py b/algosdk/v2client/models/__init__.py index 018d28d5..8a005972 100644 --- a/algosdk/v2client/models/__init__.py +++ b/algosdk/v2client/models/__init__.py @@ -36,8 +36,6 @@ SimulateRequestTransactionGroup, SimulateTraceConfig, ) -from algosdk.v2client.models.avm_value import AVMValue -from algosdk.v2client.models.simulate_exec_trace import SimulateExecTrace __all__ = [ "Account", @@ -56,6 +54,4 @@ "SimulateRequest", "SimulateRequestTransactionGroup", "SimulateTraceConfig", - "AVMValue", - "SimulateExecTrace", ] diff --git a/algosdk/v2client/models/avm_value.py b/algosdk/v2client/models/avm_value.py deleted file mode 100644 index a85bd72a..00000000 --- a/algosdk/v2client/models/avm_value.py +++ /dev/null @@ -1,21 +0,0 @@ -from typing import Dict, Any, Optional - - -class AVMValue: - type: int - uint: int - bytes: bytes - - def __init__( - self, *, type: int = 0, uint: int = 0, _bytes: Optional[bytes] = None - ) -> None: - self.type = type - self.uint = uint - self.bytes = _bytes if _bytes else b"" - - def dictify(self) -> Dict[str, Any]: - return { - "type": self.type, - "uint": self.uint, - "bytes": self.bytes, - } diff --git a/algosdk/v2client/models/simulate_exec_trace.py b/algosdk/v2client/models/simulate_exec_trace.py deleted file mode 100644 index 4cf076e3..00000000 --- a/algosdk/v2client/models/simulate_exec_trace.py +++ /dev/null @@ -1,31 +0,0 @@ -from typing import Dict, Any, List - -from algosdk.v2client.models import AVMValue - - -class SimulateExecTrace: - approval_program_trace: List[AVMValue] - clear_state_program_trace: List[AVMValue] - logic_sig_trace: List[AVMValue] - inner_trace: "List[SimulateExecTrace]" - - def __init__( - self, - *, - approval_program_trace: List[AVMValue], - clear_state_program_trace: List[AVMValue], - logic_sig_trace: List[AVMValue], - inner_trace: "List[SimulateExecTrace]" - ): - self.approval_program_trace = approval_program_trace - self.clear_state_program_trace = clear_state_program_trace - self.logic_sig_trace = logic_sig_trace - self.inner_trace = inner_trace - - def dictify(self) -> Dict[str, Any]: - return { - "approval-program-trace": self.approval_program_trace, - "clear-state-program-trace": self.clear_state_program_trace, - "logic-sig-trace": self.logic_sig_trace, - "inner-trace": self.inner_trace, - } diff --git a/algosdk/v2client/models/simulate_request.py b/algosdk/v2client/models/simulate_request.py index e5ee022d..58e3a594 100644 --- a/algosdk/v2client/models/simulate_request.py +++ b/algosdk/v2client/models/simulate_request.py @@ -39,6 +39,14 @@ def dictify(self) -> Dict[str, Any]: "scratch-change": self.scratch_change, } + @staticmethod + def undictify(d: Dict[str, Any]) -> "SimulateTraceConfig": + return SimulateTraceConfig( + enable="enable" in d and d["enable"], + stack_change="stack-change" in d and d["stack-change"], + scratch_change="scratch-change" in d and d["scratch-change"], + ) + class SimulateRequest: txn_groups: List[SimulateRequestTransactionGroup] diff --git a/tests/steps/other_v2_steps.py b/tests/steps/other_v2_steps.py index 3c21c7f4..71a5d670 100644 --- a/tests/steps/other_v2_steps.py +++ b/tests/steps/other_v2_steps.py @@ -1543,10 +1543,22 @@ def exec_trace_config_in_simulation(context, options: str): ) -@then(u'{unit_index}th unit in the "{trace_type}" trace at txn-groups path "{group_path}" should add to stack "{stack_addition:MaybeString}", pop from stack by {pop_count}, write to "{scratch_index}" scratch slot by "{scratch_var}".') -def step_impl(context, unit_index, trace_type, group_path, stack_addition: str, pop_count, scratch_index, scratch_var): - raise NotImplementedError(u'STEP: Then 4th unit in the "approval" trace at txn-groups path "0" should add to stack "uint64:2", pop from stack by 2, write to "none" scratch slot by "none".') - +@then( + '{unit_index}th unit in the "{trace_type}" trace at txn-groups path "{group_path}" should add to stack "{stack_addition:MaybeString}", pop from stack by {pop_count}, write to "{scratch_index}" scratch slot by "{scratch_var}".' +) +def step_impl( + context, + unit_index, + trace_type, + group_path, + stack_addition: str, + pop_count, + scratch_index, + scratch_var, +): + raise NotImplementedError( + 'STEP: Then 4th unit in the "approval" trace at txn-groups path "0" should add to stack "uint64:2", pop from stack by 2, write to "none" scratch slot by "none".' + ) @when("we make a SetSyncRound call against round {round}")