diff --git a/explorer/src/components/transaction/ProgramLogSection.tsx b/explorer/src/components/transaction/ProgramLogSection.tsx index 1ded8fcbd..ae429a9ec 100644 --- a/explorer/src/components/transaction/ProgramLogSection.tsx +++ b/explorer/src/components/transaction/ProgramLogSection.tsx @@ -15,7 +15,11 @@ export function ProgramLogSection({ signature }: SignatureProps) { const logMessages = transaction.meta?.logMessages || null; const err = transaction.meta?.err || null; - const prettyLogs = prettyProgramLogs(logMessages, err, cluster); + + let prettyLogs = null; + if (logMessages !== null) { + prettyLogs = prettyProgramLogs(logMessages, err, cluster); + } return ( <> @@ -23,11 +27,17 @@ export function ProgramLogSection({ signature }: SignatureProps) {

Program Logs

- + {prettyLogs !== null ? ( + + ) : ( +
+ Logs not supported for this transaction +
+ )} ); diff --git a/explorer/src/pages/inspector/SimulatorCard.tsx b/explorer/src/pages/inspector/SimulatorCard.tsx index 33bbe5e6b..fd549efb7 100644 --- a/explorer/src/pages/inspector/SimulatorCard.tsx +++ b/explorer/src/pages/inspector/SimulatorCard.tsx @@ -101,6 +101,9 @@ function useSimulator(message: Message) { // Simulate without signers to skip signer verification const resp = await connection.simulateTransaction(tx); + if (resp.value.logs === null) { + throw new Error("Expected to receive logs from simulation"); + } // Prettify logs setLogs(prettyProgramLogs(resp.value.logs, resp.value.err, cluster)); diff --git a/explorer/src/utils/program-logs.ts b/explorer/src/utils/program-logs.ts index fb5935b9e..4b01ecd94 100644 --- a/explorer/src/utils/program-logs.ts +++ b/explorer/src/utils/program-logs.ts @@ -15,7 +15,7 @@ export type InstructionLogs = { }; export function prettyProgramLogs( - logs: string[] | null, + logs: string[], error: TransactionError | null, cluster: Cluster ): InstructionLogs[] { @@ -27,10 +27,7 @@ export function prettyProgramLogs( }; let prettyError; - if (!logs) { - if (error) throw new Error(JSON.stringify(error)); - throw new Error("No logs detected"); - } else if (error) { + if (error) { prettyError = getTransactionInstructionError(error); }