Skip to content

Commit

Permalink
update plugins docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fracek committed Jan 6, 2025
1 parent d93eb5a commit 8e7fa4c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/v2/getting-started/indexers/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ The `factory` function is used to add data filters at runtime. This is useful fo

**Arguments**

- **`block`**: `TBlock`<br/>The block received from the DNA stream. This is chain-specific (see [Beacon Chain](/docs/v2/networks/beaconchain/data), [EVM (Ethereum)](/docs/v2/networks/evm/data), [Starknet](/docs/v2/networks/starknet/data)).
- **`context`**: `object`<br/>The context shared between the indexer and the plugins.
- **`block`**<span class="arg-type">`TBlock`</span><br/><span class="arg-description">The block received from the DNA stream. This is chain-specific (see [Beacon Chain](/docs/v2/networks/beaconchain/data), [EVM (Ethereum)](/docs/v2/networks/evm/data), [Starknet](/docs/v2/networks/starknet/data)).</span>
- **`context`**<span class="arg-type">`object`</span><br/><span class="arg-description">The context shared between the indexer and the plugins.</span>

The following example shows a minimal indexer that streams `PairCreated` events from Uniswap V2 to detect new pools, and then streams the pool's events.

Expand Down
21 changes: 14 additions & 7 deletions docs/v2/getting-started/plugins/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,20 @@ Indexers are extensible through hooks and plugins. Hooks are functions that are

The following hooks are available in all indexers.

- `run:before`: Called before the indexer starts running.
- `run:after`: Called after the indexer has finished running.
- `connect:before`: Called before the indexer connects to the DNA stream. Can be used to change the request or stream options.
- `connect:after`: Called after the indexer has connected to the DNA stream.
- `connect:factory`: Called before the indexer reconnects to the DNA stream with a new filter (in factory mode).
- `message`: Called for each message received from the DNA stream. Additionally, message-specific hooks are available: `message:invalidate`, `message:finalize`, `message:heartbeat`, `message:systemMessage`.
- `handler:middleware`: Called to register indexer's middlewares.
- **`run:before`**<span class="arg-type">`() => void`</span><br/>
<span class="arg-description">Called before the indexer starts running.</span>
- **`run:after`**<span class="arg-type">`() => void`</span><br/>
<span class="arg-description">Called after the indexer has finished running.</span>
- **`connect:before`**<span class="arg-type">`({ request, options }: { request: StreamDataRequest<TFilter>, options: StreamDataOptions }) => void`</span><br/>
<span class="arg-description">Called before the indexer connects to the DNA stream. Can be used to change the request or stream options.</span>
- **`connect:after`**<span class="arg-type">`({ request }: { request: StreamDataRequest<TFilter> }) => void`</span><br/>
<span class="arg-description">Called after the indexer has connected to the DNA stream.</span>
- **`connect:factory`**<span class="arg-type">`({ request, endCursor }: { request: StreamDataRequest<TFilter>, endCursor: { orderKey: bigint, uniqueKey?: string } }) => void`</span><br/>
<span class="arg-description">Called before the indexer reconnects to the DNA stream with a new filter (in factory mode).</span>
- **`message`**<span class="arg-type">`({ message }: { message: StreamDataResponse<TBlock> }) => void`</span><br/>
<span class="arg-description">Called for each message received from the DNA stream. Additionally, message-specific hooks are available: `message:invalidate`, `message:finalize`, `message:heartbeat`, `message:systemMessage`.</span>
- **`handler:middleware`**<span class="arg-type">`({ use }: { use: MiddlewareFunction) => void }) => void`</span><br/>
<span class="arg-description">Called to register indexer's middlewares.</span>

## Using plugins

Expand Down

0 comments on commit 8e7fa4c

Please sign in to comment.