Skip to content

Commit

Permalink
Expose inbox message index
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed May 31, 2024
1 parent e670d34 commit 81d7758
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Tzkt.Api/Models/SmartRollups/SrMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ public class SrMessage
/// </summary>
public int Level { get; set; }

/// <summary>
/// Index of the inbox message within the block.
/// </summary>
public int Index { get; set; }

/// <summary>
/// Timestamp of the block where the message was pushed.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions Tzkt.Api/Repositories/SmartRollupsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1421,6 +1421,7 @@ async Task<IEnumerable<dynamic>> QueryInboxMessagesAsync(SrMessageFilter filter,
var select = """
m."Id",
m."Level",
m."Index",
m."Type",
m."Payload",
m."Protocol",
Expand All @@ -1445,6 +1446,7 @@ async Task<IEnumerable<dynamic>> QueryInboxMessagesAsync(SrMessageFilter filter,
{
case "id": columns.Add(@"m.""Id"""); break;
case "level": columns.Add(@"m.""Level"""); break;
case "index": columns.Add(@"m.""Index"""); break;
case "timestamp": columns.Add(@"m.""Level"""); break;
case "type": columns.Add(@"m.""Type"""); break;
case "payload": columns.Add(@"m.""Payload"""); break;
Expand Down Expand Up @@ -1510,6 +1512,7 @@ public async Task<IEnumerable<SrMessage>> GetInboxMessages(SrMessageFilter filte
{
Id = row.Id,
Level = row.Level,
Index = row.Index,
Timestamp = Times[(int)row.Level],
Type = SrMessageTypes.ToString((int)row.Type),
PredecessorHash = row.pHash,
Expand Down Expand Up @@ -1551,6 +1554,10 @@ public async Task<object[][]> GetInboxMessages(SrMessageFilter filter, Paginatio
foreach (var row in rows)
result[j++][i] = row.Level;
break;
case "index":
foreach (var row in rows)
result[j++][i] = row.Index;
break;
case "timestamp":
foreach (var row in rows)
result[j++][i] = Times[(int)row.Level];
Expand Down

0 comments on commit 81d7758

Please sign in to comment.