Skip to content

[FEATURE] Support for metadata filtering #11

@e1Ru1o

Description

@e1Ru1o

Problem

There is no way for filtering based on metadata, that makes the developers iterate over large results pages in case where they can be significantly reduced by specifying some metadata fields to filter.

Metadata works as a Map<string, string> so adding a filter to match key-value pairs on it will allow less computation on the Forta API user side and more precise/powerful filters.

Proposed Solution

I have no details to provide about how to accomplish this feature programmatically, but I have one comment to share about how I would like it to looks like in the API.

By adding something like a metadataContains field in AlertsInput the user will be able to filter to filter alerts by specifying key-value pairs that should be present in the metadata, for example:

alertInput = {
  input: {
    ... // some filter parameters
     metadataContains: {
       key1: string1,
       key2: string2,
     }
  }
}

In that way users can filter all the alerts that contains string1 as key1 & string2 as key2.

Additional context

Some examples of usage:

  1. There is a race condition for calling a function. Each time it is called an event is emitted with the caller in the metadata. It is needed to filter all the alerts given a caller.
  2. There is an event containing hashes in the metadata as hash: "true" to simulate a set of hashes. It is needed to filter alerts containing an specific hash.
  3. There is a bot monitoring roles in some smart contract. There is needed to count how many times operator X granted the role R. (operator & role are metadata fields)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions