Skip to content

Commit

Permalink
muck up changes for SimulateATCResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
ahangsu committed Apr 25, 2023
1 parent d04d2b4 commit f67ff32
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions algosdk/atomic_transaction_composer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from algosdk.transaction import GenericSignedTransaction
from algosdk.abi.address_type import AddressType
from algosdk.v2client import algod
from algosdk.v2client.models import models
from algosdk.v2client import models

# The first four bytes of an ABI method call return must have this hash
ABI_RETURN_HASH = b"\x15\x1f\x7c\x75"
Expand Down Expand Up @@ -267,6 +267,34 @@ def __init__(
self.missing_signature = missing_signature


class SimulateEvalOverrides:
def __init__(
self,
*,
max_log_calls: Optional[int] = None,
max_log_size: Optional[int] = None,
) -> None:
self.max_log_calls = max_log_calls
self.max_log_size = max_log_size

@staticmethod
def from_simulation_result(
simulation_result: Dict[str, Any]
) -> Optional["SimulateEvalOverrides"]:
if "eval-overrides" not in simulation_result:
return None

eval_override_dict = simulation_result.get("eval-overrides", dict())
eval_override = SimulateEvalOverrides()

if "max-log-calls" in eval_override_dict:
eval_override.max_log_calls = eval_override_dict["max-log-calls"]
if "max-log-size" in eval_override_dict:
eval_override.max_log_size = eval_override_dict["max-log-size"]

return eval_override


class SimulateAtomicTransactionResponse:
def __init__(
self,
Expand All @@ -277,6 +305,7 @@ def __init__(
simulate_response: Dict[str, Any],
tx_ids: List[str],
results: List[SimulateABIResult],
eval_overrides: Optional[SimulateEvalOverrides],
) -> None:
self.version = version
self.would_succeed = would_succeed
Expand All @@ -285,6 +314,7 @@ def __init__(
self.simulate_response = simulate_response
self.tx_ids = tx_ids
self.abi_results = results
self.eval_overrides = eval_overrides


class AtomicTransactionComposer:
Expand Down Expand Up @@ -770,12 +800,17 @@ def __report_simulation_response(self, simulation_result: Dict[str, Any]):
simulate_response=simulation_result,
tx_ids=self.tx_ids,
results=sim_results,
eval_overrides=SimulateEvalOverrides.from_simulation_result(
simulation_result
),
)

def simulate_with_request(
self,
client: algod.AlgodClient,
request: models.SimulateRequest = models.SimulateRequest(),
request: models.SimulateRequest = models.SimulateRequest(
txn_groups=list()
),
):
current_simulation_request = request

Expand Down

0 comments on commit f67ff32

Please sign in to comment.