This repository was archived by the owner on Jan 27, 2026. It is now read-only.
Open
Conversation
jkylling
reviewed
Jul 24, 2025
| ## 2. Project Structure | ||
|
|
||
| - **`sim.toml`**: The main configuration file for your app. Defines the app name and code generation settings. | ||
| - **`abis/`**: Contains the JSON ABI files for the smart contracts you want to index. Use `sim abi add abis/<path/to/abi.json>` to register them. |
Collaborator
There was a problem hiding this comment.
nit:
Suggested change
| - **`abis/`**: Contains the JSON ABI files for the smart contracts you want to index. Use `sim abi add abis/<path/to/abi.json>` to register them. | |
| - **`abis/`**: Contains the JSON ABI files for the smart contracts you want to index. Use `sim abi add <path/to/abi.json>` to register them. |
|
|
||
| ### Context and Inputs | ||
|
|
||
| - Handler functions receive context objects (`EventContext`, `FunctionContext`) and typed input/output structs. To find the correct context objects, look in `lib/sim-idx-generated/`. |
Collaborator
There was a problem hiding this comment.
The context objects are defined in lib/sim-idx-sol/src/Context.sol.
Collaborator
There was a problem hiding this comment.
The inputs and outputs structs are defined within lib/sim-idx-generated/
Comment on lines
+77
to
+79
| - **Name Conflicts**: If two ABIs have a function/event with the same name, either: | ||
| 1. (Recommended) Split logic into two separate listener contracts. | ||
| 2. Set `codegen_naming_convention = "abi_prefix"` in `sim.toml` to use prefixed handler names (e.g., `ABI1$onSwapFunction`). |
Collaborator
There was a problem hiding this comment.
I hope this is not a common pitfall. It should be more like an edge case, but we don't know yet.
| - `sim abi add <path/to/abi.json>`: Add an ABI and generate bindings. | ||
| - `sim build`: Compile contracts and generate API schema. | ||
| - `sim test`: Run Foundry unit tests from `listeners/test/`. | ||
| - `sim listeners evaluate --chain-id <id> --start-block <num> [--listeners=<name>]`: Dry-run listener against historical blocks. |
Collaborator
There was a problem hiding this comment.
This is not really a dry-run?
Suggested change
| - `sim listeners evaluate --chain-id <id> --start-block <num> [--listeners=<name>]`: Dry-run listener against historical blocks. | |
| - `sim listeners evaluate --chain-id <id> --start-block <num> [--listeners=<name>]`: Run listener(s) against historical blocks. |
It's also possible to supply an end block, but at most a 16 block range is allowed.
|
|
||
| ## 1. Framework & Setup | ||
|
|
||
| - **Stack**: Your API runs on **Cloudflare Workers** using the **Hono** web framework and **Drizzle ORM** for database access. |
Collaborator
There was a problem hiding this comment.
Should we have links to documentation for Hono and Drizzle?
Comment on lines
+33
to
+36
| // Basic validation | ||
| if (!poolAddress.startsWith('0x')) { | ||
| return Response.json({ error: "Invalid pool address format" }, { status: 400 }); | ||
| } |
Collaborator
There was a problem hiding this comment.
This might be better with something like:
Suggested change
| // Basic validation | |
| if (!poolAddress.startsWith('0x')) { | |
| return Response.json({ error: "Invalid pool address format" }, { status: 400 }); | |
| } | |
| // Basic validation | |
| let validatedPoolAddress; | |
| try { | |
| validatedPoolAddress = Address.from(poolAddress); | |
| } catch (...) { | |
| return Response.json({ error: "Invalid pool address format" }, { status: 400 }); | |
| } | |
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Updating the Cursor Rules files for the root and
/apis.