Skip to content

Commit 90c3595

Browse files
committed
fix filter
1 parent f9f32f1 commit 90c3595

File tree

2 files changed

+14
-28
lines changed
  • apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/cross-chain
  • packages/thirdweb/src/event/actions

2 files changed

+14
-28
lines changed

apps/dashboard/src/app/(dashboard)/(chain)/[chain_id]/[contractAddress]/cross-chain/page.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ export default async function Page(props: {
3838
chain_id: string;
3939
}>;
4040
}) {
41+
const params = await props.params;
42+
const info = await getContractPageParamsInfo(params);
43+
4144
const ProxyDeployedEvent = prepareEvent({
4245
signature:
4346
"event ProxyDeployedV2(address indexed implementation, address indexed proxy, address indexed deployer, bytes32 inputSalt, bytes data, bytes extraData)",
47+
filters: {
48+
proxy: params.contractAddress.toLowerCase(),
49+
},
4450
});
4551

46-
const params = await props.params;
47-
const info = await getContractPageParamsInfo(params);
48-
4952
if (!info) {
5053
notFound();
5154
}
@@ -113,12 +116,6 @@ export default async function Page(props: {
113116
const events = await getContractEvents({
114117
contract: twCloneFactoryContract,
115118
events: [ProxyDeployedEvent],
116-
insightTopicFilters: [
117-
{
118-
topic: params.contractAddress as `0x${string}`,
119-
index: 2,
120-
},
121-
],
122119
});
123120
const event = events.find(
124121
(e) =>
@@ -206,7 +203,6 @@ export default async function Page(props: {
206203
const events = await getContractEvents({
207204
contract: contract,
208205
events: [moduleEvent],
209-
blockRange: 123456n,
210206
});
211207

212208
const filteredEvents = events.filter(

packages/thirdweb/src/event/actions/get-events.ts

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,8 @@ export type GetContractEventsResult<
5757

5858
export type GetLogsParamsExtra = {
5959
signature?: string;
60-
insightTopicFilters?: InsightTopicFilter[];
6160
} & GetLogsParams;
6261

63-
export type InsightTopicFilter = {
64-
topic: Hex;
65-
index: 1 | 2 | 3;
66-
};
67-
6862
/**
6963
* Retrieves events from a contract based on the provided options.
7064
* @param options - The options for retrieving events.
@@ -120,9 +114,7 @@ export async function getContractEvents<
120114
>[],
121115
const TStrict extends boolean = true,
122116
>(
123-
options: GetContractEventsOptions<abi, abiEvents, TStrict> & {
124-
insightTopicFilters?: InsightTopicFilter[];
125-
},
117+
options: GetContractEventsOptions<abi, abiEvents, TStrict>,
126118
): Promise<GetContractEventsResult<abiEvents, TStrict>> {
127119
const { contract, events, blockRange, ...restParams } = options;
128120

@@ -190,7 +182,6 @@ export async function getContractEvents<
190182
address: getAddress(contract.address),
191183
topics: e.topics,
192184
signature: `${e?.abiEvent.name}(${e?.abiEvent.inputs.map((i) => i.type).join(",")})`,
193-
insightTopicFilters: options.insightTopicFilters,
194185
}))
195186
: // otherwise we want "all" events (aka not pass any topics at all)
196187
[{ ...restParams, address: getAddress(contract.address) }];
@@ -229,9 +220,8 @@ async function getLogsFromInsight(options: {
229220
chain: Chain;
230221
client: ThirdwebClient;
231222
signature?: string;
232-
insightTopicFilters?: InsightTopicFilter[];
233223
}): Promise<Log[]> {
234-
const { params, chain, client, signature, insightTopicFilters } = options;
224+
const { params, chain, client, signature } = options;
235225

236226
const chainServices = await getChainServices(chain);
237227
const insightEnabled = chainServices.some(
@@ -277,12 +267,12 @@ async function getLogsFromInsight(options: {
277267
}
278268
}
279269

280-
if (insightTopicFilters) {
281-
for (const topicFilter of insightTopicFilters) {
282-
url.searchParams.set(
283-
`filter_topic_${topicFilter.index}`,
284-
topicFilter.topic,
285-
);
270+
if (params.topics) {
271+
const args = params.topics.slice(1);
272+
for (const [i, a] of args.entries()) {
273+
if (a) {
274+
url.searchParams.set(`filter_topic_${i + 1}`, a as Hex);
275+
}
286276
}
287277
}
288278

0 commit comments

Comments
 (0)