Skip to content

Commit 766e444

Browse files
committed
docs: update webhook parameter filtering types and add example
1 parent ebd415e commit 766e444

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components/FilterDetailsStep.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,7 @@ export function FilterDetailsStep({
191191
render={({ field }) => (
192192
<FormItem className="flex flex-col">
193193
<div className="flex items-center justify-between text-xs">
194-
<FormLabel>
195-
Contract Addresses
196-
</FormLabel>
194+
<FormLabel>Contract Addresses</FormLabel>
197195
<p className="text-muted-foreground">
198196
Enter a contract address
199197
</p>
@@ -281,9 +279,7 @@ export function FilterDetailsStep({
281279
render={({ field }) => (
282280
<FormItem className="flex flex-col">
283281
<div className="flex items-center justify-between text-xs">
284-
<FormLabel>
285-
To Address
286-
</FormLabel>
282+
<FormLabel>To Address</FormLabel>
287283
<p className="text-muted-foreground">Enter a to address</p>
288284
</div>
289285
<FormControl>

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/utils/webhookTypes.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ export const webhookFormSchema = z.object({
4242
if (val === undefined || val.trim() === "") {
4343
return true;
4444
}
45-
return val.split(/[\,\s]+/).filter(Boolean).every((a) => isAddress(a.trim()));
45+
return val
46+
.split(/[\,\s]+/)
47+
.filter(Boolean)
48+
.every((a) => isAddress(a.trim()));
4649
},
4750
{
4851
message: "Enter valid addresses (comma-separated) or leave empty",
@@ -65,7 +68,10 @@ export const webhookFormSchema = z.object({
6568
if (val === undefined || val.trim() === "") {
6669
return true;
6770
}
68-
return val.split(/[\,\s]+/).filter(Boolean).every((a) => isAddress(a.trim()));
71+
return val
72+
.split(/[\,\s]+/)
73+
.filter(Boolean)
74+
.every((a) => isAddress(a.trim()));
6975
},
7076
{
7177
message: "Enter valid addresses (comma-separated) or leave empty",

apps/portal/src/app/insight/webhooks/filtering/page.mdx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Each webhook must have either an events filter or a transactions filter (or both
3535
signatures: { // Filter by event signatures
3636
sig_hash: string, // Event signature hash
3737
abi?: string, // Optional ABI for data decoding
38-
params?: Record<string, any> // Filter on decoded parameters
38+
params?: Record<string, string | number> // Filter on decoded parameters
3939
}[]
4040
}
4141
}
@@ -51,7 +51,7 @@ Each webhook must have either an events filter or a transactions filter (or both
5151
signatures: { // Filter by function signatures
5252
sig_hash: string, // Function signature hash
5353
abi?: string, // Optional ABI for data decoding
54-
params?: string[] // Filter on decoded parameters
54+
params?: Record<string, string | number> // Filter on decoded parameters
5555
}[]
5656
}
5757
}
@@ -106,6 +106,27 @@ And this example will filter for `Approve` function calls on Ethereum for the co
106106

107107
`params` on the `signatures` object will allow you to filter based on the decoded data. Only strict equality is supported at the moment.
108108

109+
For example, if you want to filter for `Transfer` events where the `from` address is `0x1f9840a85d5af5bf1d1762f925bdaddc4201f984`, you can use the following:
110+
```typescript
111+
{
112+
...
113+
"filters": {
114+
"v1.events": {
115+
"chain_ids": ["1"],
116+
"addresses": ["0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"],
117+
"signatures": [{
118+
"sig_hash": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
119+
"abi": "{\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"}",
120+
"params": {
121+
"from": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"
122+
}
123+
}]
124+
}
125+
}
126+
...
127+
}
128+
```
129+
109130
### Notes
110131
- You can specify ABIs to receive decoded event/transaction data
111132
- Parameter filtering supports equality matching only

0 commit comments

Comments
 (0)