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

Contract source filter #1373

Merged
merged 24 commits into from
Jan 5, 2025
Merged

Conversation

khaidarkairbek
Copy link
Collaborator

Relates to #1372. Added a support for more flexible contract source filters in build. Currently, I am assuming the type of the filter as defined in #1372. If we land on this design for an api, the next step would be dealing with GetEventFilter type in the config.

typedarray and others added 16 commits December 20, 2024 18:03
* chore: add logs

* chore: changeset

---------

Co-authored-by: typedarray <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* chore: improve pg error handling for tests

* chore: changeset

* chore: use error prop

---------

Co-authored-by: typedarray <[email protected]>
* typo: merge abis url

* Update contracts-and-networks.mdx

---------

Co-authored-by: Kevin <[email protected]>
* fix: raw sql sets fast path flag to false

* test

---------

Co-authored-by: typedarray <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
source.filter,
).reduce(
(acc, cur) => {
if (acc.includes(cur) === false) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if this .includes() works how you expect on objects

topic2: null,
topic3: null,
},
];

if (source.filter !== undefined) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm finding this code block a little hard to follow. I think you have it right: multiple filters in the config should result to multiple sources. Might be helpful to try to limit the use of .reduce

export type GetEventFilter<
abi extends Abi,
contract,
///
safeEventNames extends string = SafeEventNames<abi>,
> = contract extends {
filter: {
event: infer event extends readonly string[] | string;
event: infer event extends string;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Need to add a branch for array of filters

});
});

test("event filter with event and args", () => {
test("event filters with event only filter", () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice test

@kyscott18 kyscott18 self-requested a review January 1, 2025 18:22
@kyscott18 kyscott18 changed the base branch from main to v0.9 January 2, 2025 22:35
@khaidarkairbek khaidarkairbek merged commit 1adf84d into ponder-sh:v0.9 Jan 5, 2025
8 checks passed
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

Successfully merging this pull request may close these issues.

4 participants