Skip to content

Commit 5569a35

Browse files
authored
fix: allowed callTracer to return empty array if no call actions found (#3768)
Signed-off-by: Logan Nguyen <logan.nguyen@swirldslabs.com>
1 parent fca86cc commit 5569a35

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

packages/relay/src/lib/debug.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export class DebugImpl implements Debug {
429429
transactionHash: string,
430430
tracerConfig: ICallTracerConfig,
431431
requestDetails: RequestDetails,
432-
): Promise<CallTracerResult> {
432+
): Promise<CallTracerResult | null> {
433433
try {
434434
const [actionsResponse, transactionsResponse] = await Promise.all([
435435
this.mirrorNodeClient.getContractsResultsActions(transactionHash, requestDetails),
@@ -444,6 +444,9 @@ export class DebugImpl implements Debug {
444444
throw predefined.RESOURCE_NOT_FOUND(`Failed to retrieve contract results for transaction ${transactionHash}`);
445445
}
446446

447+
// return empty array if no actions
448+
if (actionsResponse.length === 0) return null;
449+
447450
const { call_type: type } = actionsResponse[0];
448451
const formattedActions = await this.formatActionsResult(actionsResponse, requestDetails);
449452

packages/relay/src/lib/types/debug.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,5 +73,5 @@ export interface TraceBlockByNumberTxResult {
7373
/**
7474
* The result of the trace, which can be either a {@link CallTracerResult} or an {@link EntityTraceStateMap}.
7575
*/
76-
result: CallTracerResult | EntityTraceStateMap;
76+
result: CallTracerResult | EntityTraceStateMap | null;
7777
}

packages/relay/tests/lib/debug.spec.ts

+13
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,19 @@ describe('Debug API Test Suite', async function () {
422422

423423
expect(result).to.deep.equal(expectedResult);
424424
});
425+
426+
it('Should return empty array if no actions found', async function () {
427+
restMock.onGet(CONTARCTS_RESULTS_ACTIONS).reply(200, JSON.stringify({ actions: [] }));
428+
429+
const result = await debugService.traceTransaction(
430+
transactionHash,
431+
callTracer,
432+
tracerConfigFalse,
433+
requestDetails,
434+
);
435+
436+
expect(result).to.be.null;
437+
});
425438
});
426439

427440
describe('opcodeLogger', async function () {

0 commit comments

Comments
 (0)