diff --git a/src/components/tx/TxSimulation/SimulationResult.tsx b/src/components/tx/TxSimulation/SimulationResult.tsx index f4cbd8a0da..f4bd9ec4ff 100644 --- a/src/components/tx/TxSimulation/SimulationResult.tsx +++ b/src/components/tx/TxSimulation/SimulationResult.tsx @@ -15,6 +15,14 @@ type SimulationResultProps = { onClose: () => void } +const getCallTraceErrors = (simulation?: TenderlySimulation) => { + if (!simulation) { + return [] + } + + return simulation.transaction.call_trace.filter((call) => call.error) +} + export const SimulationResult = ({ simulationRequestStatus, simulation, @@ -30,8 +38,13 @@ export const SimulationResult = ({ return null } + const isSuccess = simulation?.simulation.status + + // Safe can emit failure event even though Tenderly simulation succeeds + const isCallTraceError = isSuccess && getCallTraceErrors(simulation).length > 0 + // Error - if (requestError || !simulation?.simulation.status) { + if (requestError || !isSuccess || isCallTraceError) { return ( @@ -44,9 +57,16 @@ export const SimulationResult = ({ ) : ( - The transaction failed during the simulation throwing error {simulation?.transaction.error_message}{' '} - in the contract at {simulation?.transaction.error_info?.address}. Full simulation report is available{' '} - on Tenderly. + {isCallTraceError ? ( + <>The transaction failed during the simulation. + ) : ( + <> + The transaction failed during the simulation throwing error{' '} + {simulation?.transaction.error_message} in the contract at{' '} + {simulation?.transaction.error_info?.address}. + + )}{' '} + Full simulation report is available on Tenderly. )} diff --git a/src/components/tx/TxSimulation/types.ts b/src/components/tx/TxSimulation/types.ts index 8ea3446a11..a15dedfb6b 100644 --- a/src/components/tx/TxSimulation/types.ts +++ b/src/components/tx/TxSimulation/types.ts @@ -256,6 +256,11 @@ interface Transaction { timestamp: Date method: string decoded_input: null + // Note: manually added (partial keys of `call_trace`) + call_trace: Array<{ + error?: string + input: string + }> } interface TransactionInfo {