-
Notifications
You must be signed in to change notification settings - Fork 4
Description
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:
- 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.
- 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. - 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)