Skip to content
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

feat: factory start/endBlock #1566

Open
khaidarkairbek opened this issue Feb 26, 2025 · 1 comment
Open

feat: factory start/endBlock #1566

khaidarkairbek opened this issue Feb 26, 2025 · 1 comment

Comments

@khaidarkairbek
Copy link
Collaborator

Problem / use case

Currently, the factory address tracks child addresses in the interval between start and endBlock of the contract/account config.

However, in some niche use cases there might be a need to track factory address only for a small subinterval of the contract indexing timeline. The other use case might be when the factory needs to track child addresses before the contract indexing timeline. Ex: collect uniswap pools via factory but only interested in contract activity from a week ago.

In the current implementation, you would either need to run contract indexing for an unnecessarily big interval or collect more child addresses than needed.

@kyscott18 @typedarray let me know what you think.

Proposed solution

I would propose a solution building on current factory implementation with optional startBlock and endBlock fields:

type Factory<event extends AbiEvent = AbiEvent> = {
  /** Address of the factory contract that creates this contract. */
  address: `0x${string}` | readonly `0x${string}`[];
  /** ABI event that announces the creation of a new instance of this contract. */
  event: event;
  /** Name of the factory event parameter that contains the new child contract address. */
  parameter: Exclude<event["inputs"][number]["name"], undefined>;
  /** Optional factory interval */
  startBlock?: number; 
  endBlock?: number; 
};

Due to the nature of the factory addresses, the following validations would make sense:
factory startBlock <= contract/account startBlock:
- either error out during validation or default contract startBlock to factory startBlock
factory endBlock <= contarct/account endBlock:
- either error out during validation of default factory endBlock to contract endBlock

@harry-nutsfi
Copy link

Exactly the problem that I've raised in the telegram channel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants