diff --git a/Circles.Index.Query/FilterPredicate.cs b/Circles.Index.Query/FilterPredicate.cs index 7e44c1c..694f01d 100644 --- a/Circles.Index.Query/FilterPredicate.cs +++ b/Circles.Index.Query/FilterPredicate.cs @@ -19,6 +19,7 @@ public ParameterizedSql ToSql(IDatabaseUtils database) FilterType.LessThan => $"{database.QuoteIdentifier(Column)} < {parameterName}_0", FilterType.LessThanOrEquals => $"{database.QuoteIdentifier(Column)} <= {parameterName}_0", FilterType.Like => $"{database.QuoteIdentifier(Column)} LIKE {parameterName}_0", + FilterType.ILike => $"{database.QuoteIdentifier(Column)} ILIKE {parameterName}_0", FilterType.NotLike => $"{database.QuoteIdentifier(Column)} NOT LIKE {parameterName}_0", FilterType.In => ConvertToEnumerable(Value)?.Any() ?? false ? $"{database.QuoteIdentifier(Column)} IN ({FormatArrayParameter(Value, parameterName)})" diff --git a/Circles.Index.Query/FilterType.cs b/Circles.Index.Query/FilterType.cs index b3e0977..f88dbab 100644 --- a/Circles.Index.Query/FilterType.cs +++ b/Circles.Index.Query/FilterType.cs @@ -25,6 +25,9 @@ public enum FilterType [JsonConverter(typeof(JsonStringEnumConverter))] Like, + [JsonConverter(typeof(JsonStringEnumConverter))] + ILike, + [JsonConverter(typeof(JsonStringEnumConverter))] NotLike, diff --git a/Circles.Index.Rpc/CirclesRpcModule.cs b/Circles.Index.Rpc/CirclesRpcModule.cs index 17b06c7..eb2c298 100644 --- a/Circles.Index.Rpc/CirclesRpcModule.cs +++ b/Circles.Index.Rpc/CirclesRpcModule.cs @@ -336,11 +336,11 @@ public ResultWrapper circles_query(SelectDto query) } public ResultWrapper circles_events(Address? address, long? fromBlock, long? toBlock = null, - FilterPredicateDto[]? filterPredicates = null, bool? sortAscending = false) + string[]? eventTypes = null, FilterPredicateDto[]? filterPredicates = null, bool? sortAscending = false) { var queryEvents = new QueryEvents(_indexerContext); return ResultWrapper.Success(queryEvents.CirclesEvents(address, fromBlock, toBlock, - filterPredicates, sortAscending)); + eventTypes, filterPredicates, sortAscending)); } private string[] GetTokenExposureIds(Address address) diff --git a/Circles.Index.Rpc/ICirclesRpcModule.cs b/Circles.Index.Rpc/ICirclesRpcModule.cs index 341744a..9c0c7c4 100644 --- a/Circles.Index.Rpc/ICirclesRpcModule.cs +++ b/Circles.Index.Rpc/ICirclesRpcModule.cs @@ -57,5 +57,6 @@ public interface ICirclesRpcModule : IRpcModule [JsonRpcMethod(Description = "Returns all events affecting the specified account since block N", IsImplemented = true)] - ResultWrapper circles_events(Address? address, long? fromBlock, long? toBlock = null, FilterPredicateDto[]? filters = null, bool? sortAscending = false); + ResultWrapper circles_events(Address? address, long? fromBlock, long? toBlock = null, + string[]? eventTypes = null, FilterPredicateDto[]? filters = null, bool? sortAscending = false); } \ No newline at end of file diff --git a/Circles.Index.Rpc/QueryEvents.cs b/Circles.Index.Rpc/QueryEvents.cs index 5831eab..9a1a538 100644 --- a/Circles.Index.Rpc/QueryEvents.cs +++ b/Circles.Index.Rpc/QueryEvents.cs @@ -22,11 +22,12 @@ public class QueryEvents(Context context) /// If specified, only events concerning this account are queried /// HEAD - 1000 if not specified otherwise /// HEAD if not specified otherwise - /// Additional filters to apply to the query + /// An array of event types to include in the query + /// Additional filters to apply to the query. The filtered columns must be present in all queried events! /// An array of CirclesEvent objects /// Thrown when the zero address is queried, fromBlock is less than 0, toBlock is less than fromBlock, or toBlock is greater than the current head public CirclesEvent[] CirclesEvents(Address? address, long? fromBlock, long? toBlock = null, - FilterPredicateDto[]? additionalFilters = null, bool? sortAscending = false) + string[]? onlyTheseTypes = null, FilterPredicateDto[]? additionalFilters = null, bool? sortAscending = false) { long currentHead = context.NethermindApi.BlockTree?.Head?.Number ?? throw new Exception("BlockTree or Head is null"); @@ -37,7 +38,7 @@ public CirclesEvent[] CirclesEvents(Address? address, long? fromBlock, long? toB ValidateInputs(addressString, fromBlock.Value, toBlock, currentHead); - var queries = BuildQueries(addressString, fromBlock.Value, toBlock, additionalFilters); + var queries = BuildQueries(addressString, fromBlock.Value, toBlock, onlyTheseTypes, additionalFilters); var events = ExecuteQueries(queries); @@ -63,14 +64,21 @@ private void ValidateInputs(string? address, long fromBlock, long? toBlock, long } private List(); foreach (var table in context.Database.Schema.Tables) { if (table.Key.Namespace.StartsWith("V_") || table.Key.Namespace == "System") + { + continue; + } + + if (onlyTheseTypes != null && !onlyTheseTypes.Contains($"{table.Key.Namespace}_{table.Key.Table}")) + { continue; + } var addressColumnFilters = address == null ? [] diff --git a/Circles.Index/Circles.Index.csproj b/Circles.Index/Circles.Index.csproj index 38cd53d..e59b8fb 100644 --- a/Circles.Index/Circles.Index.csproj +++ b/Circles.Index/Circles.Index.csproj @@ -8,8 +8,8 @@ Daniel Janz (Gnosis Service GmbH) Gnosis Service GmbH Circles - 1.8.1 - 1.8.1 + 1.8.2 + 1.8.2