Skip to content

Conversation

@dericksozo
Copy link
Contributor

Updating the Cursor Rules files for the root and /apis.

@dericksozo dericksozo self-assigned this Jul 24, 2025
@dericksozo dericksozo added the documentation Improvements or additions to documentation label Jul 24, 2025
@dericksozo dericksozo requested a review from jkylling July 24, 2025 07:02
## 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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/`.
Copy link
Collaborator

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.

Copy link
Collaborator

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/

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`).
Copy link
Collaborator

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.
Copy link
Collaborator

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?

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.
Copy link
Collaborator

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?

Comment on lines +33 to +36
// Basic validation
if (!poolAddress.startsWith('0x')) {
return Response.json({ error: "Invalid pool address format" }, { status: 400 });
}
Copy link
Collaborator

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:

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 });
}
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants