Skip to content

Commit

Permalink
Merge pull request #31 from aboutcircles/feature/add-table-introspection
Browse files Browse the repository at this point in the history
Feature/add table introspection
  • Loading branch information
jaensen authored Jan 22, 2025
2 parents f8b9e73 + b202c0e commit 4ea1fb6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
16 changes: 8 additions & 8 deletions Circles.Index.Rpc/CirclesRpcModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,29 +383,29 @@ public Task<ResultWrapper<string>> circles_health()
return Task.FromResult(ResultWrapper<string>.Success("Healthy"));
}

public Task<ResultWrapper<IEnumerable<Namespace>>> circles_tables()
public Task<ResultWrapper<IEnumerable<DatabaseNamespace>>> circles_tables()
{
var namespaces = new List<Namespace>();
foreach (var namepsace in _indexerContext.Database.Schema.Tables.GroupBy(o => o.Key.Namespace))
var namespaces = new List<DatabaseNamespace>();
foreach (var @namespace in _indexerContext.Database.Schema.Tables.GroupBy(o => o.Key.Namespace))
{
var namespaceDto = new Namespace(namepsace.Key);
var namespaceDto = new DatabaseNamespace(@namespace.Key);
namespaces.Add(namespaceDto);

foreach (var table in namepsace)
foreach (var table in @namespace)
{
var topic = table.Value.Topic.ToHexString(true);
var tableDto = new Table(table.Key.Table, topic);
var tableDto = new DatabaseTable(table.Key.Table, topic);
namespaceDto.Tables = namespaceDto.Tables.Append(tableDto).ToArray();

foreach (var column in table.Value.Columns)
{
var columnDto = new Column(column.Column, column.Type.ToString());
var columnDto = new DatabaseColumn(column.Column, column.Type.ToString());
tableDto.Columns = tableDto.Columns.Append(columnDto).ToArray();
}
}
}

return Task.FromResult(ResultWrapper<IEnumerable<Namespace>>.Success(namespaces));
return Task.FromResult(ResultWrapper<IEnumerable<DatabaseNamespace>>.Success(namespaces));
}

private string[] GetTokenExposureIds(Address address)
Expand Down
15 changes: 9 additions & 6 deletions Circles.Index.Rpc/ICirclesRpcModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,19 @@ public record CirclesTrustRelations(Address User, CirclesTrustRelation[] Trusts,

public record CirclesEvent(string Event, IDictionary<string, object?> Values);

public record Column(string Name, string Type);
public record DatabaseColumn(string Column, string Type);

public class Table(string Name, string Topic)
public class DatabaseTable(string table, string topic)
{
public Column[] Columns { get; set; } = [];
public string Table { get; set; } = table;
public string Topic { get; set; } = topic;
public DatabaseColumn[] Columns { get; set; } = [];
}

public class Namespace(string Name)
public class DatabaseNamespace(string @namespace)
{
public Table[] Tables { get; set; } = [];
public string Namespace { get; set; } = @namespace;
public DatabaseTable[] Tables { get; set; } = [];
}

#endregion
Expand Down Expand Up @@ -86,5 +89,5 @@ ResultWrapper<CirclesEvent[]> circles_events(Address? address, long? fromBlock,
[JsonRpcMethod(
Description = "Returns all indexed tables and columns grouped by namespace",
IsImplemented = true)]
Task<ResultWrapper<IEnumerable<Namespace>>> circles_tables();
Task<ResultWrapper<IEnumerable<DatabaseNamespace>>> circles_tables();
}
4 changes: 2 additions & 2 deletions Circles.Index/Circles.Index.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<Authors>Daniel Janz (Gnosis Service GmbH)</Authors>
<Copyright>Gnosis Service GmbH</Copyright>
<Product>Circles</Product>
<AssemblyVersion>1.11.15</AssemblyVersion>
<FileVersion>1.11.15</FileVersion>
<AssemblyVersion>1.11.16</AssemblyVersion>
<FileVersion>1.11.16</FileVersion>
</PropertyGroup>


Expand Down

0 comments on commit 4ea1fb6

Please sign in to comment.