Skip to content

Commit d25788e

Browse files
authored
fix: return 400 if transaction logs not found (#780)
1 parent 39f1fc2 commit d25788e

File tree

1 file changed

+8
-5
lines changed
  • src/server/routes/transaction/blockchain

1 file changed

+8
-5
lines changed

src/server/routes/transaction/blockchain/getLogs.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
type Hex,
1313
} from "thirdweb";
1414
import { resolveContractAbi } from "thirdweb/contract";
15+
import { TransactionReceipt } from "thirdweb/transaction";
1516
import { TransactionDB } from "../../../../db/transactions/db";
1617
import { getChain } from "../../../../utils/chain";
1718
import { thirdwebClient } from "../../../../utils/sdk";
@@ -168,12 +169,14 @@ export async function getTransactionLogs(fastify: FastifyInstance) {
168169
}
169170

170171
// Try to get the receipt.
171-
const transactionReceipt = await eth_getTransactionReceipt(rpcRequest, {
172-
hash,
173-
});
174-
if (!transactionReceipt) {
172+
let transactionReceipt: TransactionReceipt | undefined;
173+
try {
174+
transactionReceipt = await eth_getTransactionReceipt(rpcRequest, {
175+
hash,
176+
});
177+
} catch {
175178
throw createCustomError(
176-
"Cannot get logs for a transaction that is not mined.",
179+
"Unable to get transaction receipt. The transaction may not have been mined yet.",
177180
StatusCodes.BAD_REQUEST,
178181
"TRANSACTION_NOT_MINED",
179182
);

0 commit comments

Comments
 (0)