Skip to content

Commit e2f8fa7

Browse files
authored
chore: always parse function name for transaction receipts (#694)
1 parent 817056f commit e2f8fa7

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

src/worker/tasks/processTransactionReceiptsWorker.ts

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import { Prisma } from "@prisma/client";
2-
import { AbiEvent } from "abitype";
3-
import { Job, Processor, Worker } from "bullmq";
1+
import type { Prisma } from "@prisma/client";
2+
import type { AbiEvent } from "abitype";
3+
import { Worker, type Job, type Processor } from "bullmq";
44
import superjson from "superjson";
55
import {
6-
Address,
7-
ThirdwebContract,
86
eth_getBlockByNumber,
97
eth_getTransactionReceipt,
108
getContract,
119
getRpcClient,
10+
type Address,
11+
type ThirdwebContract,
1212
} from "thirdweb";
1313
import { resolveContractAbi } from "thirdweb/contract";
14-
import { Abi, Hash, decodeFunctionData } from "viem";
14+
import { decodeFunctionData, type Abi, type Hash } from "viem";
1515
import { bulkInsertContractTransactionReceipts } from "../../db/contractTransactionReceipts/createContractTransactionReceipts";
1616
import { WebhooksEventTypes } from "../../schema/webhooks";
1717
import { getChain } from "../../utils/chain";
@@ -20,8 +20,8 @@ import { normalizeAddress } from "../../utils/primitiveTypes";
2020
import { redis } from "../../utils/redis/redis";
2121
import { thirdwebClient } from "../../utils/sdk";
2222
import {
23-
EnqueueProcessTransactionReceiptsData,
2423
ProcessTransactionReceiptsQueue,
24+
type EnqueueProcessTransactionReceiptsData,
2525
} from "../queues/processTransactionReceiptsQueue";
2626
import { logWorkerExceptions } from "../queues/queues";
2727
import { SendWebhookQueue } from "../queues/sendWebhookQueue";
@@ -55,9 +55,8 @@ const handler: Processor<any, void, string> = async (job: Job<string>) => {
5555
}
5656

5757
// Enqueue webhooks.
58-
const webhooksByContractAddress = await getWebhooksByContractAddresses(
59-
chainId,
60-
);
58+
const webhooksByContractAddress =
59+
await getWebhooksByContractAddresses(chainId);
6160
for (const transactionReceipt of insertedReceipts) {
6261
const webhooks =
6362
webhooksByContractAddress[transactionReceipt.contractAddress] ?? [];
@@ -154,17 +153,16 @@ const getFormattedTransactionReceipts = async ({
154153
continue;
155154
}
156155

157-
let functionName: string | undefined = undefined;
158-
if (config.functions.length > 0) {
159-
functionName = await getFunctionName({
160-
contract: config.contract,
161-
data: transaction.input,
162-
});
163-
164-
if (!config.functions.includes(functionName)) {
165-
// This transaction is not for a subscribed function name.
166-
continue;
167-
}
156+
const functionName = await getFunctionName({
157+
contract: config.contract,
158+
data: transaction.input,
159+
});
160+
if (
161+
config.functions.length > 0 &&
162+
!config.functions.includes(functionName)
163+
) {
164+
// This transaction is not for a subscribed function name.
165+
continue;
168166
}
169167

170168
// Store the transaction and receipt.

0 commit comments

Comments
 (0)