-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: basic utxo indexer example and minor updates to support sundae …
…swap liquidity pool query (#35)
- Loading branch information
Showing
16 changed files
with
479 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/scripts/*.csv | ||
/scripts/*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.watcherExclude": { | ||
"**/target": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin | ||
obj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Cardano.Sync.Data; | ||
using Cardano.Sync.Data.Models; | ||
using Cardano.Sync.Reducers; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Mumak.Indexer.Data; | ||
|
||
public class MumakDbContext | ||
( | ||
DbContextOptions<MumakDbContext> options, | ||
IConfiguration configuration | ||
) : CardanoDbContext(options, configuration) | ||
{ | ||
public DbSet<Utxo> Utxos { get; set; } | ||
|
||
override protected void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
base.OnModelCreating(modelBuilder); | ||
|
||
modelBuilder.Entity<Utxo>(entity => | ||
{ | ||
entity.ToTable("utxos"); | ||
entity.HasKey(e => new { e.Slot, e.Id, e.TxIndex }); | ||
entity.Property(e => e.Id) | ||
.HasColumnName("id"); | ||
entity.Property(e => e.TxIndex) | ||
.HasColumnName("tx_index"); | ||
entity.Property(e => e.Slot) | ||
.HasColumnName("slot"); | ||
entity.Property(e => e.Raw) | ||
.HasColumnName("raw"); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Cardano.Sync.Data.Models; | ||
|
||
namespace Mumak.Indexer.Data; | ||
|
||
public record Utxo( | ||
string Id, | ||
ulong TxIndex, | ||
ulong Slot, | ||
byte[] Raw | ||
) : IReducerModel; |
71 changes: 71 additions & 0 deletions
71
indexer/Migrations/20240910100707_InitialCreate.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace Mumak.Indexer.Migrations | ||
{ | ||
/// <inheritdoc /> | ||
public partial class InitialCreate : Migration | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.EnsureSchema( | ||
name: "public"); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "ReducerStates", | ||
schema: "public", | ||
columns: table => new | ||
{ | ||
Name = table.Column<string>(type: "text", nullable: false), | ||
Slot = table.Column<decimal>(type: "numeric(20,0)", nullable: false), | ||
Hash = table.Column<string>(type: "text", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_ReducerStates", x => x.Name); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "utxos", | ||
schema: "public", | ||
columns: table => new | ||
{ | ||
id = table.Column<string>(type: "text", nullable: false), | ||
tx_index = table.Column<decimal>(type: "numeric(20,0)", nullable: false), | ||
slot = table.Column<decimal>(type: "numeric(20,0)", nullable: false), | ||
raw = table.Column<byte[]>(type: "bytea", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_utxos", x => new { x.slot, x.id, x.tx_index }); | ||
}); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "ReducerStates", | ||
schema: "public"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "utxos", | ||
schema: "public"); | ||
} | ||
} | ||
} |
Oops, something went wrong.