-
Notifications
You must be signed in to change notification settings - Fork 1
Cursor Rules Updates #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| ## 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
| - **`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/`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The context objects are defined in lib/sim-idx-sol/src/Context.sol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inputs and outputs structs are defined within lib/sim-idx-generated/
| - **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`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not really a dry-run?
| - `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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have links to documentation for Hono and Drizzle?
| // Basic validation | ||
| if (!poolAddress.startsWith('0x')) { | ||
| return Response.json({ error: "Invalid pool address format" }, { status: 400 }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be better with something like:
| // 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 }); | |
| } | |
| ... |
Updating the Cursor Rules files for the root and
/apis.