pub struct SimulationResult { /* private fields */ }Expand description
Result of a transaction simulation.
Contains detailed information about what would happen if the transaction were submitted to the network.
Implementations§
Source§impl SimulationResult
impl SimulationResult
Sourcepub fn from_response(response: Vec<Value>) -> AptosResult<Self>
pub fn from_response(response: Vec<Value>) -> AptosResult<Self>
Parses a simulation result from the API response.
§Errors
Returns an error if the response is empty or if parsing the JSON fails.
Sourcepub fn from_json(data: Value) -> AptosResult<Self>
pub fn from_json(data: Value) -> AptosResult<Self>
Parses a simulation result from JSON.
§Errors
Returns an error if the JSON structure is invalid or missing required fields.
Sourcepub fn max_gas_amount(&self) -> u64
pub fn max_gas_amount(&self) -> u64
Returns the maximum gas amount specified.
Sourcepub fn gas_unit_price(&self) -> u64
pub fn gas_unit_price(&self) -> u64
Returns the gas unit price.
Sourcepub fn safe_gas_estimate(&self) -> u64
pub fn safe_gas_estimate(&self) -> u64
Returns the estimated gas cost with a safety margin.
Adds 20% to the simulated gas to account for variations.
Sourcepub fn changes(&self) -> &[StateChange]
pub fn changes(&self) -> &[StateChange]
Returns the state changes that would be made.
Sourcepub fn events(&self) -> &[SimulatedEvent]
pub fn events(&self) -> &[SimulatedEvent]
Returns the events that would be emitted.
Sourcepub fn vm_error(&self) -> Option<&VmError>
pub fn vm_error(&self) -> Option<&VmError>
Returns detailed VM error information if the simulation failed.
Sourcepub fn is_insufficient_balance(&self) -> bool
pub fn is_insufficient_balance(&self) -> bool
Checks if the failure is due to insufficient balance.
Sourcepub fn is_sequence_number_error(&self) -> bool
pub fn is_sequence_number_error(&self) -> bool
Checks if the failure is due to sequence number issues.
Sourcepub fn is_out_of_gas(&self) -> bool
pub fn is_out_of_gas(&self) -> bool
Checks if the failure is due to out of gas.
Sourcepub fn error_message(&self) -> Option<String>
pub fn error_message(&self) -> Option<String>
Returns a user-friendly error message if the simulation failed.
Trait Implementations§
Source§impl Clone for SimulationResult
impl Clone for SimulationResult
Source§fn clone(&self) -> SimulationResult
fn clone(&self) -> SimulationResult
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more