Skip to content

Commit 96c154f

Browse files
committed
fix: throw COULD_NOT_SIMULATE_TRANSACTION for eth_call
Signed-off-by: Logan Nguyen <[email protected]>
1 parent a48c393 commit 96c154f

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

packages/relay/src/lib/services/ethService/contractService/ContractService.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -526,14 +526,13 @@ export class ContractService implements IContractService {
526526
}
527527

528528
if (e.isContractRevert()) {
529-
if (this.logger.isLevelEnabled('trace')) {
530-
this.logger.trace(
531-
`mirror node eth_call request encountered contract revert. message: ${e.message}, details: ${e.detail}, data: ${e.data}`,
532-
);
533-
}
534-
return predefined.CONTRACT_REVERT(e.detail || e.message, e.data);
529+
throw predefined.CONTRACT_REVERT(e.detail || e.message, e.data);
530+
} else if (e.statusCode === 400) {
531+
throw predefined.COULD_NOT_SIMULATE_TRANSACTION(e.detail || e.message);
535532
}
536-
// for any other Mirror Node upstream server errors (429, 500, 502, 503, 504, etc.), preserve the original error and re-throw to the upper layer
533+
534+
// for any other error or Mirror Node upstream server errors (429, 500, 502, 503, 504, etc.),
535+
// preserve the original error and re-throw to the upper layer for further handling logic
537536
throw e;
538537
}
539538

packages/server/tests/acceptance/htsPrecompile/precompileCalls.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,11 @@ describe('@precompile-calls Tests for eth_call with HTS', async function () {
741741
data: CALLDATA_BALANCE_OF + NON_EXISTING_ACCOUNT.padStart(64, '0'),
742742
};
743743

744-
await relay.callFailing(Constants.ETH_ENDPOINTS.ETH_CALL, [callData, 'latest'], predefined.CONTRACT_REVERT());
744+
await relay.callFailing(
745+
Constants.ETH_ENDPOINTS.ETH_CALL,
746+
[callData, 'latest'],
747+
predefined.COULD_NOT_SIMULATE_TRANSACTION('Sender account not found.'),
748+
);
745749
});
746750

747751
it('Call to allowance method of an HTS token with non-existing owner account in call data returns error', async () => {

0 commit comments

Comments
 (0)