From 2d15cd6a478a3b131a130d82da4212f52ba384d1 Mon Sep 17 00:00:00 2001 From: catalyst17 Date: Mon, 9 Jun 2025 12:00:22 +0000 Subject: [PATCH] docs: update webhook parameter filtering types and add example (#7295) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # [Portal] Fix: Update webhook parameter filtering documentation ## Notes for the reviewer This PR updates the webhook filtering documentation to: 1. Correct the type definition for `params` in both events and transactions filters 2. Add a practical example showing how to filter for `Transfer` events with specific parameters ## How to test Review the updated documentation to ensure the type definitions are correct and the new example is clear and helpful. --- ## PR-Codex overview This PR updates the `params` property in the webhooks filtering configuration to allow for stricter type definitions, changing it from `Record` to `Record`. It also provides an example of how to filter `Transfer` events. ### Detailed summary - Changed `params` type in the `webhooks` filtering from `Record` to `Record`. - Updated `params` type in the `signatures` object from `string[]` to `Record`. - Added an example for filtering `Transfer` events with a specific `from` address. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` --- .../app/insight/webhooks/filtering/page.mdx | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/portal/src/app/insight/webhooks/filtering/page.mdx b/apps/portal/src/app/insight/webhooks/filtering/page.mdx index ec9d6ec5dbb..d376cbfe40e 100644 --- a/apps/portal/src/app/insight/webhooks/filtering/page.mdx +++ b/apps/portal/src/app/insight/webhooks/filtering/page.mdx @@ -35,7 +35,7 @@ Each webhook must have either an events filter or a transactions filter (or both signatures: { // Filter by event signatures sig_hash: string, // Event signature hash abi?: string, // Optional ABI for data decoding - params?: Record // Filter on decoded parameters + params?: Record // Filter on decoded parameters }[] } } @@ -51,7 +51,7 @@ Each webhook must have either an events filter or a transactions filter (or both signatures: { // Filter by function signatures sig_hash: string, // Function signature hash abi?: string, // Optional ABI for data decoding - params?: string[] // Filter on decoded parameters + params?: Record // Filter on decoded parameters }[] } } @@ -106,6 +106,27 @@ And this example will filter for `Approve` function calls on Ethereum for the co `params` on the `signatures` object will allow you to filter based on the decoded data. Only strict equality is supported at the moment. +For example, if you want to filter for `Transfer` events where the `from` address is `0x1f9840a85d5af5bf1d1762f925bdaddc4201f984`, you can use the following: +```typescript +{ + ... + "filters": { + "v1.events": { + "chain_ids": ["1"], + "addresses": ["0x1f9840a85d5af5bf1d1762f925bdaddc4201f984"], + "signatures": [{ + "sig_hash": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef", + "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\"}", + "params": { + "from": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984" + } + }] + } + } + ... +} +``` + ### Notes - You can specify ABIs to receive decoded event/transaction data - Parameter filtering supports equality matching only