Skip to content

Event filtering by contract addresses#495

Merged
DZakh merged 11 commits into
mainfrom
dz/event-filters-by-addresses
Apr 2, 2025
Merged

Event filtering by contract addresses#495
DZakh merged 11 commits into
mainfrom
dz/event-filters-by-addresses

Conversation

@DZakh

@DZakh DZakh commented Mar 28, 2025

Copy link
Copy Markdown
Member

No description provided.

@DZakh DZakh requested a review from JonoPrest April 1, 2025 13:15
@DZakh

DZakh commented Apr 1, 2025

Copy link
Copy Markdown
Member Author

@JonoPrest Here's the usage example #469 (comment)

// The idea is that it can only be coerced from fuel/evmEventConfig
// and it can include their fields. We prevent manual creation,
// so the fields are not overwritten and we can safely cast the type back to fuel/evmEventConfig
type eventConfig = private {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do the fields still come up with lsp hover etc?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes

),
)
| [topicSelection] => topicSelection
| ([topicSelection], _) if dynamicEventFilters->Utils.Array.isEmpty => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
| ([topicSelection], _) if dynamicEventFilters->Utils.Array.isEmpty => {
| ([topicSelection], []) => {

Comment on lines +206 to +207
| _ =>
raise(
Source.GetItemsError(
UnsupportedSelection({
message: "RPC data-source currently supports event filters only when there's a single wildcard event. Join our Discord channel, to get updates on the new releases.",
}),
),
)
}

// Some RPC providers would fail
// if we don't strip trailing empty topics
// also we need to change empty topics in the middle to null
let topics = switch topicSelection {
| {topic0, topic1: [], topic2: [], topic3: []} => [topic0]
| {topic0, topic1, topic2: [], topic3: []} => [topic0, topic1]
| {topic0, topic1: [], topic2, topic3: []} => [topic0, %raw(`null`), topic2]
| {topic0, topic1, topic2, topic3: []} => [topic0, topic1, topic2]
| {topic0, topic1: [], topic2: [], topic3} => [topic0, %raw(`null`), %raw(`null`), topic3]
| {topic0, topic1: [], topic2, topic3} => [topic0, %raw(`null`), topic2, topic3]
| {topic0, topic1, topic2: [], topic3} => [topic0, topic1, %raw(`null`), topic3]
| {topic0, topic1, topic2, topic3} => [topic0, topic1, topic2, topic3]
switch (dynamicEventFilters, selection.eventConfigs) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Check that topic selection is empty

@JonoPrest JonoPrest left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Amazing! 🚀

@DZakh DZakh enabled auto-merge (squash) April 2, 2025 08:18
@DZakh DZakh merged commit 6fbbbe9 into main Apr 2, 2025
@DZakh DZakh deleted the dz/event-filters-by-addresses branch April 2, 2025 08:25
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.

Feature request: filter events by contract addresses deployed through a factory contract

2 participants