diff --git a/.github/README.md b/.github/README.md index e239757..6f98707 100644 --- a/.github/README.md +++ b/.github/README.md @@ -2,8 +2,8 @@

- - OpenIndex logo + + OpenIndex logo

diff --git a/package.json b/package.json index ddb4b44..903cef7 100644 --- a/package.json +++ b/package.json @@ -117,20 +117,6 @@ } } }, - "pnpm": { - "overrides": { - "@microsoft/api-extractor>typescript": "^5.5.4", - "hono@<4.2.7": ">=4.2.7", - "ws@>=8.0.0 <8.17.1": ">=8.17.1", - "hono@<4.5.8": ">=4.5.8", - "micromatch@<4.0.8": ">=4.0.8", - "webpack@>=5.0.0-alpha.0 <5.94.0": ">=5.94.0", - "rollup@>=4.0.0 <4.22.4": ">=4.22.4", - "hono@<4.6.5": ">=4.6.5", - "es-module-lexer": "1.7.0" - }, - "patchedDependencies": {} - }, "size-limit": [ { "name": "import * from 'openindex'", diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index d2ad427..44fbb70 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -3,3 +3,13 @@ packages: - site - src trustPolicy: no-downgrade +overrides: + "@microsoft/api-extractor>typescript": "^5.5.4" + "hono@<4.2.7": ">=4.2.7" + "ws@>=8.0.0 <8.17.1": ">=8.17.1" + "hono@<4.5.8": ">=4.5.8" + "micromatch@<4.0.8": ">=4.0.8" + "webpack@>=5.0.0-alpha.0 <5.94.0": ">=5.94.0" + "rollup@>=4.0.0 <4.22.4": ">=4.22.4" + "hono@<4.6.5": ">=4.6.5" + "es-module-lexer": "1.7.0" diff --git a/site/vocs.config.ts b/site/vocs.config.ts index 2814dc2..ff62c93 100644 --- a/site/vocs.config.ts +++ b/site/vocs.config.ts @@ -1,6 +1,6 @@ import { defineConfig } from 'vocs/config' import pkg from '../src/package.json' -import { sidebar, topNav } from './config-generated' +import { sidebar } from './config-generated' export default defineConfig({ baseUrl: @@ -41,15 +41,9 @@ export default defineConfig({ { text: 'API Reference', collapsed: true, - items: [ - { - text: 'Core', - link: '/api', - }, - ], + items: sidebar['/api'].items, }, ], - ...sidebar, }, socials: [ { @@ -62,7 +56,6 @@ export default defineConfig({ }, ], topNav: [ - ...topNav, { text: pkg.version, items: [ diff --git a/src/README.md b/src/README.md index 8b0c2c0..6f98707 100644 --- a/src/README.md +++ b/src/README.md @@ -2,11 +2,15 @@

- - OpenIndex logo + + OpenIndex logo

+

+ Easier indexing for Ethereum. +

+

@@ -30,13 +34,50 @@ ## Overview -OpenIndex is a TypeScript library. +OpenIndex is a lightweight, type-safe EVM indexer built on [viem](https://viem.sh). It turns a viem `PublicClient` into a live event indexer: you describe the events you care about with an ABI, write a handler, and OpenIndex watches new blocks and dispatches matching logs to your handler in real time. + +Handlers are imperative, so you keep full control over event filters, transforms, and storage — index into a database, a queue, memory, or anywhere else you like. + +## Install + +```bash +pnpm add openindex viem +``` + +```bash +npm install openindex viem +``` + +```bash +bun add openindex viem +``` + +## Example + +Index `Transfer` events on Ethereum mainnet: + +```ts +import { createPublicClient, http, parseAbiItem } from 'viem' +import { mainnet } from 'viem/chains' +import { EventHandler, Indexer } from 'openindex' + +const client = createPublicClient({ chain: mainnet, transport: http() }) + +const transfer = parseAbiItem( + 'event Transfer(address indexed from, address indexed to, uint256 value)', +) + +const handler = EventHandler.from([transfer], (logs) => { + for (const log of logs) { + console.log(log.args.from, '→', log.args.to, log.args.value) + } +}) -## Documentation +Indexer.start(client, [handler]) +``` -[Head to the documentation](https://openindex.dev) to read and learn more about OpenIndex. +The `logs` passed to your handler are fully typed from the ABI you provide. -## Community +## License -- Follow [@0xSplits](https://x.com/0xSplits) on X for project updates -- Join the [discussions on GitHub](https://github.com/0xSplits/openindex/discussions) +[MIT](https://github.com/0xSplits/openindex/blob/main/LICENSE) License