From 5758c4735821e3730efa0ca513c8924385f4be32 Mon Sep 17 00:00:00 2001 From: dmir Date: Sat, 8 Jul 2023 18:36:35 +0300 Subject: [PATCH 01/51] Tickets init --- Tzkt.Data/Models/Accounts/Contract.cs | 2 + Tzkt.Data/Models/AppState.cs | 3 + Tzkt.Data/Models/Blocks/BlockEvents.cs | 27 ++-- .../Operations/TransferTicketOperation.cs | 8 +- Tzkt.Data/Models/Scripts/TIcket.cs | 97 ++++++++++++++ Tzkt.Data/TzktContext.cs | 4 + .../Handlers/Proto16/Commits/TicketsCommit.cs | 101 ++++++++++++++ Tzkt.Sync/Services/Cache/CacheService.cs | 1 + Tzkt.Sync/Services/Cache/TicketsCache.cs | 125 ++++++++++++++++++ 9 files changed, 354 insertions(+), 14 deletions(-) create mode 100644 Tzkt.Data/Models/Scripts/TIcket.cs create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs create mode 100644 Tzkt.Sync/Services/Cache/TicketsCache.cs diff --git a/Tzkt.Data/Models/Accounts/Contract.cs b/Tzkt.Data/Models/Accounts/Contract.cs index 56b9c42ff..8f7390a8a 100644 --- a/Tzkt.Data/Models/Accounts/Contract.cs +++ b/Tzkt.Data/Models/Accounts/Contract.cs @@ -12,6 +12,8 @@ public class Contract : Account public ContractTags Tags { get; set; } public int TokensCount { get; set; } public int EventsCount { get; set; } + + public int TicketsCount { get; set; } public bool? Spendable { get; set; } diff --git a/Tzkt.Data/Models/AppState.cs b/Tzkt.Data/Models/AppState.cs index 67b09f344..16b07b179 100644 --- a/Tzkt.Data/Models/AppState.cs +++ b/Tzkt.Data/Models/AppState.cs @@ -97,6 +97,9 @@ public class AppState public int TokensCount { get; set; } public int TokenBalancesCount { get; set; } public int TokenTransfersCount { get; set; } + + public int TicketsCount { get; set; } + public int EventsCount { get; set; } #endregion diff --git a/Tzkt.Data/Models/Blocks/BlockEvents.cs b/Tzkt.Data/Models/Blocks/BlockEvents.cs index 4252207a3..540471d48 100644 --- a/Tzkt.Data/Models/Blocks/BlockEvents.cs +++ b/Tzkt.Data/Models/Blocks/BlockEvents.cs @@ -5,18 +5,19 @@ namespace Tzkt.Data.Models [Flags] public enum BlockEvents { - None = 0b_0000_0000_0000, - CycleBegin = 0b_0000_0000_0001, - CycleEnd = 0b_0000_0000_0010, - ProtocolBegin = 0b_0000_0000_0100, - ProtocolEnd = 0b_0000_0000_1000, - Deactivations = 0b_0000_0001_0000, - NewAccounts = 0b_0000_0010_0000, - BalanceSnapshot = 0b_0000_0100_0000, - SmartContracts = 0b_0000_1000_0000, - DelegatorContracts = 0b_0001_0000_0000, - Bigmaps = 0b_0010_0000_0000, - Tokens = 0b_0100_0000_0000, - Events = 0b_1000_0000_0000 + None = 0b_0000_0000_0000_0000, + CycleBegin = 0b_0000_0000_0000_0001, + CycleEnd = 0b_0000_0000_0000_0010, + ProtocolBegin = 0b_0000_0000_0000_0100, + ProtocolEnd = 0b_0000_0000_0000_1000, + Deactivations = 0b_0000_0000_0001_0000, + NewAccounts = 0b_0000_0000_0010_0000, + BalanceSnapshot = 0b_0000_0000_0100_0000, + SmartContracts = 0b_0000_0000_1000_0000, + DelegatorContracts = 0b_0000_0001_0000_0000, + Bigmaps = 0b_0000_0010_0000_0000, + Tokens = 0b_0000_0100_0000_0000, + Events = 0b_0000_1000_0000_0000, + Tickets = 0b_0001_0000_0000_0000 } } diff --git a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs index afe93cba0..7b3f20f01 100644 --- a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs +++ b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs @@ -1,4 +1,5 @@ -using System.Numerics; +using System.ComponentModel.DataAnnotations.Schema; +using System.Numerics; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Tzkt.Data.Models.Base; @@ -15,6 +16,11 @@ public class TransferTicketOperation : ManagerOperation public byte[] RawContent { get; set; } public string JsonContent { get; set; } public string Entrypoint { get; set; } + + #region relations + [ForeignKey(nameof(TicketerId))] + public Account Ticketer { get; set; } + #endregion } public static class TransferTicketOperationModel diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs new file mode 100644 index 000000000..1ddfb5f26 --- /dev/null +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -0,0 +1,97 @@ +using System; +using System.Numerics; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Tzkt.Data.Models +{ + public class Ticket + { + public long Id { get; set; } + public int ContractId { get; set; } + public BigInteger TicketId { get; set; } + + public int FirstMinterId { get; set; } + public int FirstLevel { get; set; } + public int LastLevel { get; set; } + + public int TransfersCount { get; set; } + public int BalancesCount { get; set; } + public int HoldersCount { get; set; } + + public BigInteger TotalMinted { get; set; } + public BigInteger TotalBurned { get; set; } + public BigInteger TotalSupply { get; set; } + + public int? OwnerId { get; set; } + public int? IndexedAt { get; set; } + } + + public static class TicketModel + { + public static void BuildTicketModel(this ModelBuilder modelBuilder) + { + #region keys + modelBuilder.Entity() + .HasKey(x => x.Id); + #endregion + + #region props + // shadow property + modelBuilder.Entity() + .Property("Metadata") + .HasColumnType("jsonb"); + + // TODO: switch to `numeric` type after migration to .NET 6 + var converter = new ValueConverter( + x => x.ToString(), + x => BigInteger.Parse(x)); + + modelBuilder.Entity() + .Property(x => x.TicketId) + .HasConversion(converter); + + modelBuilder.Entity() + .Property(x => x.TotalMinted) + .HasConversion(converter); + + modelBuilder.Entity() + .Property(x => x.TotalBurned) + .HasConversion(converter); + + modelBuilder.Entity() + .Property(x => x.TotalSupply) + .HasConversion(converter); + #endregion + + #region indexes + modelBuilder.Entity() + .HasIndex(x => x.Id) + .IsUnique(); + + modelBuilder.Entity() + .HasIndex(x => x.ContractId); + + modelBuilder.Entity() + .HasIndex(x => new { x.ContractId, x.TicketId }) + .IsUnique(); + + modelBuilder.Entity() + .HasIndex(x => x.FirstMinterId); + + modelBuilder.Entity() + .HasIndex(x => x.LastLevel); + + modelBuilder.Entity() + .HasIndex(x => x.IndexedAt) + .HasFilter($@"""{nameof(Ticket.IndexedAt)}"" is not null"); + + // shadow property + modelBuilder.Entity() + .HasIndex("Metadata") + .HasMethod("gin") + .HasOperators("jsonb_path_ops"); + #endregion + } + } +} diff --git a/Tzkt.Data/TzktContext.cs b/Tzkt.Data/TzktContext.cs index dc3ef3a05..6f40a93a1 100644 --- a/Tzkt.Data/TzktContext.cs +++ b/Tzkt.Data/TzktContext.cs @@ -109,6 +109,10 @@ public class TzktContext : DbContext public DbSet TokenTransfers { get; set; } #endregion + #region tickets + public DbSet Tickets { get; set; } + #endregion + #region rollups public DbSet SmartRollupCommitments { get; set; } public DbSet RefutationGames { get; set; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs new file mode 100644 index 000000000..d89e3732e --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -0,0 +1,101 @@ +using System.Numerics; +using Netezos.Encoding; +using Tzkt.Data.Models; +using Tzkt.Data.Models.Base; + +namespace Tzkt.Sync.Protocols.Proto16 +{ + class TicketsCommit : ProtocolCommit + { + public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } + + public virtual async Task Apply(Block block) + { + var ops = new Dictionary(); + + #region group updates + if (block.TransferTicketOps != null) + { + + + foreach (var tx in block.TransferTicketOps) + { + if (tx.Status != OperationStatus.Applied) continue; + + ops.Add(tx, (false, tx.Ticketer as Contract)); + } + } + + + #endregion + + if (ops.Count == 0) return; + + } + + Account GetOrCreateAccount(ContractOperation op, string address) + { + if (!Cache.Accounts.TryGetCached(address, out var account)) + { + account = address[0] == 't' && address[1] == 'z' + ? new User + { + Id = Cache.AppState.NextAccountId(), + Address = address, + FirstLevel = op.Level, + LastLevel = op.Level, + Type = AccountType.User + } + : new Account + { + Id = Cache.AppState.NextAccountId(), + Address = address, + FirstLevel = op.Level, + LastLevel = op.Level, + Type = AccountType.Ghost + }; + Db.Accounts.Add(account); + Cache.Accounts.Add(account); + + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.NewAccounts; + } + return account; + } + + Ticket GetOrCreateTicket(ContractOperation op, Contract contract, BigInteger ticketId) + { + if (Cache.Tickets.TryGet(contract.Id, ticketId, out var ticket)) return ticket; + + var state = Cache.AppState.Get(); + state.TicketsCount++; + + ticket = new Ticket + { + Id = Cache.AppState.NextSubId(op), + ContractId = contract.Id, + TicketId = ticketId, + FirstMinterId = op.InitiatorId ?? op.SenderId, + FirstLevel = op.Level, + LastLevel = op.Level, + TotalBurned = BigInteger.Zero, + TotalMinted = BigInteger.Zero, + TotalSupply = BigInteger.Zero, + IndexedAt = op.Level <= state.Level ? state.Level + 1 : null + }; + Db.Tickets.Add(ticket); + Cache.Tickets.Add(ticket); + + Db.TryAttach(contract); + contract.TicketsCount++; + + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.Tickets; + return ticket; + } + } +} diff --git a/Tzkt.Sync/Services/Cache/CacheService.cs b/Tzkt.Sync/Services/Cache/CacheService.cs index 58cd0c7e6..319dc8586 100644 --- a/Tzkt.Sync/Services/Cache/CacheService.cs +++ b/Tzkt.Sync/Services/Cache/CacheService.cs @@ -20,6 +20,7 @@ public class CacheService public BigMapsCache BigMaps { get; private set; } public BigMapKeysCache BigMapKeys { get; private set; } public TokensCache Tokens { get; private set; } + public TicketsCache Tickets { get; private set; } public TokenBalancesCache TokenBalances { get; private set; } public SmartRollupCommitmentCache SmartRollupCommitments { get; private set; } public SmartRollupStakesCache SmartRollupStakes { get; private set; } diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs new file mode 100644 index 000000000..9dd032789 --- /dev/null +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +using Tzkt.Data; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Services.Cache +{ + public class TicketsCache + { + public const int MaxItems = 4 * 4096; //TODO: set limits in app settings + + static readonly Dictionary CachedById = new(MaxItems); + static readonly Dictionary<(int, BigInteger), Ticket> CachedByKey = new(MaxItems); + + readonly TzktContext Db; + + public TicketsCache(TzktContext db) + { + Db = db; + } + + public void Reset() + { + CachedById.Clear(); + CachedByKey.Clear(); + } + + public void Trim() + { + if (CachedById.Count > MaxItems * 0.9) + { + var toRemove = CachedById.Values + .OrderBy(x => x.LastLevel) + .Take(MaxItems / 2) + .ToList(); + + foreach (var item in toRemove) + Remove(item); + } + } + + public void Add(Ticket token) + { + CachedById[token.Id] = token; + CachedByKey[(token.ContractId, token.TicketId)] = token; + } + + public void Remove(Ticket token) + { + CachedById.Remove(token.Id); + CachedByKey.Remove((token.ContractId, token.TicketId)); + } + + public bool Has(int contractId, BigInteger tokenId) + { + return CachedByKey.ContainsKey((contractId, tokenId)); + } + + public Ticket GetOrAdd(Ticket token) + { + if (CachedById.TryGetValue(token.Id, out var res)) + return res; + Add(token); + return token; + } + + public Ticket Get(long id) + { + if (!CachedById.TryGetValue(id, out var token)) + throw new Exception($"Ticket #{id} doesn't exist"); + return token; + } + + public Ticket Get(int contractId, BigInteger tokenId) + { + if (!CachedByKey.TryGetValue((contractId, tokenId), out var token)) + throw new Exception($"Ticket ({contractId}, {tokenId}) doesn't exist"); + return token; + } + + public bool TryGet(int contractId, BigInteger tokenId, out Ticket token) + { + return CachedByKey.TryGetValue((contractId, tokenId), out token); + } + + public async Task Preload(IEnumerable ids) + { + var missed = ids.Where(x => !CachedById.ContainsKey(x)).ToHashSet(); + if (missed.Count > 0) + { + var items = await Db.Tickets + .Where(x => missed.Contains(x.Id)) + .ToListAsync(); + + foreach (var item in items) + Add(item); + } + } + + public async Task Preload(IEnumerable<(int, BigInteger)> ids) + { + var missed = ids.Where(x => !CachedByKey.ContainsKey(x)).ToHashSet(); + if (missed.Count > 0) + { + for (int i = 0, n = 2048; i < missed.Count; i += n) + { + var corteges = string.Join(',', missed.Skip(i).Take(n).Select(x => $"({x.Item1}, '{x.Item2}')")); + var items = await Db.Tickets + .FromSqlRaw($@" + SELECT * FROM ""{nameof(TzktContext.Tickets)}"" + WHERE (""{nameof(Ticket.ContractId)}"", ""{nameof(Ticket.TicketId)}"") IN ({corteges})") + .ToListAsync(); + + foreach (var item in items) + Add(item); + } + } + } + } +} From 3bfe63de1c0ac6ceeebed35c71ade43ef98bac47 Mon Sep 17 00:00:00 2001 From: Dmitry Mirgaleev Date: Mon, 17 Jul 2023 12:51:54 +0200 Subject: [PATCH 02/51] WIP tickets --- .../20230717085608_ticket.Designer.cs | 6118 +++++++++++++++++ Tzkt.Data/Migrations/20230717085608_ticket.cs | 87 + .../Migrations/TzktContextModelSnapshot.cs | 66 + .../Commits/Operations/TransactionsCommit.cs | 11 + .../Commits/Operations/TransactionsCommit.cs | 34 +- Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs | 23 + 6 files changed, 6338 insertions(+), 1 deletion(-) create mode 100644 Tzkt.Data/Migrations/20230717085608_ticket.Designer.cs create mode 100644 Tzkt.Data/Migrations/20230717085608_ticket.cs create mode 100644 Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs diff --git a/Tzkt.Data/Migrations/20230717085608_ticket.Designer.cs b/Tzkt.Data/Migrations/20230717085608_ticket.Designer.cs new file mode 100644 index 000000000..b650cd0a4 --- /dev/null +++ b/Tzkt.Data/Migrations/20230717085608_ticket.Designer.cs @@ -0,0 +1,6118 @@ +// +using System; +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Tzkt.Data; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + [DbContext(typeof(TzktContext))] + [Migration("20230717085608_ticket")] + partial class ticket + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveRefutationGamesCount") + .HasColumnType("integer"); + + b.Property("ActiveTokensCount") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character varying(37)"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("ContractsCount") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegationLevel") + .HasColumnType("integer"); + + b.Property("DelegationsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageCount") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("MigrationsCount") + .HasColumnType("integer"); + + b.Property("OriginationsCount") + .HasColumnType("integer"); + + b.Property("RefutationGamesCount") + .HasColumnType("integer"); + + b.Property("RevealsCount") + .HasColumnType("integer"); + + b.Property("RollupBonds") + .HasColumnType("bigint"); + + b.Property("RollupsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesCount") + .HasColumnType("integer"); + + b.Property("SmartRollupBonds") + .HasColumnType("bigint"); + + b.Property("SmartRollupCementCount") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupsCount") + .HasColumnType("integer"); + + b.Property("Staked") + .HasColumnType("boolean"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TransactionsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchCount") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UpdateConsensusKeyCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("DelegateId"); + + b.HasIndex("Extras"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Staked"); + + b.HasIndex("Type"); + + b.ToTable("Accounts"); + + b.HasDiscriminator("Type").HasValue((byte)3); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("ActivationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AppState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountCounter") + .HasColumnType("integer"); + + b.Property("AccountsCount") + .HasColumnType("integer"); + + b.Property("ActivationOpsCount") + .HasColumnType("integer"); + + b.Property("BallotOpsCount") + .HasColumnType("integer"); + + b.Property("BigMapCounter") + .HasColumnType("integer"); + + b.Property("BigMapKeyCounter") + .HasColumnType("integer"); + + b.Property("BigMapUpdateCounter") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Chain") + .HasColumnType("text"); + + b.Property("ChainId") + .HasColumnType("text"); + + b.Property("CommitmentsCount") + .HasColumnType("integer"); + + b.Property("ConstantsCount") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("CyclesCount") + .HasColumnType("integer"); + + b.Property("DelegationOpsCount") + .HasColumnType("integer"); + + b.Property("DomainsLevel") + .HasColumnType("integer"); + + b.Property("DomainsNameRegistry") + .HasColumnType("text"); + + b.Property("DoubleBakingOpsCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsementOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardOpsCount") + .HasColumnType("integer"); + + b.Property("EventCounter") + .HasColumnType("integer"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxMessageCounter") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageOpsCount") + .HasColumnType("integer"); + + b.Property("KnownHead") + .HasColumnType("integer"); + + b.Property("LastSync") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerCounter") + .HasColumnType("integer"); + + b.Property("MigrationOpsCount") + .HasColumnType("integer"); + + b.Property("NextProtocol") + .HasColumnType("text"); + + b.Property("NonceRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("OperationCounter") + .HasColumnType("bigint"); + + b.Property("OriginationOpsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ProtocolsCount") + .HasColumnType("integer"); + + b.Property("QuoteBtc") + .HasColumnType("double precision"); + + b.Property("QuoteCny") + .HasColumnType("double precision"); + + b.Property("QuoteEth") + .HasColumnType("double precision"); + + b.Property("QuoteEur") + .HasColumnType("double precision"); + + b.Property("QuoteGbp") + .HasColumnType("double precision"); + + b.Property("QuoteJpy") + .HasColumnType("double precision"); + + b.Property("QuoteKrw") + .HasColumnType("double precision"); + + b.Property("QuoteLevel") + .HasColumnType("integer"); + + b.Property("QuoteUsd") + .HasColumnType("double precision"); + + b.Property("RefutationGameCounter") + .HasColumnType("integer"); + + b.Property("RegisterConstantOpsCount") + .HasColumnType("integer"); + + b.Property("RevealOpsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltyOpsCount") + .HasColumnType("integer"); + + b.Property("ScriptCounter") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCementOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentCounter") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteOpsCount") + .HasColumnType("integer"); + + b.Property("StorageCounter") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TransactionOpsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchOpsCount") + .HasColumnType("integer"); + + b.Property("UpdateConsensusKeyOpsCount") + .HasColumnType("integer"); + + b.Property("VdfRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("VotingEpoch") + .HasColumnType("integer"); + + b.Property("VotingPeriod") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AppState"); + + b.HasData( + new + { + Id = -1, + AccountCounter = 0, + AccountsCount = 0, + ActivationOpsCount = 0, + BallotOpsCount = 0, + BigMapCounter = 0, + BigMapKeyCounter = 0, + BigMapUpdateCounter = 0, + BlocksCount = 0, + CommitmentsCount = 0, + ConstantsCount = 0, + Cycle = -1, + CyclesCount = 0, + DelegationOpsCount = 0, + DomainsLevel = 0, + DoubleBakingOpsCount = 0, + DoubleEndorsingOpsCount = 0, + DoublePreendorsingOpsCount = 0, + DrainDelegateOpsCount = 0, + EndorsementOpsCount = 0, + EndorsingRewardOpsCount = 0, + EventCounter = 0, + EventsCount = 0, + Hash = "", + InboxMessageCounter = 0, + IncreasePaidStorageOpsCount = 0, + KnownHead = 0, + LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Level = -1, + ManagerCounter = 0, + MigrationOpsCount = 0, + NextProtocol = "", + NonceRevelationOpsCount = 0, + OperationCounter = 0L, + OriginationOpsCount = 0, + PreendorsementOpsCount = 0, + ProposalOpsCount = 0, + ProposalsCount = 0, + Protocol = "", + ProtocolsCount = 0, + QuoteBtc = 0.0, + QuoteCny = 0.0, + QuoteEth = 0.0, + QuoteEur = 0.0, + QuoteGbp = 0.0, + QuoteJpy = 0.0, + QuoteKrw = 0.0, + QuoteLevel = -1, + QuoteUsd = 0.0, + RefutationGameCounter = 0, + RegisterConstantOpsCount = 0, + RevealOpsCount = 0, + RevelationPenaltyOpsCount = 0, + ScriptCounter = 0, + SetDepositsLimitOpsCount = 0, + SmartRollupAddMessagesOpsCount = 0, + SmartRollupCementOpsCount = 0, + SmartRollupCommitmentCounter = 0, + SmartRollupExecuteOpsCount = 0, + SmartRollupOriginateOpsCount = 0, + SmartRollupPublishOpsCount = 0, + SmartRollupRecoverBondOpsCount = 0, + SmartRollupRefuteOpsCount = 0, + StorageCounter = 0, + TicketsCount = 0, + Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + TokenBalancesCount = 0, + TokenTransfersCount = 0, + TokensCount = 0, + TransactionOpsCount = 0, + TransferTicketOpsCount = 0, + TxRollupCommitOpsCount = 0, + TxRollupDispatchTicketsOpsCount = 0, + TxRollupFinalizeCommitmentOpsCount = 0, + TxRollupOriginationOpsCount = 0, + TxRollupRejectionOpsCount = 0, + TxRollupRemoveCommitmentOpsCount = 0, + TxRollupReturnBondOpsCount = 0, + TxRollupSubmitBatchOpsCount = 0, + UpdateConsensusKeyOpsCount = 0, + VdfRevelationOpsCount = 0, + VotingEpoch = -1, + VotingPeriod = -1 + }); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStake") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("BlockFees") + .HasColumnType("bigint"); + + b.Property("BlockRewards") + .HasColumnType("bigint"); + + b.Property("Blocks") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleBakingRewards") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingRewards") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingRewards") + .HasColumnType("bigint"); + + b.Property("EndorsementRewards") + .HasColumnType("bigint"); + + b.Property("Endorsements") + .HasColumnType("integer"); + + b.Property("ExpectedBlocks") + .HasColumnType("double precision"); + + b.Property("ExpectedEndorsements") + .HasColumnType("double precision"); + + b.Property("FutureBlockRewards") + .HasColumnType("bigint"); + + b.Property("FutureBlocks") + .HasColumnType("integer"); + + b.Property("FutureEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("FutureEndorsements") + .HasColumnType("integer"); + + b.Property("MissedBlockFees") + .HasColumnType("bigint"); + + b.Property("MissedBlockRewards") + .HasColumnType("bigint"); + + b.Property("MissedBlocks") + .HasColumnType("integer"); + + b.Property("MissedEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("MissedEndorsements") + .HasColumnType("integer"); + + b.Property("RevelationLosses") + .HasColumnType("bigint"); + + b.Property("RevelationRewards") + .HasColumnType("bigint"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Cycle", "BakerId") + .IsUnique(); + + b.ToTable("BakerCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Round") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakingRights"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Vote") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("BallotOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("ActiveKeys") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("KeyType") + .HasColumnType("bytea"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Ptr") + .HasColumnType("integer"); + + b.Property("StoragePath") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TotalKeys") + .HasColumnType("integer"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.Property("ValueType") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasAlternateKey("Ptr"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Ptr") + .IsUnique(); + + b.ToTable("BigMaps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("JsonKey") + .HasColumnType("jsonb"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("KeyHash") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawKey") + .HasColumnType("bytea"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonKey"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); + + b.HasIndex("JsonValue"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("BigMapPtr", "Active") + .HasFilter("\"Active\" = true"); + + b.HasIndex("BigMapPtr", "KeyHash"); + + b.ToTable("BigMapKeys"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("BigMapKeyId") + .HasColumnType("integer"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BigMapKeyId") + .HasFilter("\"BigMapKeyId\" is not null"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("BigMapUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlockRound") + .HasColumnType("integer"); + + b.Property("Bonus") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Events") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Fees") + .HasColumnType("bigint"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggle") + .HasColumnType("boolean"); + + b.Property("LBToggleEma") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Operations") + .HasColumnType("bigint"); + + b.Property("PayloadRound") + .HasColumnType("integer"); + + b.Property("ProducerId") + .HasColumnType("integer"); + + b.Property("ProposerId") + .HasColumnType("integer"); + + b.Property("ProtoCode") + .HasColumnType("integer"); + + b.Property("ResetBakerDeactivation") + .HasColumnType("integer"); + + b.Property("ResetProposerDeactivation") + .HasColumnType("integer"); + + b.Property("RevelationId") + .HasColumnType("bigint"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Validations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("Level") + .IsUnique(); + + b.HasIndex("ProducerId"); + + b.HasIndex("ProposerId"); + + b.HasIndex("ProtoCode"); + + b.HasIndex("RevelationId") + .IsUnique(); + + b.HasIndex("SoftwareId"); + + b.ToTable("Blocks"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character(37)") + .IsFixedLength(); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Commitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("JsonPayload") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RawPayload") + .HasColumnType("bytea"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonPayload"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("Tag"); + + b.HasIndex("TransactionId"); + + b.HasIndex("ContractCodeHash", "Tag"); + + b.HasIndex("ContractId", "Tag"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Seed") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("SelectedBakers") + .HasColumnType("integer"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("SnapshotIndex") + .HasColumnType("integer"); + + b.Property("SnapshotLevel") + .HasColumnType("integer"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalDelegated") + .HasColumnType("bigint"); + + b.Property("TotalDelegators") + .HasColumnType("integer"); + + b.Property("TotalStaking") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("Cycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevDelegateId") + .HasColumnType("integer"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("PrevDelegateId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.ToTable("DelegationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatorId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("DelegatorId"); + + b.HasIndex("Cycle", "BakerId"); + + b.HasIndex("Cycle", "DelegatorId") + .IsUnique(); + + b.ToTable("DelegatorCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("jsonb"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("Reverse") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("Address"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Level"); + + b.HasIndex("Name"); + + b.HasIndex("Owner"); + + b.ToTable("Domains"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleBakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleEndorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoublePreendorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Fee") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("TargetId"); + + b.ToTable("DrainDelegateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("EndorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Expected") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Received") + .HasColumnType("bigint"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("EndorsingRewardOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Change") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.ToTable("FreezerUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OperationId") + .HasColumnType("bigint"); + + b.Property("Payload") + .HasColumnType("bytea"); + + b.Property("PredecessorLevel") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OperationId"); + + b.HasIndex("Type", "Id"); + + b.ToTable("InboxMessages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("IncreasePaidStorageOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BalanceChange") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Level"); + + b.HasIndex("ScriptId"); + + b.HasIndex("StorageId"); + + b.ToTable("MigrationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RevealedCycle") + .HasColumnType("integer"); + + b.Property("RevealedLevel") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasAlternateKey("RevealedLevel"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RevealedCycle"); + + b.HasIndex("SenderId"); + + b.ToTable("NonceRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash") + .HasFilter("\"ContractCodeHash\" IS NOT NULL"); + + b.HasIndex("ContractId"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("ManagerId"); + + b.HasIndex("OpHash"); + + b.HasIndex("ScriptId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.ToTable("OriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("PreendorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstPeriod") + .HasColumnType("integer"); + + b.Property("Hash") + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastPeriod") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Upvotes") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Hash"); + + b.ToTable("Proposals"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Duplicated") + .HasColumnType("boolean"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("ProposalOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotQuorumMax") + .HasColumnType("integer"); + + b.Property("BallotQuorumMin") + .HasColumnType("integer"); + + b.Property("BlockDeposit") + .HasColumnType("bigint"); + + b.Property("BlockReward0") + .HasColumnType("bigint"); + + b.Property("BlockReward1") + .HasColumnType("bigint"); + + b.Property("BlocksPerCommitment") + .HasColumnType("integer"); + + b.Property("BlocksPerCycle") + .HasColumnType("integer"); + + b.Property("BlocksPerSnapshot") + .HasColumnType("integer"); + + b.Property("BlocksPerVoting") + .HasColumnType("integer"); + + b.Property("ByteCost") + .HasColumnType("integer"); + + b.Property("Code") + .HasColumnType("integer"); + + b.Property("ConsensusThreshold") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("text"); + + b.Property("DoubleBakingPunishment") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingPunishmentDenominator") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingPunishmentNumerator") + .HasColumnType("integer"); + + b.Property("EndorsementDeposit") + .HasColumnType("bigint"); + + b.Property("EndorsementReward0") + .HasColumnType("bigint"); + + b.Property("EndorsementReward1") + .HasColumnType("bigint"); + + b.Property("EndorsersPerBlock") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstCycle") + .HasColumnType("integer"); + + b.Property("FirstCycleLevel") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FrozenDepositsPercentage") + .HasColumnType("integer"); + + b.Property("HardBlockGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationStorageLimit") + .HasColumnType("integer"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBSubsidy") + .HasColumnType("integer"); + + b.Property("LBToggleThreshold") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBakingReward") + .HasColumnType("bigint"); + + b.Property("MaxEndorsingReward") + .HasColumnType("bigint"); + + b.Property("MaxSlashingPeriod") + .HasColumnType("integer"); + + b.Property("MinParticipationDenominator") + .HasColumnType("integer"); + + b.Property("MinParticipationNumerator") + .HasColumnType("integer"); + + b.Property("NoRewardCycles") + .HasColumnType("integer"); + + b.Property("OriginationSize") + .HasColumnType("integer"); + + b.Property("PreservedCycles") + .HasColumnType("integer"); + + b.Property("ProposalQuorum") + .HasColumnType("integer"); + + b.Property("RampUpCycles") + .HasColumnType("integer"); + + b.Property("RevelationReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupChallengeWindow") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentPeriod") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginationSize") + .HasColumnType("integer"); + + b.Property("SmartRollupStakeAmount") + .HasColumnType("bigint"); + + b.Property("SmartRollupTimeoutPeriod") + .HasColumnType("integer"); + + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); + + b.Property("TokensPerRoll") + .HasColumnType("bigint"); + + b.Property("TxRollupCommitmentBond") + .HasColumnType("bigint"); + + b.Property("TxRollupOriginationSize") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Protocols"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Btc") + .HasColumnType("double precision"); + + b.Property("Cny") + .HasColumnType("double precision"); + + b.Property("Eth") + .HasColumnType("double precision"); + + b.Property("Eur") + .HasColumnType("double precision"); + + b.Property("Gbp") + .HasColumnType("double precision"); + + b.Property("Jpy") + .HasColumnType("double precision"); + + b.Property("Krw") + .HasColumnType("double precision"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Usd") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("InitiatorCommitmentId") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InitiatorLoss") + .HasColumnType("bigint"); + + b.Property("InitiatorReward") + .HasColumnType("bigint"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("LastMoveId") + .HasColumnType("bigint"); + + b.Property("OpponentCommitmentId") + .HasColumnType("integer"); + + b.Property("OpponentId") + .HasColumnType("integer"); + + b.Property("OpponentLoss") + .HasColumnType("bigint"); + + b.Property("OpponentReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("InitiatorCommitmentId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("LastLevel"); + + b.HasIndex("OpponentCommitmentId"); + + b.HasIndex("OpponentId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("RefutationGames"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("Refs") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique() + .HasFilter("\"Address\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RegisterConstantOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RevealOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("MissedLevel") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("RevelationPenaltyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Script", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CodeSchema") + .HasColumnType("bytea"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("StorageSchema") + .HasColumnType("bytea"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("Views") + .HasColumnType("bytea[]"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Scripts"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Limit") + .HasColumnType("text"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SetDepositsLimitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MessagesCount") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupAddMessagesOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupCementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("PredecessorId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Stakers") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Successors") + .HasColumnType("integer"); + + b.Property("Ticks") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Hash"); + + b.HasIndex("InboxLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("PredecessorId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("Hash", "SmartRollupId"); + + b.ToTable("SmartRollupCommitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupExecuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("Kernel") + .HasColumnType("bytea"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("OriginationProof") + .HasColumnType("bytea"); + + b.Property("ParameterType") + .HasColumnType("bytea"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupOriginateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("BondStatus") + .HasColumnType("integer"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Flags") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("SmartRollupId", "BondStatus", "SenderId") + .HasFilter("\"BondStatus\" IS NOT NULL"); + + b.ToTable("SmartRollupPublishOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("StakerId"); + + b.ToTable("SmartRollupRecoverBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DissectionEnd") + .HasColumnType("bigint"); + + b.Property("DissectionStart") + .HasColumnType("bigint"); + + b.Property("DissectionSteps") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GameId") + .HasColumnType("integer"); + + b.Property("GameStatus") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Move") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupRefuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .HasFilter("\"DelegateId\" IS NULL"); + + b.ToTable("SnapshotBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("ShortHash") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character(8)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("TotalActivated") + .HasColumnType("bigint"); + + b.Property("TotalBanished") + .HasColumnType("bigint"); + + b.Property("TotalBootstrapped") + .HasColumnType("bigint"); + + b.Property("TotalBurned") + .HasColumnType("bigint"); + + b.Property("TotalCommitments") + .HasColumnType("bigint"); + + b.Property("TotalCreated") + .HasColumnType("bigint"); + + b.Property("TotalFrozen") + .HasColumnType("bigint"); + + b.Property("TotalRollupBonds") + .HasColumnType("bigint"); + + b.Property("TotalSmartRollupBonds") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle") + .IsUnique() + .HasFilter("\"Cycle\" IS NOT NULL"); + + b.HasIndex("Date") + .IsUnique() + .HasFilter("\"Date\" IS NOT NULL"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Statistics"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Storage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("numeric"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Token", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TokenId") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("ContractId", "TokenId") + .IsUnique(); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("ContractId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TokenId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "ContractId"); + + b.HasIndex("AccountId", "TokenId") + .IsUnique(); + + b.ToTable("TokenBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TokenId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("TokenTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InternalDelegations") + .HasColumnType("smallint"); + + b.Property("InternalOperations") + .HasColumnType("smallint"); + + b.Property("InternalOriginations") + .HasColumnType("smallint"); + + b.Property("InternalTransactions") + .HasColumnType("smallint"); + + b.Property("JsonParameters") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawParameters") + .HasColumnType("bytea"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetCodeHash") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("JsonParameters"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.HasIndex("TargetCodeHash") + .HasFilter("\"TargetCodeHash\" IS NOT NULL"); + + b.HasIndex("TargetId"); + + b.ToTable("TransactionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("TargetId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TransferTicketOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupCommitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupDispatchTicketsOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupFinalizeCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupOriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitterId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitterId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRejectionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRemoveCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupReturnBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupSubmitBatchOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("PublicKeyHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("UpdateConsensusKeyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Proof") + .HasColumnType("bytea"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Solution") + .HasColumnType("bytea"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotsQuorum") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("integer"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("NayBallots") + .HasColumnType("integer"); + + b.Property("NayVotingPower") + .HasColumnType("bigint"); + + b.Property("ParticipationEma") + .HasColumnType("integer"); + + b.Property("PassBallots") + .HasColumnType("integer"); + + b.Property("PassVotingPower") + .HasColumnType("bigint"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("SingleWinner") + .HasColumnType("boolean"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Supermajority") + .HasColumnType("integer"); + + b.Property("TopUpvotes") + .HasColumnType("integer"); + + b.Property("TopVotingPower") + .HasColumnType("bigint"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalVotingPower") + .HasColumnType("bigint"); + + b.Property("UpvotesQuorum") + .HasColumnType("integer"); + + b.Property("YayBallots") + .HasColumnType("integer"); + + b.Property("YayVotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Epoch"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("VotingPeriods"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Period"); + + b.HasIndex("Period", "BakerId") + .IsUnique(); + + b.ToTable("VotingSnapshots"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("smallint"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Spendable") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("WeirdDelegateId") + .HasColumnType("integer"); + + b.HasIndex("CodeHash"); + + b.HasIndex("CreatorId"); + + b.HasIndex("ManagerId"); + + b.HasIndex("TypeHash"); + + b.HasIndex("WeirdDelegateId"); + + b.HasIndex("Type", "Kind") + .HasFilter("\"Type\" = 2"); + + b.HasDiscriminator().HasValue((byte)2); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)4); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("CementedCommitments") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("ExecutedCommitments") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("LastCommitment") + .HasColumnType("text"); + + b.Property("OrphanCommitments") + .HasColumnType("integer"); + + b.Property("PendingCommitments") + .HasColumnType("integer"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("RefutedCommitments") + .HasColumnType("integer"); + + b.Property("TotalStakers") + .HasColumnType("integer"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)5); + }); + + modelBuilder.Entity("Tzkt.Data.Models.User", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("Activated") + .HasColumnType("boolean"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("RegisterConstantsCount") + .HasColumnType("integer"); + + b.Property("Revealed") + .HasColumnType("boolean"); + + b.Property("SetDepositsLimitsCount") + .HasColumnType("integer"); + + b.HasDiscriminator().HasValue((byte)0); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasBaseType("Tzkt.Data.Models.User"); + + b.Property("ActivationLevel") + .HasColumnType("integer"); + + b.Property("BallotsCount") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("DeactivationLevel") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingCount") + .HasColumnType("integer"); + + b.Property("EndorsementsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardsCount") + .HasColumnType("integer"); + + b.Property("FrozenDeposit") + .HasColumnType("bigint"); + + b.Property("FrozenDepositLimit") + .HasColumnType("bigint"); + + b.Property("NonceRevelationsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltiesCount") + .HasColumnType("integer"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.Property("VdfRevelationsCount") + .HasColumnType("integer"); + + b.HasIndex("SoftwareId"); + + b.HasIndex("Type", "Staked") + .HasFilter("\"Type\" = 1"); + + b.HasDiscriminator().HasValue((byte)1); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany("DelegatedAccounts") + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") + .WithMany("CreatedAccounts") + .HasForeignKey("FirstLevel") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Delegate"); + + b.Navigation("FirstBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.HasOne("Tzkt.Data.Models.User", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Activations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Ballots") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") + .WithMany() + .HasForeignKey("ProposerId"); + + b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") + .WithMany() + .HasForeignKey("ProtoCode") + .HasPrincipalKey("Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") + .WithOne("RevealedBlock") + .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); + + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Proposer"); + + b.Navigation("Protocol"); + + b.Navigation("Revelation"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Delegations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") + .WithMany() + .HasForeignKey("PrevDelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("PrevDelegate"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleBakings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleEndorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoublePreendorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DrainDelegateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Endorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("IncreasePaidStorageOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Migrations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Account"); + + b.Navigation("Block"); + + b.Navigation("Script"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Revelations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Contract", "Contract") + .WithMany() + .HasForeignKey("ContractId"); + + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Originations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Block"); + + b.Navigation("Contract"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("Manager"); + + b.Navigation("Script"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Preendorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Proposals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RegisterConstants") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Reveals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RevelationPenalties") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDepositsLimits") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupAddMessagesOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupCementOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupExecuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupOriginateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupPublishOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRecoverBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRefuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Transactions") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.HasOne("Tzkt.Data.Models.Account", "Target") + .WithMany() + .HasForeignKey("TargetId"); + + b.Navigation("Block"); + + b.Navigation("Initiator"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TransferTicketOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + + b.Navigation("Ticketer"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupCommitOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupDispatchTicketsOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupFinalizeCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupOriginationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRejectionOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRemoveCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupReturnBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupSubmitBatchOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("UpdateConsensusKeyOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("VdfRevelationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") + .WithMany() + .HasForeignKey("WeirdDelegateId"); + + b.Navigation("Creator"); + + b.Navigation("Manager"); + + b.Navigation("WeirdDelegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Navigation("Activations"); + + b.Navigation("Ballots"); + + b.Navigation("CreatedAccounts"); + + b.Navigation("Delegations"); + + b.Navigation("DoubleBakings"); + + b.Navigation("DoubleEndorsings"); + + b.Navigation("DoublePreendorsings"); + + b.Navigation("DrainDelegateOps"); + + b.Navigation("Endorsements"); + + b.Navigation("IncreasePaidStorageOps"); + + b.Navigation("Migrations"); + + b.Navigation("Originations"); + + b.Navigation("Preendorsements"); + + b.Navigation("Proposals"); + + b.Navigation("RegisterConstants"); + + b.Navigation("Reveals"); + + b.Navigation("RevelationPenalties"); + + b.Navigation("Revelations"); + + b.Navigation("SetDepositsLimits"); + + b.Navigation("SmartRollupAddMessagesOps"); + + b.Navigation("SmartRollupCementOps"); + + b.Navigation("SmartRollupExecuteOps"); + + b.Navigation("SmartRollupOriginateOps"); + + b.Navigation("SmartRollupPublishOps"); + + b.Navigation("SmartRollupRecoverBondOps"); + + b.Navigation("SmartRollupRefuteOps"); + + b.Navigation("Transactions"); + + b.Navigation("TransferTicketOps"); + + b.Navigation("TxRollupCommitOps"); + + b.Navigation("TxRollupDispatchTicketsOps"); + + b.Navigation("TxRollupFinalizeCommitmentOps"); + + b.Navigation("TxRollupOriginationOps"); + + b.Navigation("TxRollupRejectionOps"); + + b.Navigation("TxRollupRemoveCommitmentOps"); + + b.Navigation("TxRollupReturnBondOps"); + + b.Navigation("TxRollupSubmitBatchOps"); + + b.Navigation("UpdateConsensusKeyOps"); + + b.Navigation("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Navigation("RevealedBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.Navigation("DelegatedAccounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tzkt.Data/Migrations/20230717085608_ticket.cs b/Tzkt.Data/Migrations/20230717085608_ticket.cs new file mode 100644 index 000000000..789a721ac --- /dev/null +++ b/Tzkt.Data/Migrations/20230717085608_ticket.cs @@ -0,0 +1,87 @@ +using System.Numerics; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class ticket : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TicketsCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketsCount", + table: "Accounts", + type: "integer", + nullable: true); + + migrationBuilder.CreateTable( + name: "Tickets", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ContractId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "numeric", nullable: false), + FirstMinterId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + BalancesCount = table.Column(type: "integer", nullable: false), + HoldersCount = table.Column(type: "integer", nullable: false), + TotalMinted = table.Column(type: "numeric", nullable: false), + TotalBurned = table.Column(type: "numeric", nullable: false), + TotalSupply = table.Column(type: "numeric", nullable: false), + OwnerId = table.Column(type: "integer", nullable: true), + IndexedAt = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tickets", x => x.Id); + }); + + migrationBuilder.UpdateData( + table: "AppState", + keyColumn: "Id", + keyValue: -1, + column: "TicketsCount", + value: 0); + + migrationBuilder.AddForeignKey( + name: "FK_TransferTicketOps_Accounts_TicketerId", + table: "TransferTicketOps", + column: "TicketerId", + principalTable: "Accounts", + principalColumn: "Id"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TransferTicketOps_Accounts_TicketerId", + table: "TransferTicketOps"); + + migrationBuilder.DropTable( + name: "Tickets"); + + migrationBuilder.DropColumn( + name: "TicketsCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "TicketsCount", + table: "Accounts"); + } + } +} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 4d7ef24f1..142913988 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -1,5 +1,6 @@ // using System; +using System.Numerics; using System.Text.Json; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -448,6 +449,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageCounter") .HasColumnType("integer"); + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -573,6 +577,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, StorageCounter = 0, + TicketsCount = 0, Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TokenBalancesCount = 0, TokenTransfersCount = 0, @@ -3550,6 +3555,58 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Storages"); }); + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("numeric"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Tickets"); + }); + modelBuilder.Entity("Tzkt.Data.Models.Token", b => { b.Property("Id") @@ -4833,6 +4890,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("TokensCount") .HasColumnType("integer"); @@ -5720,9 +5780,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId"); + b.Navigation("Block"); b.Navigation("Sender"); + + b.Navigation("Ticketer"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index f7affc264..b2208707d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -17,6 +17,8 @@ class TransactionsCommit : ProtocolCommit { public TransactionOperation Transaction { get; private set; } public IEnumerable BigMapDiffs { get; private set; } + public IEnumerable TicketUpdates { get; private set; } + public IEnumerable TicketReceipt { get; private set; } public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } @@ -145,6 +147,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content await ProcessStorage(transaction, storage); } + TicketUpdates = ParseTicketUpdates("ticket_updates", result); + if (transaction.Target is SmartRollup) Proto.Inbox.Push(transaction.Id); } @@ -288,6 +292,8 @@ public virtual async Task ApplyInternal(Block block, ManagerOperation parent, Js BigMapDiffs = ParseBigMapDiffs(transaction, result); await ProcessStorage(transaction, storage); } + + TicketReceipt = ParseTicketUpdates("ticket_receipt", result); if (transaction.Target is SmartRollup) Proto.Inbox.Push(transaction.Id); @@ -686,5 +692,10 @@ protected virtual int GetConsumedGas(JsonElement result) { return result.OptionalInt32("consumed_gas") ?? 0; } + + protected virtual IEnumerable ParseTicketUpdates(string property, JsonElement result) + { + return null; + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs index 77c2f248a..0f0b960aa 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs @@ -1,7 +1,39 @@ -namespace Tzkt.Sync.Protocols.Proto17 +using System.Text.Json; +using Netezos.Encoding; + +namespace Tzkt.Sync.Protocols.Proto17 { class TransactionsCommit : Proto14.TransactionsCommit { public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } + + protected override IEnumerable ParseTicketUpdates(string property, JsonElement result) + { + if (!result.TryGetProperty("ticket_receipt", out var ticketUpdates)) + return null; + + return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + { + TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) + ? new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + ContentType = ticketToken.TryGetProperty("content_type", out var contentType) + ? Micheline.FromJson(contentType) + : null, + Content = ticketToken.TryGetProperty("content", out var content) + ? Micheline.FromJson(content) + : null, + } + : null, + Updates = x.TryGetProperty("updates", out var updates) + ? updates.RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = y.RequiredString("amount") + }) + : null + }); + } } } diff --git a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs new file mode 100644 index 000000000..0fa329d39 --- /dev/null +++ b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs @@ -0,0 +1,23 @@ +using Netezos.Encoding; + +namespace Tzkt.Sync.Protocols +{ + public class TicketUpdate + { + public TicketToken TicketToken { get; set; } + public IEnumerable Updates { get; set; } + } + + public class TicketToken + { + public string Ticketer { get; set; } + public IMicheline ContentType { get; set; } + public IMicheline Content { get; set; } + } + + public class Update + { + public string Account { get; set; } + public string Amount { get; set; } + } +} \ No newline at end of file From e4880068dffaf055fffa91e6f55c5926aba65b02 Mon Sep 17 00:00:00 2001 From: Dmitry Mirgaleev Date: Mon, 17 Jul 2023 20:00:07 +0200 Subject: [PATCH 03/51] WIP tickets --- Tzkt.Data/Models/Scripts/TIcket.cs | 9 ++-- .../Commits/Operations/TransactionsCommit.cs | 26 +++++++++- .../Operations/TransferTicketCommit.cs | 33 ++++++++++++ .../Commits/TicketsCommit.cs | 50 +++++++++---------- .../Handlers/Proto17/Proto17Handler.cs | 10 ++++ Tzkt.Sync/Services/Cache/TicketsCache.cs | 34 ++++++------- 6 files changed, 116 insertions(+), 46 deletions(-) rename Tzkt.Sync/Protocols/Handlers/{Proto16 => Proto17}/Commits/TicketsCommit.cs (66%) diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs index 1ddfb5f26..9d0dce7f9 100644 --- a/Tzkt.Data/Models/Scripts/TIcket.cs +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -8,7 +8,7 @@ namespace Tzkt.Data.Models public class Ticket { public long Id { get; set; } - public int ContractId { get; set; } + public int TicketerId { get; set; } public BigInteger TicketId { get; set; } public int FirstMinterId { get; set; } @@ -25,6 +25,9 @@ public class Ticket public int? OwnerId { get; set; } public int? IndexedAt { get; set; } + + public int ContentHash { get; set; } + public int ContentTypeHash { get; set; } } public static class TicketModel @@ -70,10 +73,10 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) .IsUnique(); modelBuilder.Entity() - .HasIndex(x => x.ContractId); + .HasIndex(x => x.TicketerId); modelBuilder.Entity() - .HasIndex(x => new { x.ContractId, x.TicketId }) + .HasIndex(x => new {ContractId = x.TicketerId, x.TicketId }) .IsUnique(); modelBuilder.Entity() diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index b2208707d..ec29cdd18 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -695,7 +695,31 @@ protected virtual int GetConsumedGas(JsonElement result) protected virtual IEnumerable ParseTicketUpdates(string property, JsonElement result) { - return null; + if (!result.TryGetProperty(property, out var ticketUpdates)) + return null; + + return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + { + TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) + ? new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + ContentType = ticketToken.TryGetProperty("content_type", out var contentType) + ? Micheline.FromJson(contentType) + : null, + Content = ticketToken.TryGetProperty("content", out var content) + ? Micheline.FromJson(content) + : null, + } + : null, + Updates = x.TryGetProperty("updates", out var updates) + ? updates.RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = y.RequiredString("amount") + }) + : null + }); } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 81d018c32..73cfe1bde 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -13,6 +13,8 @@ namespace Tzkt.Sync.Protocols.Proto13 class TransferTicketCommit : ProtocolCommit { public TransferTicketOperation Operation { get; private set; } + public IEnumerable TicketUpdates { get; private set; } + public TransferTicketCommit(ProtocolHandler protocol) : base(protocol) { } @@ -120,6 +122,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content if (senderDelegate.Id != sender.Id) senderDelegate.DelegatedBalance -= burned; } + + TicketUpdates = ParseTicketUpdates(result); } #endregion @@ -195,5 +199,34 @@ public virtual async Task Revert(Block block, TransferTicketOperation operation) Cache.AppState.ReleaseManagerCounter(); Cache.AppState.ReleaseOperationId(); } + + protected virtual IEnumerable ParseTicketUpdates(JsonElement result) + { + if (!result.TryGetProperty("ticket_update", out var ticketUpdates)) + return null; + + return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + { + TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) + ? new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + ContentType = ticketToken.TryGetProperty("content_type", out var contentType) + ? Micheline.FromJson(contentType) + : null, + Content = ticketToken.TryGetProperty("content", out var content) + ? Micheline.FromJson(content) + : null, + } + : null, + Updates = x.TryGetProperty("updates", out var updates) + ? updates.RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = y.RequiredString("amount") + }) + : null + }); + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs similarity index 66% rename from Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs rename to Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index d89e3732e..afb1ac23d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -3,37 +3,29 @@ using Tzkt.Data.Models; using Tzkt.Data.Models.Base; -namespace Tzkt.Sync.Protocols.Proto16 +namespace Tzkt.Sync.Protocols.Proto17 { class TicketsCommit : ProtocolCommit { public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } - public virtual async Task Apply(Block block) + readonly List Updates = new(); + + public virtual void Append(IEnumerable updates) + { + Updates.AddRange(updates); + } + + public virtual async Task Apply() { - var ops = new Dictionary(); - - #region group updates - if (block.TransferTicketOps != null) + foreach (var update in Updates) { - - - foreach (var tx in block.TransferTicketOps) - { - if (tx.Status != OperationStatus.Applied) continue; - - ops.Add(tx, (false, tx.Ticketer as Contract)); - } + // var ticket = GetOrCreateTicket(); } - - #endregion - - if (ops.Count == 0) return; } @@ -67,9 +59,9 @@ Account GetOrCreateAccount(ContractOperation op, string address) return account; } - Ticket GetOrCreateTicket(ContractOperation op, Contract contract, BigInteger ticketId) + Ticket GetOrCreateTicket(TicketUpdate update, ContractOperation op, Contract contract, int contentHash, int contentTypeHash) { - if (Cache.Tickets.TryGet(contract.Id, ticketId, out var ticket)) return ticket; + if (Cache.Tickets.TryGet(contract.Id, contentHash, contentTypeHash, out var ticket)) return ticket; var state = Cache.AppState.Get(); state.TicketsCount++; @@ -77,14 +69,15 @@ Ticket GetOrCreateTicket(ContractOperation op, Contract contract, BigInteger tic ticket = new Ticket { Id = Cache.AppState.NextSubId(op), - ContractId = contract.Id, - TicketId = ticketId, + TicketerId = contract.Id, FirstMinterId = op.InitiatorId ?? op.SenderId, FirstLevel = op.Level, LastLevel = op.Level, TotalBurned = BigInteger.Zero, TotalMinted = BigInteger.Zero, TotalSupply = BigInteger.Zero, + ContentHash = Script.GetHash(update.TicketToken.Content.ToBytes()), + ContentTypeHash = Script.GetHash(update.TicketToken.ContentType.ToBytes()), IndexedAt = op.Level <= state.Level ? state.Level + 1 : null }; Db.Tickets.Add(ticket); @@ -97,5 +90,12 @@ Ticket GetOrCreateTicket(ContractOperation op, Contract contract, BigInteger tic op.Block.Events |= BlockEvents.Tickets; return ticket; } + + public virtual async Task Revert(Block block) + { + //TODO Implement revert + + throw new NotImplementedException("Revert for Tickets commit not implemented yet"); + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index 837b8ef5c..ab85c8640 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -131,6 +131,7 @@ public override async Task Commit(JsonElement block) #endregion var bigMapCommit = new BigMapCommit(this); + var ticketsCommit = new TicketsCommit(this); #region operations 3 foreach (var operation in operations[3].EnumerateArray()) @@ -169,6 +170,8 @@ public override async Task Commit(JsonElement block) await parent.Apply(blockCommit.Block, operation, content); if (parent.BigMapDiffs != null) bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); + if (parent.TicketUpdates != null) + ticketsCommit.Append(parent.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) { @@ -190,6 +193,8 @@ public override async Task Commit(JsonElement block) await internalTx.ApplyInternal(blockCommit.Block, parent.Transaction, internalContent); if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -227,6 +232,8 @@ public override async Task Commit(JsonElement block) case "transfer_ticket": var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); + if (parent1.TicketUpdates != null) + ticketsCommit.Append(parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) @@ -238,6 +245,8 @@ public override async Task Commit(JsonElement block) await internalTx.ApplyInternal(blockCommit.Block, parent1.Operation, internalContent); if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(internalTx.TicketUpdates); break; default: throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); @@ -310,6 +319,7 @@ public override async Task Commit(JsonElement block) new InboxCommit(this).Apply(blockCommit.Block); await bigMapCommit.Apply(); + await ticketsCommit.Apply(); await new TokensCommit(this).Apply(blockCommit.Block, bigMapCommit.Updates); var brCommit = new BakingRightsCommit(this); diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs index 9dd032789..c4e4dec9e 100644 --- a/Tzkt.Sync/Services/Cache/TicketsCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -15,7 +15,7 @@ public class TicketsCache public const int MaxItems = 4 * 4096; //TODO: set limits in app settings static readonly Dictionary CachedById = new(MaxItems); - static readonly Dictionary<(int, BigInteger), Ticket> CachedByKey = new(MaxItems); + static readonly Dictionary<(int ContractId, int ContentHash, int ContentTypeHash), Ticket> CachedByKey = new(MaxItems); readonly TzktContext Db; @@ -44,21 +44,21 @@ public void Trim() } } - public void Add(Ticket token) + public void Add(Ticket ticket) { - CachedById[token.Id] = token; - CachedByKey[(token.ContractId, token.TicketId)] = token; + CachedById[ticket.Id] = ticket; + CachedByKey[(ticket.TicketerId, ticket.ContentHash, ticket.ContentTypeHash)] = ticket; } - public void Remove(Ticket token) + public void Remove(Ticket ticket) { - CachedById.Remove(token.Id); - CachedByKey.Remove((token.ContractId, token.TicketId)); + CachedById.Remove(ticket.Id); + CachedByKey.Remove((ticket.TicketerId, ticket.ContentHash, ticket.ContentTypeHash)); } - public bool Has(int contractId, BigInteger tokenId) + public bool Has(int contractId, int contentHash, int contentTypeHash) { - return CachedByKey.ContainsKey((contractId, tokenId)); + return CachedByKey.ContainsKey((contractId, contentHash, contentTypeHash)); } public Ticket GetOrAdd(Ticket token) @@ -76,16 +76,16 @@ public Ticket Get(long id) return token; } - public Ticket Get(int contractId, BigInteger tokenId) + public Ticket Get(int contractId, int contentHash, int contentTypeHash) { - if (!CachedByKey.TryGetValue((contractId, tokenId), out var token)) - throw new Exception($"Ticket ({contractId}, {tokenId}) doesn't exist"); - return token; + if (!CachedByKey.TryGetValue((contractId, contentHash, contentTypeHash), out var ticket)) + throw new Exception($"Ticket ({contractId}, {contentHash}, {contentTypeHash}) doesn't exist"); + return ticket; } - public bool TryGet(int contractId, BigInteger tokenId, out Ticket token) + public bool TryGet(int contractId, int contentHash, int contentTypeHash, out Ticket token) { - return CachedByKey.TryGetValue((contractId, tokenId), out token); + return CachedByKey.TryGetValue((contractId, contentHash, contentTypeHash), out token); } public async Task Preload(IEnumerable ids) @@ -102,7 +102,7 @@ public async Task Preload(IEnumerable ids) } } - public async Task Preload(IEnumerable<(int, BigInteger)> ids) + public async Task Preload(IEnumerable<(int, int, int)> ids) { var missed = ids.Where(x => !CachedByKey.ContainsKey(x)).ToHashSet(); if (missed.Count > 0) @@ -113,7 +113,7 @@ public async Task Preload(IEnumerable<(int, BigInteger)> ids) var items = await Db.Tickets .FromSqlRaw($@" SELECT * FROM ""{nameof(TzktContext.Tickets)}"" - WHERE (""{nameof(Ticket.ContractId)}"", ""{nameof(Ticket.TicketId)}"") IN ({corteges})") + WHERE (""{nameof(Ticket.TicketerId)}"", ""{nameof(Ticket.TicketId)}"") IN ({corteges})") .ToListAsync(); foreach (var item in items) From 58a01e9eb917ade0bc7374e48477896f30546bb3 Mon Sep 17 00:00:00 2001 From: Dmitry Mirgaleev Date: Tue, 18 Jul 2023 19:15:35 +0200 Subject: [PATCH 04/51] WIP TicketUpdates and TicketTransfers --- .../20230718133721_tickets.Designer.cs | 6124 ++++++++++++++++ .../Migrations/20230718133721_tickets.cs | 50 + .../20230718171450_ticketUpdates.Designer.cs | 6227 +++++++++++++++++ .../20230718171450_ticketUpdates.cs | 150 + .../Migrations/TzktContextModelSnapshot.cs | 111 +- Tzkt.Data/Models/Accounts/Account.cs | 5 + Tzkt.Data/Models/AppState.cs | 2 + .../Operations/Base/ContractOperation.cs | 1 + Tzkt.Data/Models/Scripts/TicketBalance.cs | 82 + Tzkt.Data/Models/Scripts/TicketTransfer.cs | 84 + Tzkt.Data/TzktContext.cs | 2 + .../Commits/Operations/TransactionsCommit.cs | 2 +- .../Handlers/Proto17/Commits/TicketsCommit.cs | 169 +- .../Handlers/Proto17/Proto17Handler.cs | 9 +- Tzkt.Sync/Services/Cache/CacheService.cs | 5 +- .../Services/Cache/TicketBalancesCache.cs | 94 + 16 files changed, 13102 insertions(+), 15 deletions(-) create mode 100644 Tzkt.Data/Migrations/20230718133721_tickets.Designer.cs create mode 100644 Tzkt.Data/Migrations/20230718133721_tickets.cs create mode 100644 Tzkt.Data/Migrations/20230718171450_ticketUpdates.Designer.cs create mode 100644 Tzkt.Data/Migrations/20230718171450_ticketUpdates.cs create mode 100644 Tzkt.Data/Models/Scripts/TicketBalance.cs create mode 100644 Tzkt.Data/Models/Scripts/TicketTransfer.cs create mode 100644 Tzkt.Sync/Services/Cache/TicketBalancesCache.cs diff --git a/Tzkt.Data/Migrations/20230718133721_tickets.Designer.cs b/Tzkt.Data/Migrations/20230718133721_tickets.Designer.cs new file mode 100644 index 000000000..7097afaa4 --- /dev/null +++ b/Tzkt.Data/Migrations/20230718133721_tickets.Designer.cs @@ -0,0 +1,6124 @@ +// +using System; +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Tzkt.Data; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + [DbContext(typeof(TzktContext))] + [Migration("20230718133721_tickets")] + partial class tickets + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveRefutationGamesCount") + .HasColumnType("integer"); + + b.Property("ActiveTokensCount") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character varying(37)"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("ContractsCount") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegationLevel") + .HasColumnType("integer"); + + b.Property("DelegationsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageCount") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("MigrationsCount") + .HasColumnType("integer"); + + b.Property("OriginationsCount") + .HasColumnType("integer"); + + b.Property("RefutationGamesCount") + .HasColumnType("integer"); + + b.Property("RevealsCount") + .HasColumnType("integer"); + + b.Property("RollupBonds") + .HasColumnType("bigint"); + + b.Property("RollupsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesCount") + .HasColumnType("integer"); + + b.Property("SmartRollupBonds") + .HasColumnType("bigint"); + + b.Property("SmartRollupCementCount") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupsCount") + .HasColumnType("integer"); + + b.Property("Staked") + .HasColumnType("boolean"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TransactionsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchCount") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UpdateConsensusKeyCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("DelegateId"); + + b.HasIndex("Extras"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Staked"); + + b.HasIndex("Type"); + + b.ToTable("Accounts"); + + b.HasDiscriminator("Type").HasValue((byte)3); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("ActivationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AppState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountCounter") + .HasColumnType("integer"); + + b.Property("AccountsCount") + .HasColumnType("integer"); + + b.Property("ActivationOpsCount") + .HasColumnType("integer"); + + b.Property("BallotOpsCount") + .HasColumnType("integer"); + + b.Property("BigMapCounter") + .HasColumnType("integer"); + + b.Property("BigMapKeyCounter") + .HasColumnType("integer"); + + b.Property("BigMapUpdateCounter") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Chain") + .HasColumnType("text"); + + b.Property("ChainId") + .HasColumnType("text"); + + b.Property("CommitmentsCount") + .HasColumnType("integer"); + + b.Property("ConstantsCount") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("CyclesCount") + .HasColumnType("integer"); + + b.Property("DelegationOpsCount") + .HasColumnType("integer"); + + b.Property("DomainsLevel") + .HasColumnType("integer"); + + b.Property("DomainsNameRegistry") + .HasColumnType("text"); + + b.Property("DoubleBakingOpsCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsementOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardOpsCount") + .HasColumnType("integer"); + + b.Property("EventCounter") + .HasColumnType("integer"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxMessageCounter") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageOpsCount") + .HasColumnType("integer"); + + b.Property("KnownHead") + .HasColumnType("integer"); + + b.Property("LastSync") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerCounter") + .HasColumnType("integer"); + + b.Property("MigrationOpsCount") + .HasColumnType("integer"); + + b.Property("NextProtocol") + .HasColumnType("text"); + + b.Property("NonceRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("OperationCounter") + .HasColumnType("bigint"); + + b.Property("OriginationOpsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ProtocolsCount") + .HasColumnType("integer"); + + b.Property("QuoteBtc") + .HasColumnType("double precision"); + + b.Property("QuoteCny") + .HasColumnType("double precision"); + + b.Property("QuoteEth") + .HasColumnType("double precision"); + + b.Property("QuoteEur") + .HasColumnType("double precision"); + + b.Property("QuoteGbp") + .HasColumnType("double precision"); + + b.Property("QuoteJpy") + .HasColumnType("double precision"); + + b.Property("QuoteKrw") + .HasColumnType("double precision"); + + b.Property("QuoteLevel") + .HasColumnType("integer"); + + b.Property("QuoteUsd") + .HasColumnType("double precision"); + + b.Property("RefutationGameCounter") + .HasColumnType("integer"); + + b.Property("RegisterConstantOpsCount") + .HasColumnType("integer"); + + b.Property("RevealOpsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltyOpsCount") + .HasColumnType("integer"); + + b.Property("ScriptCounter") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCementOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentCounter") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteOpsCount") + .HasColumnType("integer"); + + b.Property("StorageCounter") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TransactionOpsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchOpsCount") + .HasColumnType("integer"); + + b.Property("UpdateConsensusKeyOpsCount") + .HasColumnType("integer"); + + b.Property("VdfRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("VotingEpoch") + .HasColumnType("integer"); + + b.Property("VotingPeriod") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AppState"); + + b.HasData( + new + { + Id = -1, + AccountCounter = 0, + AccountsCount = 0, + ActivationOpsCount = 0, + BallotOpsCount = 0, + BigMapCounter = 0, + BigMapKeyCounter = 0, + BigMapUpdateCounter = 0, + BlocksCount = 0, + CommitmentsCount = 0, + ConstantsCount = 0, + Cycle = -1, + CyclesCount = 0, + DelegationOpsCount = 0, + DomainsLevel = 0, + DoubleBakingOpsCount = 0, + DoubleEndorsingOpsCount = 0, + DoublePreendorsingOpsCount = 0, + DrainDelegateOpsCount = 0, + EndorsementOpsCount = 0, + EndorsingRewardOpsCount = 0, + EventCounter = 0, + EventsCount = 0, + Hash = "", + InboxMessageCounter = 0, + IncreasePaidStorageOpsCount = 0, + KnownHead = 0, + LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Level = -1, + ManagerCounter = 0, + MigrationOpsCount = 0, + NextProtocol = "", + NonceRevelationOpsCount = 0, + OperationCounter = 0L, + OriginationOpsCount = 0, + PreendorsementOpsCount = 0, + ProposalOpsCount = 0, + ProposalsCount = 0, + Protocol = "", + ProtocolsCount = 0, + QuoteBtc = 0.0, + QuoteCny = 0.0, + QuoteEth = 0.0, + QuoteEur = 0.0, + QuoteGbp = 0.0, + QuoteJpy = 0.0, + QuoteKrw = 0.0, + QuoteLevel = -1, + QuoteUsd = 0.0, + RefutationGameCounter = 0, + RegisterConstantOpsCount = 0, + RevealOpsCount = 0, + RevelationPenaltyOpsCount = 0, + ScriptCounter = 0, + SetDepositsLimitOpsCount = 0, + SmartRollupAddMessagesOpsCount = 0, + SmartRollupCementOpsCount = 0, + SmartRollupCommitmentCounter = 0, + SmartRollupExecuteOpsCount = 0, + SmartRollupOriginateOpsCount = 0, + SmartRollupPublishOpsCount = 0, + SmartRollupRecoverBondOpsCount = 0, + SmartRollupRefuteOpsCount = 0, + StorageCounter = 0, + TicketsCount = 0, + Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + TokenBalancesCount = 0, + TokenTransfersCount = 0, + TokensCount = 0, + TransactionOpsCount = 0, + TransferTicketOpsCount = 0, + TxRollupCommitOpsCount = 0, + TxRollupDispatchTicketsOpsCount = 0, + TxRollupFinalizeCommitmentOpsCount = 0, + TxRollupOriginationOpsCount = 0, + TxRollupRejectionOpsCount = 0, + TxRollupRemoveCommitmentOpsCount = 0, + TxRollupReturnBondOpsCount = 0, + TxRollupSubmitBatchOpsCount = 0, + UpdateConsensusKeyOpsCount = 0, + VdfRevelationOpsCount = 0, + VotingEpoch = -1, + VotingPeriod = -1 + }); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStake") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("BlockFees") + .HasColumnType("bigint"); + + b.Property("BlockRewards") + .HasColumnType("bigint"); + + b.Property("Blocks") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleBakingRewards") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingRewards") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingRewards") + .HasColumnType("bigint"); + + b.Property("EndorsementRewards") + .HasColumnType("bigint"); + + b.Property("Endorsements") + .HasColumnType("integer"); + + b.Property("ExpectedBlocks") + .HasColumnType("double precision"); + + b.Property("ExpectedEndorsements") + .HasColumnType("double precision"); + + b.Property("FutureBlockRewards") + .HasColumnType("bigint"); + + b.Property("FutureBlocks") + .HasColumnType("integer"); + + b.Property("FutureEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("FutureEndorsements") + .HasColumnType("integer"); + + b.Property("MissedBlockFees") + .HasColumnType("bigint"); + + b.Property("MissedBlockRewards") + .HasColumnType("bigint"); + + b.Property("MissedBlocks") + .HasColumnType("integer"); + + b.Property("MissedEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("MissedEndorsements") + .HasColumnType("integer"); + + b.Property("RevelationLosses") + .HasColumnType("bigint"); + + b.Property("RevelationRewards") + .HasColumnType("bigint"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Cycle", "BakerId") + .IsUnique(); + + b.ToTable("BakerCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Round") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakingRights"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Vote") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("BallotOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("ActiveKeys") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("KeyType") + .HasColumnType("bytea"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Ptr") + .HasColumnType("integer"); + + b.Property("StoragePath") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TotalKeys") + .HasColumnType("integer"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.Property("ValueType") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasAlternateKey("Ptr"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Ptr") + .IsUnique(); + + b.ToTable("BigMaps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("JsonKey") + .HasColumnType("jsonb"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("KeyHash") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawKey") + .HasColumnType("bytea"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonKey"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); + + b.HasIndex("JsonValue"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("BigMapPtr", "Active") + .HasFilter("\"Active\" = true"); + + b.HasIndex("BigMapPtr", "KeyHash"); + + b.ToTable("BigMapKeys"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("BigMapKeyId") + .HasColumnType("integer"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BigMapKeyId") + .HasFilter("\"BigMapKeyId\" is not null"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("BigMapUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlockRound") + .HasColumnType("integer"); + + b.Property("Bonus") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Events") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Fees") + .HasColumnType("bigint"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggle") + .HasColumnType("boolean"); + + b.Property("LBToggleEma") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Operations") + .HasColumnType("bigint"); + + b.Property("PayloadRound") + .HasColumnType("integer"); + + b.Property("ProducerId") + .HasColumnType("integer"); + + b.Property("ProposerId") + .HasColumnType("integer"); + + b.Property("ProtoCode") + .HasColumnType("integer"); + + b.Property("ResetBakerDeactivation") + .HasColumnType("integer"); + + b.Property("ResetProposerDeactivation") + .HasColumnType("integer"); + + b.Property("RevelationId") + .HasColumnType("bigint"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Validations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("Level") + .IsUnique(); + + b.HasIndex("ProducerId"); + + b.HasIndex("ProposerId"); + + b.HasIndex("ProtoCode"); + + b.HasIndex("RevelationId") + .IsUnique(); + + b.HasIndex("SoftwareId"); + + b.ToTable("Blocks"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character(37)") + .IsFixedLength(); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Commitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("JsonPayload") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RawPayload") + .HasColumnType("bytea"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonPayload"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("Tag"); + + b.HasIndex("TransactionId"); + + b.HasIndex("ContractCodeHash", "Tag"); + + b.HasIndex("ContractId", "Tag"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Seed") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("SelectedBakers") + .HasColumnType("integer"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("SnapshotIndex") + .HasColumnType("integer"); + + b.Property("SnapshotLevel") + .HasColumnType("integer"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalDelegated") + .HasColumnType("bigint"); + + b.Property("TotalDelegators") + .HasColumnType("integer"); + + b.Property("TotalStaking") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("Cycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevDelegateId") + .HasColumnType("integer"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("PrevDelegateId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.ToTable("DelegationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatorId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("DelegatorId"); + + b.HasIndex("Cycle", "BakerId"); + + b.HasIndex("Cycle", "DelegatorId") + .IsUnique(); + + b.ToTable("DelegatorCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("jsonb"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("Reverse") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("Address"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Level"); + + b.HasIndex("Name"); + + b.HasIndex("Owner"); + + b.ToTable("Domains"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleBakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleEndorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoublePreendorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Fee") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("TargetId"); + + b.ToTable("DrainDelegateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("EndorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Expected") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Received") + .HasColumnType("bigint"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("EndorsingRewardOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Change") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.ToTable("FreezerUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OperationId") + .HasColumnType("bigint"); + + b.Property("Payload") + .HasColumnType("bytea"); + + b.Property("PredecessorLevel") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OperationId"); + + b.HasIndex("Type", "Id"); + + b.ToTable("InboxMessages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("IncreasePaidStorageOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BalanceChange") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Level"); + + b.HasIndex("ScriptId"); + + b.HasIndex("StorageId"); + + b.ToTable("MigrationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RevealedCycle") + .HasColumnType("integer"); + + b.Property("RevealedLevel") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasAlternateKey("RevealedLevel"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RevealedCycle"); + + b.HasIndex("SenderId"); + + b.ToTable("NonceRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash") + .HasFilter("\"ContractCodeHash\" IS NOT NULL"); + + b.HasIndex("ContractId"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("ManagerId"); + + b.HasIndex("OpHash"); + + b.HasIndex("ScriptId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.ToTable("OriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("PreendorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstPeriod") + .HasColumnType("integer"); + + b.Property("Hash") + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastPeriod") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Upvotes") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Hash"); + + b.ToTable("Proposals"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Duplicated") + .HasColumnType("boolean"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("ProposalOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotQuorumMax") + .HasColumnType("integer"); + + b.Property("BallotQuorumMin") + .HasColumnType("integer"); + + b.Property("BlockDeposit") + .HasColumnType("bigint"); + + b.Property("BlockReward0") + .HasColumnType("bigint"); + + b.Property("BlockReward1") + .HasColumnType("bigint"); + + b.Property("BlocksPerCommitment") + .HasColumnType("integer"); + + b.Property("BlocksPerCycle") + .HasColumnType("integer"); + + b.Property("BlocksPerSnapshot") + .HasColumnType("integer"); + + b.Property("BlocksPerVoting") + .HasColumnType("integer"); + + b.Property("ByteCost") + .HasColumnType("integer"); + + b.Property("Code") + .HasColumnType("integer"); + + b.Property("ConsensusThreshold") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("text"); + + b.Property("DoubleBakingPunishment") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingPunishmentDenominator") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingPunishmentNumerator") + .HasColumnType("integer"); + + b.Property("EndorsementDeposit") + .HasColumnType("bigint"); + + b.Property("EndorsementReward0") + .HasColumnType("bigint"); + + b.Property("EndorsementReward1") + .HasColumnType("bigint"); + + b.Property("EndorsersPerBlock") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstCycle") + .HasColumnType("integer"); + + b.Property("FirstCycleLevel") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FrozenDepositsPercentage") + .HasColumnType("integer"); + + b.Property("HardBlockGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationStorageLimit") + .HasColumnType("integer"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBSubsidy") + .HasColumnType("integer"); + + b.Property("LBToggleThreshold") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBakingReward") + .HasColumnType("bigint"); + + b.Property("MaxEndorsingReward") + .HasColumnType("bigint"); + + b.Property("MaxSlashingPeriod") + .HasColumnType("integer"); + + b.Property("MinParticipationDenominator") + .HasColumnType("integer"); + + b.Property("MinParticipationNumerator") + .HasColumnType("integer"); + + b.Property("NoRewardCycles") + .HasColumnType("integer"); + + b.Property("OriginationSize") + .HasColumnType("integer"); + + b.Property("PreservedCycles") + .HasColumnType("integer"); + + b.Property("ProposalQuorum") + .HasColumnType("integer"); + + b.Property("RampUpCycles") + .HasColumnType("integer"); + + b.Property("RevelationReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupChallengeWindow") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentPeriod") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginationSize") + .HasColumnType("integer"); + + b.Property("SmartRollupStakeAmount") + .HasColumnType("bigint"); + + b.Property("SmartRollupTimeoutPeriod") + .HasColumnType("integer"); + + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); + + b.Property("TokensPerRoll") + .HasColumnType("bigint"); + + b.Property("TxRollupCommitmentBond") + .HasColumnType("bigint"); + + b.Property("TxRollupOriginationSize") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Protocols"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Btc") + .HasColumnType("double precision"); + + b.Property("Cny") + .HasColumnType("double precision"); + + b.Property("Eth") + .HasColumnType("double precision"); + + b.Property("Eur") + .HasColumnType("double precision"); + + b.Property("Gbp") + .HasColumnType("double precision"); + + b.Property("Jpy") + .HasColumnType("double precision"); + + b.Property("Krw") + .HasColumnType("double precision"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Usd") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("InitiatorCommitmentId") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InitiatorLoss") + .HasColumnType("bigint"); + + b.Property("InitiatorReward") + .HasColumnType("bigint"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("LastMoveId") + .HasColumnType("bigint"); + + b.Property("OpponentCommitmentId") + .HasColumnType("integer"); + + b.Property("OpponentId") + .HasColumnType("integer"); + + b.Property("OpponentLoss") + .HasColumnType("bigint"); + + b.Property("OpponentReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("InitiatorCommitmentId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("LastLevel"); + + b.HasIndex("OpponentCommitmentId"); + + b.HasIndex("OpponentId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("RefutationGames"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("Refs") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique() + .HasFilter("\"Address\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RegisterConstantOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RevealOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("MissedLevel") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("RevelationPenaltyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Script", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CodeSchema") + .HasColumnType("bytea"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("StorageSchema") + .HasColumnType("bytea"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("Views") + .HasColumnType("bytea[]"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Scripts"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Limit") + .HasColumnType("text"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SetDepositsLimitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MessagesCount") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupAddMessagesOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupCementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("PredecessorId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Stakers") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Successors") + .HasColumnType("integer"); + + b.Property("Ticks") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Hash"); + + b.HasIndex("InboxLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("PredecessorId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("Hash", "SmartRollupId"); + + b.ToTable("SmartRollupCommitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupExecuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("Kernel") + .HasColumnType("bytea"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("OriginationProof") + .HasColumnType("bytea"); + + b.Property("ParameterType") + .HasColumnType("bytea"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupOriginateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("BondStatus") + .HasColumnType("integer"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Flags") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("SmartRollupId", "BondStatus", "SenderId") + .HasFilter("\"BondStatus\" IS NOT NULL"); + + b.ToTable("SmartRollupPublishOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("StakerId"); + + b.ToTable("SmartRollupRecoverBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DissectionEnd") + .HasColumnType("bigint"); + + b.Property("DissectionStart") + .HasColumnType("bigint"); + + b.Property("DissectionSteps") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GameId") + .HasColumnType("integer"); + + b.Property("GameStatus") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Move") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupRefuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .HasFilter("\"DelegateId\" IS NULL"); + + b.ToTable("SnapshotBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("ShortHash") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character(8)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("TotalActivated") + .HasColumnType("bigint"); + + b.Property("TotalBanished") + .HasColumnType("bigint"); + + b.Property("TotalBootstrapped") + .HasColumnType("bigint"); + + b.Property("TotalBurned") + .HasColumnType("bigint"); + + b.Property("TotalCommitments") + .HasColumnType("bigint"); + + b.Property("TotalCreated") + .HasColumnType("bigint"); + + b.Property("TotalFrozen") + .HasColumnType("bigint"); + + b.Property("TotalRollupBonds") + .HasColumnType("bigint"); + + b.Property("TotalSmartRollupBonds") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle") + .IsUnique() + .HasFilter("\"Cycle\" IS NOT NULL"); + + b.HasIndex("Date") + .IsUnique() + .HasFilter("\"Date\" IS NOT NULL"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Statistics"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Storage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentTypeHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("numeric"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Token", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TokenId") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("ContractId", "TokenId") + .IsUnique(); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("ContractId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TokenId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "ContractId"); + + b.HasIndex("AccountId", "TokenId") + .IsUnique(); + + b.ToTable("TokenBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TokenId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("TokenTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InternalDelegations") + .HasColumnType("smallint"); + + b.Property("InternalOperations") + .HasColumnType("smallint"); + + b.Property("InternalOriginations") + .HasColumnType("smallint"); + + b.Property("InternalTransactions") + .HasColumnType("smallint"); + + b.Property("JsonParameters") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawParameters") + .HasColumnType("bytea"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetCodeHash") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("JsonParameters"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.HasIndex("TargetCodeHash") + .HasFilter("\"TargetCodeHash\" IS NOT NULL"); + + b.HasIndex("TargetId"); + + b.ToTable("TransactionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("TargetId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TransferTicketOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupCommitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupDispatchTicketsOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupFinalizeCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupOriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitterId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitterId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRejectionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRemoveCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupReturnBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupSubmitBatchOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("PublicKeyHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("UpdateConsensusKeyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Proof") + .HasColumnType("bytea"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Solution") + .HasColumnType("bytea"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotsQuorum") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("integer"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("NayBallots") + .HasColumnType("integer"); + + b.Property("NayVotingPower") + .HasColumnType("bigint"); + + b.Property("ParticipationEma") + .HasColumnType("integer"); + + b.Property("PassBallots") + .HasColumnType("integer"); + + b.Property("PassVotingPower") + .HasColumnType("bigint"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("SingleWinner") + .HasColumnType("boolean"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Supermajority") + .HasColumnType("integer"); + + b.Property("TopUpvotes") + .HasColumnType("integer"); + + b.Property("TopVotingPower") + .HasColumnType("bigint"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalVotingPower") + .HasColumnType("bigint"); + + b.Property("UpvotesQuorum") + .HasColumnType("integer"); + + b.Property("YayBallots") + .HasColumnType("integer"); + + b.Property("YayVotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Epoch"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("VotingPeriods"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Period"); + + b.HasIndex("Period", "BakerId") + .IsUnique(); + + b.ToTable("VotingSnapshots"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("smallint"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Spendable") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("WeirdDelegateId") + .HasColumnType("integer"); + + b.HasIndex("CodeHash"); + + b.HasIndex("CreatorId"); + + b.HasIndex("ManagerId"); + + b.HasIndex("TypeHash"); + + b.HasIndex("WeirdDelegateId"); + + b.HasIndex("Type", "Kind") + .HasFilter("\"Type\" = 2"); + + b.HasDiscriminator().HasValue((byte)2); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)4); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("CementedCommitments") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("ExecutedCommitments") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("LastCommitment") + .HasColumnType("text"); + + b.Property("OrphanCommitments") + .HasColumnType("integer"); + + b.Property("PendingCommitments") + .HasColumnType("integer"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("RefutedCommitments") + .HasColumnType("integer"); + + b.Property("TotalStakers") + .HasColumnType("integer"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)5); + }); + + modelBuilder.Entity("Tzkt.Data.Models.User", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("Activated") + .HasColumnType("boolean"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("RegisterConstantsCount") + .HasColumnType("integer"); + + b.Property("Revealed") + .HasColumnType("boolean"); + + b.Property("SetDepositsLimitsCount") + .HasColumnType("integer"); + + b.HasDiscriminator().HasValue((byte)0); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasBaseType("Tzkt.Data.Models.User"); + + b.Property("ActivationLevel") + .HasColumnType("integer"); + + b.Property("BallotsCount") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("DeactivationLevel") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingCount") + .HasColumnType("integer"); + + b.Property("EndorsementsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardsCount") + .HasColumnType("integer"); + + b.Property("FrozenDeposit") + .HasColumnType("bigint"); + + b.Property("FrozenDepositLimit") + .HasColumnType("bigint"); + + b.Property("NonceRevelationsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltiesCount") + .HasColumnType("integer"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.Property("VdfRevelationsCount") + .HasColumnType("integer"); + + b.HasIndex("SoftwareId"); + + b.HasIndex("Type", "Staked") + .HasFilter("\"Type\" = 1"); + + b.HasDiscriminator().HasValue((byte)1); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany("DelegatedAccounts") + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") + .WithMany("CreatedAccounts") + .HasForeignKey("FirstLevel") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Delegate"); + + b.Navigation("FirstBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.HasOne("Tzkt.Data.Models.User", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Activations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Ballots") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") + .WithMany() + .HasForeignKey("ProposerId"); + + b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") + .WithMany() + .HasForeignKey("ProtoCode") + .HasPrincipalKey("Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") + .WithOne("RevealedBlock") + .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); + + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Proposer"); + + b.Navigation("Protocol"); + + b.Navigation("Revelation"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Delegations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") + .WithMany() + .HasForeignKey("PrevDelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("PrevDelegate"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleBakings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleEndorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoublePreendorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DrainDelegateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Endorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("IncreasePaidStorageOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Migrations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Account"); + + b.Navigation("Block"); + + b.Navigation("Script"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Revelations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Contract", "Contract") + .WithMany() + .HasForeignKey("ContractId"); + + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Originations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Block"); + + b.Navigation("Contract"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("Manager"); + + b.Navigation("Script"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Preendorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Proposals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RegisterConstants") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Reveals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RevelationPenalties") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDepositsLimits") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupAddMessagesOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupCementOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupExecuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupOriginateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupPublishOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRecoverBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRefuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Transactions") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.HasOne("Tzkt.Data.Models.Account", "Target") + .WithMany() + .HasForeignKey("TargetId"); + + b.Navigation("Block"); + + b.Navigation("Initiator"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TransferTicketOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + + b.Navigation("Ticketer"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupCommitOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupDispatchTicketsOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupFinalizeCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupOriginationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRejectionOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRemoveCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupReturnBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupSubmitBatchOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("UpdateConsensusKeyOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("VdfRevelationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") + .WithMany() + .HasForeignKey("WeirdDelegateId"); + + b.Navigation("Creator"); + + b.Navigation("Manager"); + + b.Navigation("WeirdDelegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Navigation("Activations"); + + b.Navigation("Ballots"); + + b.Navigation("CreatedAccounts"); + + b.Navigation("Delegations"); + + b.Navigation("DoubleBakings"); + + b.Navigation("DoubleEndorsings"); + + b.Navigation("DoublePreendorsings"); + + b.Navigation("DrainDelegateOps"); + + b.Navigation("Endorsements"); + + b.Navigation("IncreasePaidStorageOps"); + + b.Navigation("Migrations"); + + b.Navigation("Originations"); + + b.Navigation("Preendorsements"); + + b.Navigation("Proposals"); + + b.Navigation("RegisterConstants"); + + b.Navigation("Reveals"); + + b.Navigation("RevelationPenalties"); + + b.Navigation("Revelations"); + + b.Navigation("SetDepositsLimits"); + + b.Navigation("SmartRollupAddMessagesOps"); + + b.Navigation("SmartRollupCementOps"); + + b.Navigation("SmartRollupExecuteOps"); + + b.Navigation("SmartRollupOriginateOps"); + + b.Navigation("SmartRollupPublishOps"); + + b.Navigation("SmartRollupRecoverBondOps"); + + b.Navigation("SmartRollupRefuteOps"); + + b.Navigation("Transactions"); + + b.Navigation("TransferTicketOps"); + + b.Navigation("TxRollupCommitOps"); + + b.Navigation("TxRollupDispatchTicketsOps"); + + b.Navigation("TxRollupFinalizeCommitmentOps"); + + b.Navigation("TxRollupOriginationOps"); + + b.Navigation("TxRollupRejectionOps"); + + b.Navigation("TxRollupRemoveCommitmentOps"); + + b.Navigation("TxRollupReturnBondOps"); + + b.Navigation("TxRollupSubmitBatchOps"); + + b.Navigation("UpdateConsensusKeyOps"); + + b.Navigation("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Navigation("RevealedBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.Navigation("DelegatedAccounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tzkt.Data/Migrations/20230718133721_tickets.cs b/Tzkt.Data/Migrations/20230718133721_tickets.cs new file mode 100644 index 000000000..c299e989c --- /dev/null +++ b/Tzkt.Data/Migrations/20230718133721_tickets.cs @@ -0,0 +1,50 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class tickets : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "ContractId", + table: "Tickets", + newName: "TicketerId"); + + migrationBuilder.AddColumn( + name: "ContentHash", + table: "Tickets", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ContentTypeHash", + table: "Tickets", + type: "integer", + nullable: false, + defaultValue: 0); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ContentHash", + table: "Tickets"); + + migrationBuilder.DropColumn( + name: "ContentTypeHash", + table: "Tickets"); + + migrationBuilder.RenameColumn( + name: "TicketerId", + table: "Tickets", + newName: "ContractId"); + } + } +} diff --git a/Tzkt.Data/Migrations/20230718171450_ticketUpdates.Designer.cs b/Tzkt.Data/Migrations/20230718171450_ticketUpdates.Designer.cs new file mode 100644 index 000000000..92108a280 --- /dev/null +++ b/Tzkt.Data/Migrations/20230718171450_ticketUpdates.Designer.cs @@ -0,0 +1,6227 @@ +// +using System; +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Tzkt.Data; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + [DbContext(typeof(TzktContext))] + [Migration("20230718171450_ticketUpdates")] + partial class ticketUpdates + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveRefutationGamesCount") + .HasColumnType("integer"); + + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + + b.Property("ActiveTokensCount") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character varying(37)"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("ContractsCount") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegationLevel") + .HasColumnType("integer"); + + b.Property("DelegationsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageCount") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("MigrationsCount") + .HasColumnType("integer"); + + b.Property("OriginationsCount") + .HasColumnType("integer"); + + b.Property("RefutationGamesCount") + .HasColumnType("integer"); + + b.Property("RevealsCount") + .HasColumnType("integer"); + + b.Property("RollupBonds") + .HasColumnType("bigint"); + + b.Property("RollupsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesCount") + .HasColumnType("integer"); + + b.Property("SmartRollupBonds") + .HasColumnType("bigint"); + + b.Property("SmartRollupCementCount") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupsCount") + .HasColumnType("integer"); + + b.Property("Staked") + .HasColumnType("boolean"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TransactionsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchCount") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UpdateConsensusKeyCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("DelegateId"); + + b.HasIndex("Extras"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Staked"); + + b.HasIndex("Type"); + + b.ToTable("Accounts"); + + b.HasDiscriminator("Type").HasValue((byte)3); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("ActivationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AppState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountCounter") + .HasColumnType("integer"); + + b.Property("AccountsCount") + .HasColumnType("integer"); + + b.Property("ActivationOpsCount") + .HasColumnType("integer"); + + b.Property("BallotOpsCount") + .HasColumnType("integer"); + + b.Property("BigMapCounter") + .HasColumnType("integer"); + + b.Property("BigMapKeyCounter") + .HasColumnType("integer"); + + b.Property("BigMapUpdateCounter") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Chain") + .HasColumnType("text"); + + b.Property("ChainId") + .HasColumnType("text"); + + b.Property("CommitmentsCount") + .HasColumnType("integer"); + + b.Property("ConstantsCount") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("CyclesCount") + .HasColumnType("integer"); + + b.Property("DelegationOpsCount") + .HasColumnType("integer"); + + b.Property("DomainsLevel") + .HasColumnType("integer"); + + b.Property("DomainsNameRegistry") + .HasColumnType("text"); + + b.Property("DoubleBakingOpsCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsementOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardOpsCount") + .HasColumnType("integer"); + + b.Property("EventCounter") + .HasColumnType("integer"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxMessageCounter") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageOpsCount") + .HasColumnType("integer"); + + b.Property("KnownHead") + .HasColumnType("integer"); + + b.Property("LastSync") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerCounter") + .HasColumnType("integer"); + + b.Property("MigrationOpsCount") + .HasColumnType("integer"); + + b.Property("NextProtocol") + .HasColumnType("text"); + + b.Property("NonceRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("OperationCounter") + .HasColumnType("bigint"); + + b.Property("OriginationOpsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ProtocolsCount") + .HasColumnType("integer"); + + b.Property("QuoteBtc") + .HasColumnType("double precision"); + + b.Property("QuoteCny") + .HasColumnType("double precision"); + + b.Property("QuoteEth") + .HasColumnType("double precision"); + + b.Property("QuoteEur") + .HasColumnType("double precision"); + + b.Property("QuoteGbp") + .HasColumnType("double precision"); + + b.Property("QuoteJpy") + .HasColumnType("double precision"); + + b.Property("QuoteKrw") + .HasColumnType("double precision"); + + b.Property("QuoteLevel") + .HasColumnType("integer"); + + b.Property("QuoteUsd") + .HasColumnType("double precision"); + + b.Property("RefutationGameCounter") + .HasColumnType("integer"); + + b.Property("RegisterConstantOpsCount") + .HasColumnType("integer"); + + b.Property("RevealOpsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltyOpsCount") + .HasColumnType("integer"); + + b.Property("ScriptCounter") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCementOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentCounter") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteOpsCount") + .HasColumnType("integer"); + + b.Property("StorageCounter") + .HasColumnType("integer"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TransactionOpsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchOpsCount") + .HasColumnType("integer"); + + b.Property("UpdateConsensusKeyOpsCount") + .HasColumnType("integer"); + + b.Property("VdfRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("VotingEpoch") + .HasColumnType("integer"); + + b.Property("VotingPeriod") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AppState"); + + b.HasData( + new + { + Id = -1, + AccountCounter = 0, + AccountsCount = 0, + ActivationOpsCount = 0, + BallotOpsCount = 0, + BigMapCounter = 0, + BigMapKeyCounter = 0, + BigMapUpdateCounter = 0, + BlocksCount = 0, + CommitmentsCount = 0, + ConstantsCount = 0, + Cycle = -1, + CyclesCount = 0, + DelegationOpsCount = 0, + DomainsLevel = 0, + DoubleBakingOpsCount = 0, + DoubleEndorsingOpsCount = 0, + DoublePreendorsingOpsCount = 0, + DrainDelegateOpsCount = 0, + EndorsementOpsCount = 0, + EndorsingRewardOpsCount = 0, + EventCounter = 0, + EventsCount = 0, + Hash = "", + InboxMessageCounter = 0, + IncreasePaidStorageOpsCount = 0, + KnownHead = 0, + LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Level = -1, + ManagerCounter = 0, + MigrationOpsCount = 0, + NextProtocol = "", + NonceRevelationOpsCount = 0, + OperationCounter = 0L, + OriginationOpsCount = 0, + PreendorsementOpsCount = 0, + ProposalOpsCount = 0, + ProposalsCount = 0, + Protocol = "", + ProtocolsCount = 0, + QuoteBtc = 0.0, + QuoteCny = 0.0, + QuoteEth = 0.0, + QuoteEur = 0.0, + QuoteGbp = 0.0, + QuoteJpy = 0.0, + QuoteKrw = 0.0, + QuoteLevel = -1, + QuoteUsd = 0.0, + RefutationGameCounter = 0, + RegisterConstantOpsCount = 0, + RevealOpsCount = 0, + RevelationPenaltyOpsCount = 0, + ScriptCounter = 0, + SetDepositsLimitOpsCount = 0, + SmartRollupAddMessagesOpsCount = 0, + SmartRollupCementOpsCount = 0, + SmartRollupCommitmentCounter = 0, + SmartRollupExecuteOpsCount = 0, + SmartRollupOriginateOpsCount = 0, + SmartRollupPublishOpsCount = 0, + SmartRollupRecoverBondOpsCount = 0, + SmartRollupRefuteOpsCount = 0, + StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, + Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + TokenBalancesCount = 0, + TokenTransfersCount = 0, + TokensCount = 0, + TransactionOpsCount = 0, + TransferTicketOpsCount = 0, + TxRollupCommitOpsCount = 0, + TxRollupDispatchTicketsOpsCount = 0, + TxRollupFinalizeCommitmentOpsCount = 0, + TxRollupOriginationOpsCount = 0, + TxRollupRejectionOpsCount = 0, + TxRollupRemoveCommitmentOpsCount = 0, + TxRollupReturnBondOpsCount = 0, + TxRollupSubmitBatchOpsCount = 0, + UpdateConsensusKeyOpsCount = 0, + VdfRevelationOpsCount = 0, + VotingEpoch = -1, + VotingPeriod = -1 + }); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStake") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("BlockFees") + .HasColumnType("bigint"); + + b.Property("BlockRewards") + .HasColumnType("bigint"); + + b.Property("Blocks") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleBakingRewards") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingRewards") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingRewards") + .HasColumnType("bigint"); + + b.Property("EndorsementRewards") + .HasColumnType("bigint"); + + b.Property("Endorsements") + .HasColumnType("integer"); + + b.Property("ExpectedBlocks") + .HasColumnType("double precision"); + + b.Property("ExpectedEndorsements") + .HasColumnType("double precision"); + + b.Property("FutureBlockRewards") + .HasColumnType("bigint"); + + b.Property("FutureBlocks") + .HasColumnType("integer"); + + b.Property("FutureEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("FutureEndorsements") + .HasColumnType("integer"); + + b.Property("MissedBlockFees") + .HasColumnType("bigint"); + + b.Property("MissedBlockRewards") + .HasColumnType("bigint"); + + b.Property("MissedBlocks") + .HasColumnType("integer"); + + b.Property("MissedEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("MissedEndorsements") + .HasColumnType("integer"); + + b.Property("RevelationLosses") + .HasColumnType("bigint"); + + b.Property("RevelationRewards") + .HasColumnType("bigint"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Cycle", "BakerId") + .IsUnique(); + + b.ToTable("BakerCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Round") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakingRights"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Vote") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("BallotOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("ActiveKeys") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("KeyType") + .HasColumnType("bytea"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Ptr") + .HasColumnType("integer"); + + b.Property("StoragePath") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TotalKeys") + .HasColumnType("integer"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.Property("ValueType") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasAlternateKey("Ptr"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Ptr") + .IsUnique(); + + b.ToTable("BigMaps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("JsonKey") + .HasColumnType("jsonb"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("KeyHash") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawKey") + .HasColumnType("bytea"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonKey"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); + + b.HasIndex("JsonValue"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("BigMapPtr", "Active") + .HasFilter("\"Active\" = true"); + + b.HasIndex("BigMapPtr", "KeyHash"); + + b.ToTable("BigMapKeys"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("BigMapKeyId") + .HasColumnType("integer"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BigMapKeyId") + .HasFilter("\"BigMapKeyId\" is not null"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("BigMapUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlockRound") + .HasColumnType("integer"); + + b.Property("Bonus") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Events") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Fees") + .HasColumnType("bigint"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggle") + .HasColumnType("boolean"); + + b.Property("LBToggleEma") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Operations") + .HasColumnType("bigint"); + + b.Property("PayloadRound") + .HasColumnType("integer"); + + b.Property("ProducerId") + .HasColumnType("integer"); + + b.Property("ProposerId") + .HasColumnType("integer"); + + b.Property("ProtoCode") + .HasColumnType("integer"); + + b.Property("ResetBakerDeactivation") + .HasColumnType("integer"); + + b.Property("ResetProposerDeactivation") + .HasColumnType("integer"); + + b.Property("RevelationId") + .HasColumnType("bigint"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Validations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("Level") + .IsUnique(); + + b.HasIndex("ProducerId"); + + b.HasIndex("ProposerId"); + + b.HasIndex("ProtoCode"); + + b.HasIndex("RevelationId") + .IsUnique(); + + b.HasIndex("SoftwareId"); + + b.ToTable("Blocks"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character(37)") + .IsFixedLength(); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Commitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("JsonPayload") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RawPayload") + .HasColumnType("bytea"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonPayload"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("Tag"); + + b.HasIndex("TransactionId"); + + b.HasIndex("ContractCodeHash", "Tag"); + + b.HasIndex("ContractId", "Tag"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Seed") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("SelectedBakers") + .HasColumnType("integer"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("SnapshotIndex") + .HasColumnType("integer"); + + b.Property("SnapshotLevel") + .HasColumnType("integer"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalDelegated") + .HasColumnType("bigint"); + + b.Property("TotalDelegators") + .HasColumnType("integer"); + + b.Property("TotalStaking") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("Cycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevDelegateId") + .HasColumnType("integer"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("PrevDelegateId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.ToTable("DelegationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatorId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("DelegatorId"); + + b.HasIndex("Cycle", "BakerId"); + + b.HasIndex("Cycle", "DelegatorId") + .IsUnique(); + + b.ToTable("DelegatorCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("jsonb"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("Reverse") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("Address"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Level"); + + b.HasIndex("Name"); + + b.HasIndex("Owner"); + + b.ToTable("Domains"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleBakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleEndorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoublePreendorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Fee") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("TargetId"); + + b.ToTable("DrainDelegateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("EndorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Expected") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Received") + .HasColumnType("bigint"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("EndorsingRewardOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Change") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.ToTable("FreezerUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OperationId") + .HasColumnType("bigint"); + + b.Property("Payload") + .HasColumnType("bytea"); + + b.Property("PredecessorLevel") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OperationId"); + + b.HasIndex("Type", "Id"); + + b.ToTable("InboxMessages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("IncreasePaidStorageOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BalanceChange") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Level"); + + b.HasIndex("ScriptId"); + + b.HasIndex("StorageId"); + + b.ToTable("MigrationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RevealedCycle") + .HasColumnType("integer"); + + b.Property("RevealedLevel") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasAlternateKey("RevealedLevel"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RevealedCycle"); + + b.HasIndex("SenderId"); + + b.ToTable("NonceRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash") + .HasFilter("\"ContractCodeHash\" IS NOT NULL"); + + b.HasIndex("ContractId"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("ManagerId"); + + b.HasIndex("OpHash"); + + b.HasIndex("ScriptId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.ToTable("OriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("PreendorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstPeriod") + .HasColumnType("integer"); + + b.Property("Hash") + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastPeriod") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Upvotes") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Hash"); + + b.ToTable("Proposals"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Duplicated") + .HasColumnType("boolean"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("ProposalOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotQuorumMax") + .HasColumnType("integer"); + + b.Property("BallotQuorumMin") + .HasColumnType("integer"); + + b.Property("BlockDeposit") + .HasColumnType("bigint"); + + b.Property("BlockReward0") + .HasColumnType("bigint"); + + b.Property("BlockReward1") + .HasColumnType("bigint"); + + b.Property("BlocksPerCommitment") + .HasColumnType("integer"); + + b.Property("BlocksPerCycle") + .HasColumnType("integer"); + + b.Property("BlocksPerSnapshot") + .HasColumnType("integer"); + + b.Property("BlocksPerVoting") + .HasColumnType("integer"); + + b.Property("ByteCost") + .HasColumnType("integer"); + + b.Property("Code") + .HasColumnType("integer"); + + b.Property("ConsensusThreshold") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("text"); + + b.Property("DoubleBakingPunishment") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingPunishmentDenominator") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingPunishmentNumerator") + .HasColumnType("integer"); + + b.Property("EndorsementDeposit") + .HasColumnType("bigint"); + + b.Property("EndorsementReward0") + .HasColumnType("bigint"); + + b.Property("EndorsementReward1") + .HasColumnType("bigint"); + + b.Property("EndorsersPerBlock") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstCycle") + .HasColumnType("integer"); + + b.Property("FirstCycleLevel") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FrozenDepositsPercentage") + .HasColumnType("integer"); + + b.Property("HardBlockGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationStorageLimit") + .HasColumnType("integer"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBSubsidy") + .HasColumnType("integer"); + + b.Property("LBToggleThreshold") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBakingReward") + .HasColumnType("bigint"); + + b.Property("MaxEndorsingReward") + .HasColumnType("bigint"); + + b.Property("MaxSlashingPeriod") + .HasColumnType("integer"); + + b.Property("MinParticipationDenominator") + .HasColumnType("integer"); + + b.Property("MinParticipationNumerator") + .HasColumnType("integer"); + + b.Property("NoRewardCycles") + .HasColumnType("integer"); + + b.Property("OriginationSize") + .HasColumnType("integer"); + + b.Property("PreservedCycles") + .HasColumnType("integer"); + + b.Property("ProposalQuorum") + .HasColumnType("integer"); + + b.Property("RampUpCycles") + .HasColumnType("integer"); + + b.Property("RevelationReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupChallengeWindow") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentPeriod") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginationSize") + .HasColumnType("integer"); + + b.Property("SmartRollupStakeAmount") + .HasColumnType("bigint"); + + b.Property("SmartRollupTimeoutPeriod") + .HasColumnType("integer"); + + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); + + b.Property("TokensPerRoll") + .HasColumnType("bigint"); + + b.Property("TxRollupCommitmentBond") + .HasColumnType("bigint"); + + b.Property("TxRollupOriginationSize") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Protocols"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Btc") + .HasColumnType("double precision"); + + b.Property("Cny") + .HasColumnType("double precision"); + + b.Property("Eth") + .HasColumnType("double precision"); + + b.Property("Eur") + .HasColumnType("double precision"); + + b.Property("Gbp") + .HasColumnType("double precision"); + + b.Property("Jpy") + .HasColumnType("double precision"); + + b.Property("Krw") + .HasColumnType("double precision"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Usd") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("InitiatorCommitmentId") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InitiatorLoss") + .HasColumnType("bigint"); + + b.Property("InitiatorReward") + .HasColumnType("bigint"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("LastMoveId") + .HasColumnType("bigint"); + + b.Property("OpponentCommitmentId") + .HasColumnType("integer"); + + b.Property("OpponentId") + .HasColumnType("integer"); + + b.Property("OpponentLoss") + .HasColumnType("bigint"); + + b.Property("OpponentReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("InitiatorCommitmentId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("LastLevel"); + + b.HasIndex("OpponentCommitmentId"); + + b.HasIndex("OpponentId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("RefutationGames"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("Refs") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique() + .HasFilter("\"Address\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RegisterConstantOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RevealOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("MissedLevel") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("RevelationPenaltyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Script", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CodeSchema") + .HasColumnType("bytea"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("StorageSchema") + .HasColumnType("bytea"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("Views") + .HasColumnType("bytea[]"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Scripts"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Limit") + .HasColumnType("text"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SetDepositsLimitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MessagesCount") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupAddMessagesOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupCementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("PredecessorId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Stakers") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Successors") + .HasColumnType("integer"); + + b.Property("Ticks") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Hash"); + + b.HasIndex("InboxLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("PredecessorId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("Hash", "SmartRollupId"); + + b.ToTable("SmartRollupCommitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupExecuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("Kernel") + .HasColumnType("bytea"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("OriginationProof") + .HasColumnType("bytea"); + + b.Property("ParameterType") + .HasColumnType("bytea"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupOriginateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("BondStatus") + .HasColumnType("integer"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Flags") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("SmartRollupId", "BondStatus", "SenderId") + .HasFilter("\"BondStatus\" IS NOT NULL"); + + b.ToTable("SmartRollupPublishOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("StakerId"); + + b.ToTable("SmartRollupRecoverBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DissectionEnd") + .HasColumnType("bigint"); + + b.Property("DissectionStart") + .HasColumnType("bigint"); + + b.Property("DissectionSteps") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GameId") + .HasColumnType("integer"); + + b.Property("GameStatus") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Move") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupRefuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .HasFilter("\"DelegateId\" IS NULL"); + + b.ToTable("SnapshotBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("ShortHash") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character(8)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("TotalActivated") + .HasColumnType("bigint"); + + b.Property("TotalBanished") + .HasColumnType("bigint"); + + b.Property("TotalBootstrapped") + .HasColumnType("bigint"); + + b.Property("TotalBurned") + .HasColumnType("bigint"); + + b.Property("TotalCommitments") + .HasColumnType("bigint"); + + b.Property("TotalCreated") + .HasColumnType("bigint"); + + b.Property("TotalFrozen") + .HasColumnType("bigint"); + + b.Property("TotalRollupBonds") + .HasColumnType("bigint"); + + b.Property("TotalSmartRollupBonds") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle") + .IsUnique() + .HasFilter("\"Cycle\" IS NOT NULL"); + + b.HasIndex("Date") + .IsUnique() + .HasFilter("\"Date\" IS NOT NULL"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Statistics"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Storage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentTypeHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("numeric"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("numeric"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("TicketTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Token", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TokenId") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("ContractId", "TokenId") + .IsUnique(); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("ContractId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TokenId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "ContractId"); + + b.HasIndex("AccountId", "TokenId") + .IsUnique(); + + b.ToTable("TokenBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TokenId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("TokenTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InternalDelegations") + .HasColumnType("smallint"); + + b.Property("InternalOperations") + .HasColumnType("smallint"); + + b.Property("InternalOriginations") + .HasColumnType("smallint"); + + b.Property("InternalTransactions") + .HasColumnType("smallint"); + + b.Property("JsonParameters") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawParameters") + .HasColumnType("bytea"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetCodeHash") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("JsonParameters"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.HasIndex("TargetCodeHash") + .HasFilter("\"TargetCodeHash\" IS NOT NULL"); + + b.HasIndex("TargetId"); + + b.ToTable("TransactionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("TargetId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TransferTicketOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupCommitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupDispatchTicketsOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupFinalizeCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupOriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitterId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitterId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRejectionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRemoveCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupReturnBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupSubmitBatchOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("PublicKeyHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("UpdateConsensusKeyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Proof") + .HasColumnType("bytea"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Solution") + .HasColumnType("bytea"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotsQuorum") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("integer"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("NayBallots") + .HasColumnType("integer"); + + b.Property("NayVotingPower") + .HasColumnType("bigint"); + + b.Property("ParticipationEma") + .HasColumnType("integer"); + + b.Property("PassBallots") + .HasColumnType("integer"); + + b.Property("PassVotingPower") + .HasColumnType("bigint"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("SingleWinner") + .HasColumnType("boolean"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Supermajority") + .HasColumnType("integer"); + + b.Property("TopUpvotes") + .HasColumnType("integer"); + + b.Property("TopVotingPower") + .HasColumnType("bigint"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalVotingPower") + .HasColumnType("bigint"); + + b.Property("UpvotesQuorum") + .HasColumnType("integer"); + + b.Property("YayBallots") + .HasColumnType("integer"); + + b.Property("YayVotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Epoch"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("VotingPeriods"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Period"); + + b.HasIndex("Period", "BakerId") + .IsUnique(); + + b.ToTable("VotingSnapshots"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("smallint"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Spendable") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("WeirdDelegateId") + .HasColumnType("integer"); + + b.HasIndex("CodeHash"); + + b.HasIndex("CreatorId"); + + b.HasIndex("ManagerId"); + + b.HasIndex("TypeHash"); + + b.HasIndex("WeirdDelegateId"); + + b.HasIndex("Type", "Kind") + .HasFilter("\"Type\" = 2"); + + b.HasDiscriminator().HasValue((byte)2); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)4); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("CementedCommitments") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("ExecutedCommitments") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("LastCommitment") + .HasColumnType("text"); + + b.Property("OrphanCommitments") + .HasColumnType("integer"); + + b.Property("PendingCommitments") + .HasColumnType("integer"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("RefutedCommitments") + .HasColumnType("integer"); + + b.Property("TotalStakers") + .HasColumnType("integer"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)5); + }); + + modelBuilder.Entity("Tzkt.Data.Models.User", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("Activated") + .HasColumnType("boolean"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("RegisterConstantsCount") + .HasColumnType("integer"); + + b.Property("Revealed") + .HasColumnType("boolean"); + + b.Property("SetDepositsLimitsCount") + .HasColumnType("integer"); + + b.HasDiscriminator().HasValue((byte)0); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasBaseType("Tzkt.Data.Models.User"); + + b.Property("ActivationLevel") + .HasColumnType("integer"); + + b.Property("BallotsCount") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("DeactivationLevel") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingCount") + .HasColumnType("integer"); + + b.Property("EndorsementsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardsCount") + .HasColumnType("integer"); + + b.Property("FrozenDeposit") + .HasColumnType("bigint"); + + b.Property("FrozenDepositLimit") + .HasColumnType("bigint"); + + b.Property("NonceRevelationsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltiesCount") + .HasColumnType("integer"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.Property("VdfRevelationsCount") + .HasColumnType("integer"); + + b.HasIndex("SoftwareId"); + + b.HasIndex("Type", "Staked") + .HasFilter("\"Type\" = 1"); + + b.HasDiscriminator().HasValue((byte)1); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany("DelegatedAccounts") + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") + .WithMany("CreatedAccounts") + .HasForeignKey("FirstLevel") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Delegate"); + + b.Navigation("FirstBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.HasOne("Tzkt.Data.Models.User", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Activations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Ballots") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") + .WithMany() + .HasForeignKey("ProposerId"); + + b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") + .WithMany() + .HasForeignKey("ProtoCode") + .HasPrincipalKey("Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") + .WithOne("RevealedBlock") + .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); + + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Proposer"); + + b.Navigation("Protocol"); + + b.Navigation("Revelation"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Delegations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") + .WithMany() + .HasForeignKey("PrevDelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("PrevDelegate"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleBakings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleEndorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoublePreendorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DrainDelegateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Endorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("IncreasePaidStorageOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Migrations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Account"); + + b.Navigation("Block"); + + b.Navigation("Script"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Revelations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Contract", "Contract") + .WithMany() + .HasForeignKey("ContractId"); + + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Originations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Block"); + + b.Navigation("Contract"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("Manager"); + + b.Navigation("Script"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Preendorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Proposals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RegisterConstants") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Reveals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RevelationPenalties") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDepositsLimits") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupAddMessagesOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupCementOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupExecuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupOriginateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupPublishOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRecoverBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRefuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Transactions") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.HasOne("Tzkt.Data.Models.Account", "Target") + .WithMany() + .HasForeignKey("TargetId"); + + b.Navigation("Block"); + + b.Navigation("Initiator"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TransferTicketOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + + b.Navigation("Ticketer"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupCommitOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupDispatchTicketsOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupFinalizeCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupOriginationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRejectionOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRemoveCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupReturnBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupSubmitBatchOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("UpdateConsensusKeyOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("VdfRevelationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") + .WithMany() + .HasForeignKey("WeirdDelegateId"); + + b.Navigation("Creator"); + + b.Navigation("Manager"); + + b.Navigation("WeirdDelegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Navigation("Activations"); + + b.Navigation("Ballots"); + + b.Navigation("CreatedAccounts"); + + b.Navigation("Delegations"); + + b.Navigation("DoubleBakings"); + + b.Navigation("DoubleEndorsings"); + + b.Navigation("DoublePreendorsings"); + + b.Navigation("DrainDelegateOps"); + + b.Navigation("Endorsements"); + + b.Navigation("IncreasePaidStorageOps"); + + b.Navigation("Migrations"); + + b.Navigation("Originations"); + + b.Navigation("Preendorsements"); + + b.Navigation("Proposals"); + + b.Navigation("RegisterConstants"); + + b.Navigation("Reveals"); + + b.Navigation("RevelationPenalties"); + + b.Navigation("Revelations"); + + b.Navigation("SetDepositsLimits"); + + b.Navigation("SmartRollupAddMessagesOps"); + + b.Navigation("SmartRollupCementOps"); + + b.Navigation("SmartRollupExecuteOps"); + + b.Navigation("SmartRollupOriginateOps"); + + b.Navigation("SmartRollupPublishOps"); + + b.Navigation("SmartRollupRecoverBondOps"); + + b.Navigation("SmartRollupRefuteOps"); + + b.Navigation("Transactions"); + + b.Navigation("TransferTicketOps"); + + b.Navigation("TxRollupCommitOps"); + + b.Navigation("TxRollupDispatchTicketsOps"); + + b.Navigation("TxRollupFinalizeCommitmentOps"); + + b.Navigation("TxRollupOriginationOps"); + + b.Navigation("TxRollupRejectionOps"); + + b.Navigation("TxRollupRemoveCommitmentOps"); + + b.Navigation("TxRollupReturnBondOps"); + + b.Navigation("TxRollupSubmitBatchOps"); + + b.Navigation("UpdateConsensusKeyOps"); + + b.Navigation("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Navigation("RevealedBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.Navigation("DelegatedAccounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tzkt.Data/Migrations/20230718171450_ticketUpdates.cs b/Tzkt.Data/Migrations/20230718171450_ticketUpdates.cs new file mode 100644 index 000000000..0dfe8c606 --- /dev/null +++ b/Tzkt.Data/Migrations/20230718171450_ticketUpdates.cs @@ -0,0 +1,150 @@ +using System.Numerics; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class ticketUpdates : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "TransactionOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "OriginationOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketBalancesCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketTransfersCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ActiveTicketsCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketBalancesCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketTransfersCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.CreateTable( + name: "TicketBalances", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TicketerId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "bigint", nullable: false), + AccountId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + Balance = table.Column(type: "numeric", nullable: false), + IndexedAt = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketBalances", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TicketTransfers", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Level = table.Column(type: "integer", nullable: false), + TicketerId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "bigint", nullable: false), + Amount = table.Column(type: "numeric", nullable: false), + FromId = table.Column(type: "integer", nullable: true), + ToId = table.Column(type: "integer", nullable: true), + OriginationId = table.Column(type: "bigint", nullable: true), + TransactionId = table.Column(type: "bigint", nullable: true), + MigrationId = table.Column(type: "bigint", nullable: true), + IndexedAt = table.Column(type: "integer", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketTransfers", x => x.Id); + }); + + migrationBuilder.UpdateData( + table: "AppState", + keyColumn: "Id", + keyValue: -1, + columns: new[] { "TicketBalancesCount", "TicketTransfersCount" }, + values: new object[] { 0, 0 }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TicketBalances"); + + migrationBuilder.DropTable( + name: "TicketTransfers"); + + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "TransactionOps"); + + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "OriginationOps"); + + migrationBuilder.DropColumn( + name: "TicketBalancesCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "TicketTransfersCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "ActiveTicketsCount", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketBalancesCount", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketTransfersCount", + table: "Accounts"); + } + } +} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 142913988..a75a20437 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -35,6 +35,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -127,6 +130,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -449,6 +458,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageCounter") .HasColumnType("integer"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + b.Property("TicketsCount") .HasColumnType("integer"); @@ -577,6 +592,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, TicketsCount = 0, Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TokenBalancesCount = 0, @@ -2022,6 +2039,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SubIds") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3566,7 +3586,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("BalancesCount") .HasColumnType("integer"); - b.Property("ContractId") + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentTypeHash") .HasColumnType("integer"); b.Property("FirstLevel") @@ -3590,6 +3613,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TicketId") .HasColumnType("numeric"); + b.Property("TicketerId") + .HasColumnType("integer"); + b.Property("TotalBurned") .HasColumnType("numeric"); @@ -3607,6 +3633,86 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Tickets"); }); + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("numeric"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("TicketTransfers"); + }); + modelBuilder.Entity("Tzkt.Data.Models.Token", b => { b.Property("Id") @@ -3924,6 +4030,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); diff --git a/Tzkt.Data/Models/Accounts/Account.cs b/Tzkt.Data/Models/Accounts/Account.cs index 3beb4de51..dac96e2b1 100644 --- a/Tzkt.Data/Models/Accounts/Account.cs +++ b/Tzkt.Data/Models/Accounts/Account.cs @@ -23,6 +23,11 @@ public class Account public int ActiveTokensCount { get; set; } public int TokenBalancesCount { get; set; } public int TokenTransfersCount { get; set; } + + + public int ActiveTicketsCount { get; set; } + public int TicketBalancesCount { get; set; } + public int TicketTransfersCount { get; set; } public int DelegationsCount { get; set; } public int OriginationsCount { get; set; } diff --git a/Tzkt.Data/Models/AppState.cs b/Tzkt.Data/Models/AppState.cs index 16b07b179..c78af5166 100644 --- a/Tzkt.Data/Models/AppState.cs +++ b/Tzkt.Data/Models/AppState.cs @@ -99,6 +99,8 @@ public class AppState public int TokenTransfersCount { get; set; } public int TicketsCount { get; set; } + public int TicketBalancesCount { get; set; } + public int TicketTransfersCount { get; set; } public int EventsCount { get; set; } #endregion diff --git a/Tzkt.Data/Models/Operations/Base/ContractOperation.cs b/Tzkt.Data/Models/Operations/Base/ContractOperation.cs index 5736507d0..359ca49d4 100644 --- a/Tzkt.Data/Models/Operations/Base/ContractOperation.cs +++ b/Tzkt.Data/Models/Operations/Base/ContractOperation.cs @@ -5,6 +5,7 @@ public class ContractOperation : InternalOperation public int? StorageId { get; set; } public int? BigMapUpdates { get; set; } public int? TokenTransfers { get; set; } + public int? TicketTransfers { get; set; } public int? SubIds { get; set; } } diff --git a/Tzkt.Data/Models/Scripts/TicketBalance.cs b/Tzkt.Data/Models/Scripts/TicketBalance.cs new file mode 100644 index 000000000..d6c588ba9 --- /dev/null +++ b/Tzkt.Data/Models/Scripts/TicketBalance.cs @@ -0,0 +1,82 @@ +using System.Numerics; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Tzkt.Data.Models +{ + public class TicketBalance + { + public long Id { get; set; } + public int TicketerId { get; set; } + public long TicketId { get; set; } + public int AccountId { get; set; } + public int FirstLevel { get; set; } + public int LastLevel { get; set; } + public int TransfersCount { get; set; } + public BigInteger Balance { get; set; } + public int? IndexedAt { get; set; } + } + + public static class TicketBalanceModel + { + public static void BuildTicketBalanceModel(this ModelBuilder modelBuilder) + { + #region keys + modelBuilder.Entity() + .HasKey(x => x.Id); + #endregion + + #region props + // TODO: switch to `numeric` type after migration to .NET 6 + var converter = new ValueConverter( + x => x.ToString(), + x => BigInteger.Parse(x)); + + modelBuilder.Entity() + .Property(x => x.Balance) + .HasConversion(converter); + #endregion + + #region indexes + modelBuilder.Entity() + .HasIndex(x => x.Id) + .IsUnique(); + + modelBuilder.Entity() + .HasIndex(x => x.TicketerId); + + modelBuilder.Entity() + .HasIndex(x => x.TicketerId) + .HasFilter($@"""{nameof(TicketBalance.Balance)}"" != '0'"); + + modelBuilder.Entity() + .HasIndex(x => x.TicketId); + + modelBuilder.Entity() + .HasIndex(x => x.TicketId) + .HasFilter($@"""{nameof(TicketBalance.Balance)}"" != '0'"); + + modelBuilder.Entity() + .HasIndex(x => x.AccountId); + + modelBuilder.Entity() + .HasIndex(x => x.AccountId) + .HasFilter($@"""{nameof(TicketBalance.Balance)}"" != '0'"); + + modelBuilder.Entity() + .HasIndex(x => new { x.AccountId, x.TicketerId }); + + modelBuilder.Entity() + .HasIndex(x => new { x.AccountId, x.TicketId }) + .IsUnique(); + + modelBuilder.Entity() + .HasIndex(x => x.LastLevel); + + modelBuilder.Entity() + .HasIndex(x => x.IndexedAt) + .HasFilter($@"""{nameof(TicketBalance.IndexedAt)}"" is not null"); + #endregion + } + } +} diff --git a/Tzkt.Data/Models/Scripts/TicketTransfer.cs b/Tzkt.Data/Models/Scripts/TicketTransfer.cs new file mode 100644 index 000000000..46a6047e2 --- /dev/null +++ b/Tzkt.Data/Models/Scripts/TicketTransfer.cs @@ -0,0 +1,84 @@ +using System.Numerics; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +namespace Tzkt.Data.Models +{ + public class TicketTransfer + { + public long Id { get; set; } + public int Level { get; set; } + public int TicketerId { get; set; } + public long TicketId { get; set; } + public BigInteger Amount { get; set; } + + public int? FromId { get; set; } + public int? ToId { get; set; } + + public long? OriginationId { get; set; } + public long? TransactionId { get; set; } + public long? MigrationId { get; set; } + public int? IndexedAt { get; set; } + } + + public static class TicketTransferModel + { + public static void BuildTicketTransferModel(this ModelBuilder modelBuilder) + { + #region keys + modelBuilder.Entity() + .HasKey(x => x.Id); + #endregion + + #region props + // TODO: switch to `numeric` type after migration to .NET 6 + var converter = new ValueConverter( + x => x.ToString(), + x => BigInteger.Parse(x)); + + modelBuilder.Entity() + .Property(x => x.Amount) + .HasConversion(converter); + #endregion + + #region indexes + modelBuilder.Entity() + .HasIndex(x => x.Id) + .IsUnique(); + + modelBuilder.Entity() + .HasIndex(x => x.TicketerId); + + modelBuilder.Entity() + .HasIndex(x => x.TicketId); + + modelBuilder.Entity() + .HasIndex(x => x.Level); + + modelBuilder.Entity() + .HasIndex(x => x.IndexedAt) + .HasFilter($@"""{nameof(TicketTransfer.IndexedAt)}"" is not null"); + + modelBuilder.Entity() + .HasIndex(x => x.OriginationId) + .HasFilter($@"""{nameof(TicketTransfer.OriginationId)}"" is not null"); + + modelBuilder.Entity() + .HasIndex(x => x.TransactionId) + .HasFilter($@"""{nameof(TicketTransfer.TransactionId)}"" is not null"); + + modelBuilder.Entity() + .HasIndex(x => x.MigrationId) + .HasFilter($@"""{nameof(TicketTransfer.MigrationId)}"" is not null"); + + modelBuilder.Entity() + .HasIndex(x => x.FromId) + .HasFilter($@"""{nameof(TicketTransfer.FromId)}"" is not null"); + + modelBuilder.Entity() + .HasIndex(x => x.ToId) + .HasFilter($@"""{nameof(TicketTransfer.ToId)}"" is not null"); + #endregion + } + } +} diff --git a/Tzkt.Data/TzktContext.cs b/Tzkt.Data/TzktContext.cs index 6f40a93a1..22d6d53b2 100644 --- a/Tzkt.Data/TzktContext.cs +++ b/Tzkt.Data/TzktContext.cs @@ -111,6 +111,8 @@ public class TzktContext : DbContext #region tickets public DbSet Tickets { get; set; } + public DbSet TicketBalances { get; set; } + public DbSet TicketTransfers { get; set; } #endregion #region rollups diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs index 0f0b960aa..8722932fa 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs @@ -9,7 +9,7 @@ public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } protected override IEnumerable ParseTicketUpdates(string property, JsonElement result) { - if (!result.TryGetProperty("ticket_receipt", out var ticketUpdates)) + if (!result.TryGetProperty(property, out var ticketUpdates)) return null; return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index afb1ac23d..ba40660bb 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -9,11 +9,14 @@ class TicketsCommit : ProtocolCommit { public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } - readonly List Updates = new(); + readonly List<(ContractOperation op,TicketUpdate update)> Updates = new(); - public virtual void Append(IEnumerable updates) + public virtual void Append(ContractOperation op, IEnumerable updates) { - Updates.AddRange(updates); + foreach (var update in updates) + { + Updates.Add((op, update)); + } } public virtual async Task Apply() @@ -21,9 +24,13 @@ public virtual async Task Apply() if (Updates.Count == 0) return; //TODO We need cache here; - foreach (var update in Updates) + foreach (var (op, update) in Updates) { - // var ticket = GetOrCreateTicket(); + var ticketer = await Cache.Accounts.GetAsync(update.TicketToken.Ticketer); + var contract = ticketer as Contract; + var contentHash = Script.GetHash(update.TicketToken.Content.ToBytes()); + var contentTypeHash = Script.GetHash(update.TicketToken.ContentType.ToBytes()); + var ticket = GetOrCreateTicket(op, contract, contentHash, contentTypeHash); } @@ -59,7 +66,7 @@ Account GetOrCreateAccount(ContractOperation op, string address) return account; } - Ticket GetOrCreateTicket(TicketUpdate update, ContractOperation op, Contract contract, int contentHash, int contentTypeHash) + Ticket GetOrCreateTicket(ContractOperation op, Contract contract, int contentHash, int contentTypeHash) { if (Cache.Tickets.TryGet(contract.Id, contentHash, contentTypeHash, out var ticket)) return ticket; @@ -76,8 +83,8 @@ Ticket GetOrCreateTicket(TicketUpdate update, ContractOperation op, Contract con TotalBurned = BigInteger.Zero, TotalMinted = BigInteger.Zero, TotalSupply = BigInteger.Zero, - ContentHash = Script.GetHash(update.TicketToken.Content.ToBytes()), - ContentTypeHash = Script.GetHash(update.TicketToken.ContentType.ToBytes()), + ContentHash = contentHash, + ContentTypeHash = contentTypeHash, IndexedAt = op.Level <= state.Level ? state.Level + 1 : null }; Db.Tickets.Add(ticket); @@ -90,6 +97,152 @@ Ticket GetOrCreateTicket(TicketUpdate update, ContractOperation op, Contract con op.Block.Events |= BlockEvents.Tickets; return ticket; } + + TicketBalance GetOrCreateTicketBalance(ContractOperation op, Ticket ticket, Account account) + { + if (!Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) + { + var state = Cache.AppState.Get(); + state.TicketBalancesCount++; + + ticketBalance = new TicketBalance + { + Id = Cache.AppState.NextSubId(op), + AccountId = account.Id, + TicketId = ticket.Id, + TicketerId = ticket.TicketerId, + FirstLevel = op.Level, + LastLevel = op.Level, + Balance = BigInteger.Zero, + IndexedAt = op.Level <= state.Level ? state.Level + 1 : null + }; + Db.TicketBalances.Add(ticketBalance); + Cache.TicketBalances.Add(ticketBalance); + + Db.TryAttach(ticket); + ticket.BalancesCount++; + + Db.TryAttach(account); + account.TicketBalancesCount++; + if (account.FirstLevel > op.Level) + { + account.FirstLevel = op.Level; + op.Block.Events |= BlockEvents.NewAccounts; + } + } + return ticketBalance; + } + + void TransferTickets(ContractOperation op, Contract contract, Ticket ticket, + Account from, TicketBalance fromBalance, + Account to, TicketBalance toBalance, + BigInteger amount) + { + op.TicketTransfers = (op.TicketTransfers ?? 0) + 1; + + Db.TryAttach(from); + from.TicketTransfersCount++; + + Db.TryAttach(to); + if (to != from) to.TicketTransfersCount++; + + Db.TryAttach(fromBalance); + fromBalance.Balance -= amount; + fromBalance.TransfersCount++; + fromBalance.LastLevel = op.Level; + + Db.TryAttach(toBalance); + toBalance.Balance += amount; + if (toBalance != fromBalance) toBalance.TransfersCount++; + toBalance.LastLevel = op.Level; + + ticket.TransfersCount++; + if (amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) + { + if (fromBalance.Balance == BigInteger.Zero) + { + from.ActiveTicketsCount--; + ticket.HoldersCount--; + } + if (toBalance.Balance == amount) + { + to.ActiveTicketsCount++; + ticket.HoldersCount++; + } + if (contract.Tags.HasFlag(ContractTags.Nft)) + ticket.OwnerId = to.Id; + } + + var state = Cache.AppState.Get(); + state.TicketTransfersCount++; + + Db.TicketTransfers.Add(new TicketTransfer + { + Id = Cache.AppState.NextSubId(op), + Amount = amount, + FromId = from.Id, + ToId = to.Id, + Level = op.Level, + TicketId = ticket.Id, + TicketerId = ticket.TicketerId, + TransactionId = (op as TransactionOperation)?.Id, + OriginationId = (op as OriginationOperation)?.Id, + IndexedAt = op.Level <= state.Level ? state.Level + 1 : null + }); + } + + void MintOrBurnTickets(ContractOperation op, Contract contract, Ticket ticket, + Account account, TicketBalance balance, + BigInteger diff) + { + op.TicketTransfers = (op.TicketTransfers ?? 0) + 1; + + Db.TryAttach(account); + account.TicketTransfersCount++; + + Db.TryAttach(balance); + balance.Balance += diff; + balance.TransfersCount++; + balance.LastLevel = op.Level; + + ticket.TransfersCount++; + if (balance.Balance == BigInteger.Zero) + { + account.ActiveTicketsCount--; + ticket.HoldersCount--; + + if (contract.Tags.HasFlag(ContractTags.Nft)) + ticket.OwnerId = null; + } + if (balance.Balance == diff) + { + account.ActiveTicketsCount++; + ticket.HoldersCount++; + + if (contract.Tags.HasFlag(ContractTags.Nft)) + ticket.OwnerId = account.Id; + } + if (diff > 0) ticket.TotalMinted += diff; + else ticket.TotalBurned += -diff; + ticket.TotalSupply += diff; + + var state = Cache.AppState.Get(); + state.TicketTransfersCount++; + + Db.TicketTransfers.Add(new TicketTransfer + { + Id = Cache.AppState.NextSubId(op), + Amount = diff > BigInteger.Zero ? diff : -diff, + FromId = diff < BigInteger.Zero ? account.Id : null, + ToId = diff > BigInteger.Zero ? account.Id : null, + Level = op.Level, + TicketId = ticket.Id, + TicketerId = ticket.TicketerId, + TransactionId = (op as TransactionOperation)?.Id, + OriginationId = (op as OriginationOperation)?.Id, + IndexedAt = op.Level <= state.Level ? state.Level + 1 : null + }); + } public virtual async Task Revert(Block block) { diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index ab85c8640..30779d6b2 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -171,7 +171,7 @@ public override async Task Commit(JsonElement block) if (parent.BigMapDiffs != null) bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); if (parent.TicketUpdates != null) - ticketsCommit.Append(parent.TicketUpdates); + ticketsCommit.Append(parent.Transaction, parent.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) { @@ -194,7 +194,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(internalTx.TicketUpdates); + ticketsCommit.Append(internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -233,7 +233,8 @@ public override async Task Commit(JsonElement block) var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); if (parent1.TicketUpdates != null) - ticketsCommit.Append(parent1.TicketUpdates); + //TODO Figure out behaviour for the transfer_ticket + ticketsCommit.Append(null, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) @@ -246,7 +247,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(internalTx.TicketUpdates); + ticketsCommit.Append(internalTx.Transaction, internalTx.TicketUpdates); break; default: throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); diff --git a/Tzkt.Sync/Services/Cache/CacheService.cs b/Tzkt.Sync/Services/Cache/CacheService.cs index 319dc8586..dab05bca0 100644 --- a/Tzkt.Sync/Services/Cache/CacheService.cs +++ b/Tzkt.Sync/Services/Cache/CacheService.cs @@ -20,8 +20,9 @@ public class CacheService public BigMapsCache BigMaps { get; private set; } public BigMapKeysCache BigMapKeys { get; private set; } public TokensCache Tokens { get; private set; } - public TicketsCache Tickets { get; private set; } public TokenBalancesCache TokenBalances { get; private set; } + public TicketsCache Tickets { get; private set; } + public TicketBalancesCache TicketBalances { get; private set; } public SmartRollupCommitmentCache SmartRollupCommitments { get; private set; } public SmartRollupStakesCache SmartRollupStakes { get; private set; } public RefutationGameCache RefutationGames { get; private set; } @@ -44,6 +45,8 @@ public CacheService(TzktContext db) BigMapKeys = new(db); Tokens = new(db); TokenBalances = new(db); + Tickets = new(db); + TicketBalances = new(db); SmartRollupCommitments = new(db); SmartRollupStakes = new(db); RefutationGames = new(db); diff --git a/Tzkt.Sync/Services/Cache/TicketBalancesCache.cs b/Tzkt.Sync/Services/Cache/TicketBalancesCache.cs new file mode 100644 index 000000000..0a70b76ee --- /dev/null +++ b/Tzkt.Sync/Services/Cache/TicketBalancesCache.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +using Tzkt.Data; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Services.Cache +{ + public class TicketBalancesCache + { + public const int MaxItems = 4 * 4096; //TODO: set limits in app settings + + static readonly Dictionary<(int, long), TicketBalance> Cached = new(MaxItems); + + readonly TzktContext Db; + + public TicketBalancesCache(TzktContext db) + { + Db = db; + } + + public void Reset() + { + Cached.Clear(); + } + + public void Trim() + { + if (Cached.Count > MaxItems * 0.9) + { + var toRemove = Cached.Values + .OrderBy(x => x.LastLevel) + .Take(MaxItems / 2) + .ToList(); + + foreach (var item in toRemove) + Remove(item); + } + } + + public void Add(TicketBalance ticketBalance) + { + Cached[(ticketBalance.AccountId, ticketBalance.TicketId)] = ticketBalance; + } + + public void Remove(TicketBalance ticketBalance) + { + Cached.Remove((ticketBalance.AccountId, ticketBalance.TicketId)); + } + + public TicketBalance GetOrAdd(TicketBalance ticketBalance) + { + if (Cached.TryGetValue((ticketBalance.AccountId, ticketBalance.TicketId), out var res)) + return res; + Add(ticketBalance); + return ticketBalance; + } + + public TicketBalance Get(int accountId, long ticketId) + { + if (!Cached.TryGetValue((accountId, ticketId), out var ticketBalance)) + throw new Exception($"TicketBalance ({accountId}, {ticketId}) doesn't exist"); + return ticketBalance; + } + + public bool TryGet(int accountId, long ticketId, out TicketBalance ticketBalance) + { + return Cached.TryGetValue((accountId, ticketId), out ticketBalance); + } + + public async Task Preload(IEnumerable<(int, long)> ids) + { + var missed = ids.Where(x => !Cached.ContainsKey(x)).ToHashSet(); + if (missed.Count > 0) + { + for (int i = 0, n = 2048; i < missed.Count; i += n) + { + var corteges = string.Join(',', missed.Skip(i).Take(n).Select(x => $"({x.Item1}, {x.Item2})")); + var items = await Db.TicketBalances + .FromSqlRaw($@" + SELECT * FROM ""{nameof(TzktContext.TicketBalances)}"" + WHERE (""{nameof(TicketBalance.AccountId)}"", ""{nameof(TicketBalance.TicketId)}"") IN ({corteges})") + .ToListAsync(); + + foreach (var item in items) + Add(item); + } + } + } + } +} From 2c66f866edf3a32bc47897933b287b9b890fc8d6 Mon Sep 17 00:00:00 2001 From: dmir Date: Fri, 28 Jul 2023 18:29:42 +0300 Subject: [PATCH 05/51] WIP TicketBalance Diagnostics --- .../Operations/Fictive/MigrationOperation.cs | 2 ++ .../Operations/TransferTicketOperation.cs | 1 + Tzkt.Sync/Protocols/Abstract/IRpc.cs | 1 + .../Protocols/Handlers/Genesis/Rpc/Rpc.cs | 3 ++ .../Proto1/Diagnostics/Diagnostics.cs | 13 ++++++++- .../Protocols/Handlers/Proto1/Rpc/Rpc.cs | 7 +++-- .../Handlers/Proto17/Commits/TicketsCommit.cs | 28 ++++++++++--------- .../Proto17/Diagnostics/Diagnostics.cs | 10 ++++++- .../Protocols/Handlers/Proto17/Rpc/Rpc.cs | 6 +++- Tzkt.Sync/Services/TezosNode/TezosNode.cs | 6 ++++ Tzkt.Sync/Utils/TzktClient.cs | 12 ++++++++ 11 files changed, 70 insertions(+), 19 deletions(-) diff --git a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs index 04b10dbe4..626ad0ee6 100644 --- a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs +++ b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs @@ -18,6 +18,8 @@ public class MigrationOperation public int? StorageId { get; set; } public int? BigMapUpdates { get; set; } public int? TokenTransfers { get; set; } + + //TODO Add Tickets to migrations public int? SubIds { get; set; } diff --git a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs index 7b3f20f01..d6c0b9e3d 100644 --- a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs +++ b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs @@ -17,6 +17,7 @@ public class TransferTicketOperation : ManagerOperation public string JsonContent { get; set; } public string Entrypoint { get; set; } + //TODO Delete ForeignKey #region relations [ForeignKey(nameof(TicketerId))] public Account Ticketer { get; set; } diff --git a/Tzkt.Sync/Protocols/Abstract/IRpc.cs b/Tzkt.Sync/Protocols/Abstract/IRpc.cs index 0baaecadc..d9652654c 100644 --- a/Tzkt.Sync/Protocols/Abstract/IRpc.cs +++ b/Tzkt.Sync/Protocols/Abstract/IRpc.cs @@ -22,6 +22,7 @@ public interface IRpc Task GetActiveDelegatesAsync(int level); Task GetDelegateParticipationAsync(int level, string address); Task GetCycleAsync(int level, int cycle); + Task GetTicketBalance(int level, string address, TicketToken ticket); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs index d532cc094..e22fdda75 100644 --- a/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs @@ -52,6 +52,9 @@ public Task GetCycleAsync(int level, int cycle) public Task GetDelegateParticipationAsync(int level, string address) => throw new InvalidOperationException(); + + public Task GetTicketBalance(int level, string address, TicketToken ticket) + => throw new InvalidOperationException(); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs index c00d42d64..030143ae7 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs @@ -3,7 +3,7 @@ using System.Text.Json; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; - +using Netezos.Encoding; using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -72,6 +72,15 @@ protected virtual async Task RunDiagnostics(int level, int ops = -1) var accounts = entries.Where(x => x.Entity is Account && (x.State == EntityState.Modified || x.State == EntityState.Added)) .Select(x => x.Entity as Account); + + var ticketBalances = entries.Where(x => + x.Entity is TicketBalance && (x.State == EntityState.Modified || x.State == EntityState.Added)) + .Select(x => x.Entity as TicketBalance); + + foreach (var ticketBalance in ticketBalances) + { + await TestTicketBalance(level, ticketBalance); + } await TestGlobalCounter(level, state); @@ -173,6 +182,8 @@ protected virtual async Task TestAccount(int level, Account account) TestAccountDelegate(remote, account); TestAccountCounter(remote, account); } + + protected virtual Task TestTicketBalance(int level, TicketBalance ticketBalance) => Task.CompletedTask; protected virtual void TestAccountDelegate(JsonElement remote, Account local) { diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs index dbd4ea704..48e41bbca 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs @@ -1,6 +1,4 @@ -using System; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Tzkt.Sync.Services; namespace Tzkt.Sync.Protocols.Proto1 @@ -52,6 +50,9 @@ public virtual Task GetCycleAsync(int level, int cycle) public virtual Task GetDelegateParticipationAsync(int level, string address) => throw new InvalidOperationException(); + + public virtual Task GetTicketBalance(int level, string address, TicketToken ticket) + => throw new InvalidOperationException(); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index ba40660bb..98584ab35 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -24,16 +24,24 @@ public virtual async Task Apply() if (Updates.Count == 0) return; //TODO We need cache here; - foreach (var (op, update) in Updates) + foreach (var (op, ticketUpdates) in Updates) { - var ticketer = await Cache.Accounts.GetAsync(update.TicketToken.Ticketer); + var ticketer = await Cache.Accounts.GetAsync(ticketUpdates.TicketToken.Ticketer); var contract = ticketer as Contract; - var contentHash = Script.GetHash(update.TicketToken.Content.ToBytes()); - var contentTypeHash = Script.GetHash(update.TicketToken.ContentType.ToBytes()); + var contentHash = Script.GetHash(ticketUpdates.TicketToken.Content.ToBytes()); + var contentTypeHash = Script.GetHash(ticketUpdates.TicketToken.ContentType.ToBytes()); var ticket = GetOrCreateTicket(op, contract, contentHash, contentTypeHash); - } - + //TODO Match updates, if successful, transfers, if not, burns and mints + foreach (var ticketUpdate in ticketUpdates.Updates) + { + var amount = BigInteger.Parse(ticketUpdate.Amount); + var account = GetOrCreateAccount(op, ticketUpdate.Account); + var balance = GetOrCreateTicketBalance(op, ticket, account); + MintOrBurnTickets(op, ticket, account, balance, amount); + } + + } } Account GetOrCreateAccount(ContractOperation op, string address) @@ -191,7 +199,7 @@ void TransferTickets(ContractOperation op, Contract contract, Ticket ticket, }); } - void MintOrBurnTickets(ContractOperation op, Contract contract, Ticket ticket, + void MintOrBurnTickets(ContractOperation op, Ticket ticket, Account account, TicketBalance balance, BigInteger diff) { @@ -210,17 +218,11 @@ void MintOrBurnTickets(ContractOperation op, Contract contract, Ticket ticket, { account.ActiveTicketsCount--; ticket.HoldersCount--; - - if (contract.Tags.HasFlag(ContractTags.Nft)) - ticket.OwnerId = null; } if (balance.Balance == diff) { account.ActiveTicketsCount++; ticket.HoldersCount++; - - if (contract.Tags.HasFlag(ContractTags.Nft)) - ticket.OwnerId = account.Id; } if (diff > 0) ticket.TotalMinted += diff; else ticket.TotalBurned += -diff; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs index e225a41de..8cd5f876b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs @@ -1,7 +1,15 @@ -namespace Tzkt.Sync.Protocols.Proto17 +using Netezos.Encoding; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto17 { class Diagnostics : Proto14.Diagnostics { public Diagnostics(ProtocolHandler handler) : base(handler) { } + + protected override async Task TestTicketBalance(int level, TicketBalance balance) + { + var a = await Rpc.GetTicketBalance(level, balance., ticket); + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs index 634cfed84..ffba10f66 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs @@ -1,9 +1,13 @@ -using Tzkt.Sync.Services; +using System.Text.Json; +using Tzkt.Sync.Services; namespace Tzkt.Sync.Protocols.Proto17 { class Rpc : Proto12.Rpc { public Rpc(TezosNode node) : base(node) { } + + public override Task GetTicketBalance(int level, string address, TicketToken ticket) + => Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); } } diff --git a/Tzkt.Sync/Services/TezosNode/TezosNode.cs b/Tzkt.Sync/Services/TezosNode/TezosNode.cs index b0c10ec71..cd9056037 100644 --- a/Tzkt.Sync/Services/TezosNode/TezosNode.cs +++ b/Tzkt.Sync/Services/TezosNode/TezosNode.cs @@ -7,6 +7,7 @@ using System.Text.Json; using Tzkt.Data; using Tzkt.Data.Models; +using Tzkt.Sync.Protocols; namespace Tzkt.Sync.Services { @@ -39,6 +40,11 @@ public async Task GetAsync(string url) return doc.RootElement.Clone(); } + public async Task PostAsync(string url, object data) + { + return await Rpc.PostAsync(url, data); + } + public async Task
GetHeaderAsync() { if (DateTime.UtcNow >= NextBlock) diff --git a/Tzkt.Sync/Utils/TzktClient.cs b/Tzkt.Sync/Utils/TzktClient.cs index 007572e4f..1303373b1 100644 --- a/Tzkt.Sync/Utils/TzktClient.cs +++ b/Tzkt.Sync/Utils/TzktClient.cs @@ -63,6 +63,18 @@ public async Task GetObjectAsync(string path) using var stream = await HttpClient.GetStreamAsync(path); return await JsonSerializer.DeserializeAsync(stream, SerializerOptions.Default); } + + public async Task PostAsync(string path, object data) + { + var content = JsonSerializer.Serialize(data); + + var response = await HttpClient.PostAsJsonAsync(path, content); + + using var stream = await response.Content.ReadAsStreamAsync(); + return await JsonSerializer.DeserializeAsync(stream); + } + + public void Dispose() => _HttpClient?.Dispose(); } From 7201bddd0f8dd056804f81e78934792e5fe4cf86 Mon Sep 17 00:00:00 2001 From: dmir Date: Sun, 30 Jul 2023 13:59:54 +0300 Subject: [PATCH 06/51] WIP Diagnostics --- Tzkt.Data/Models/Scripts/TIcket.cs | 13 ++----------- Tzkt.Data/Models/Scripts/TicketBalance.cs | 15 ++++++++++++++- .../Handlers/Proto17/Diagnostics/Diagnostics.cs | 1 + 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs index 9d0dce7f9..e6177aac3 100644 --- a/Tzkt.Data/Models/Scripts/TIcket.cs +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -9,7 +9,6 @@ public class Ticket { public long Id { get; set; } public int TicketerId { get; set; } - public BigInteger TicketId { get; set; } public int FirstMinterId { get; set; } public int FirstLevel { get; set; } @@ -49,11 +48,7 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) var converter = new ValueConverter( x => x.ToString(), x => BigInteger.Parse(x)); - - modelBuilder.Entity() - .Property(x => x.TicketId) - .HasConversion(converter); - + modelBuilder.Entity() .Property(x => x.TotalMinted) .HasConversion(converter); @@ -74,11 +69,7 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.TicketerId); - - modelBuilder.Entity() - .HasIndex(x => new {ContractId = x.TicketerId, x.TicketId }) - .IsUnique(); - + modelBuilder.Entity() .HasIndex(x => x.FirstMinterId); diff --git a/Tzkt.Data/Models/Scripts/TicketBalance.cs b/Tzkt.Data/Models/Scripts/TicketBalance.cs index d6c588ba9..eb8bb26f8 100644 --- a/Tzkt.Data/Models/Scripts/TicketBalance.cs +++ b/Tzkt.Data/Models/Scripts/TicketBalance.cs @@ -1,4 +1,5 @@ -using System.Numerics; +using System.ComponentModel.DataAnnotations.Schema; +using System.Numerics; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -15,6 +16,18 @@ public class TicketBalance public int TransfersCount { get; set; } public BigInteger Balance { get; set; } public int? IndexedAt { get; set; } + + //TODO Delete ForeignKey + #region relations + [ForeignKey(nameof(TicketerId))] + public Account Ticketer { get; set; } + + [ForeignKey(nameof(AccountId))] + public Account Account { get; set; } + + [ForeignKey(nameof(TicketId))] + public Ticket Ticket { get; set; } + #endregion } public static class TicketBalanceModel diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs index 8cd5f876b..fb27568cb 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs @@ -9,6 +9,7 @@ public Diagnostics(ProtocolHandler handler) : base(handler) { } protected override async Task TestTicketBalance(int level, TicketBalance balance) { + var a = balance. var a = await Rpc.GetTicketBalance(level, balance., ticket); } } From 8f22fdd9b26c5bb83412e98d0b3543c1a048c054 Mon Sep 17 00:00:00 2001 From: dmir Date: Sun, 30 Jul 2023 18:28:30 +0300 Subject: [PATCH 07/51] Equal balance till level 45 --- .../20230730143042_test.Designer.cs | 6263 +++++++++++++++++ Tzkt.Data/Migrations/20230730143042_test.cs | 114 + .../Migrations/TzktContextModelSnapshot.cs | 42 +- Tzkt.Data/Models/Scripts/TIcket.cs | 3 + Tzkt.Sync/Protocols/Abstract/IRpc.cs | 2 +- .../Protocols/Handlers/Genesis/Rpc/Rpc.cs | 2 +- .../Protocols/Handlers/Proto1/Rpc/Rpc.cs | 2 +- .../Handlers/Proto17/Commits/TicketsCommit.cs | 13 +- .../Proto17/Diagnostics/Diagnostics.cs | 23 +- .../Protocols/Handlers/Proto17/Rpc/Rpc.cs | 4 +- Tzkt.Sync/Services/Cache/TicketsCache.cs | 3 +- Tzkt.Sync/Services/TezosNode/TezosNode.cs | 4 +- Tzkt.Sync/Utils/JsonContent.cs | 12 + Tzkt.Sync/Utils/TzktClient.cs | 9 +- 14 files changed, 6473 insertions(+), 23 deletions(-) create mode 100644 Tzkt.Data/Migrations/20230730143042_test.Designer.cs create mode 100644 Tzkt.Data/Migrations/20230730143042_test.cs create mode 100644 Tzkt.Sync/Utils/JsonContent.cs diff --git a/Tzkt.Data/Migrations/20230730143042_test.Designer.cs b/Tzkt.Data/Migrations/20230730143042_test.Designer.cs new file mode 100644 index 000000000..0f39cbff2 --- /dev/null +++ b/Tzkt.Data/Migrations/20230730143042_test.Designer.cs @@ -0,0 +1,6263 @@ +// +using System; +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Tzkt.Data; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + [DbContext(typeof(TzktContext))] + [Migration("20230730143042_test")] + partial class test + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveRefutationGamesCount") + .HasColumnType("integer"); + + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + + b.Property("ActiveTokensCount") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character varying(37)"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("ContractsCount") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegationLevel") + .HasColumnType("integer"); + + b.Property("DelegationsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageCount") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("MigrationsCount") + .HasColumnType("integer"); + + b.Property("OriginationsCount") + .HasColumnType("integer"); + + b.Property("RefutationGamesCount") + .HasColumnType("integer"); + + b.Property("RevealsCount") + .HasColumnType("integer"); + + b.Property("RollupBonds") + .HasColumnType("bigint"); + + b.Property("RollupsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesCount") + .HasColumnType("integer"); + + b.Property("SmartRollupBonds") + .HasColumnType("bigint"); + + b.Property("SmartRollupCementCount") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupsCount") + .HasColumnType("integer"); + + b.Property("Staked") + .HasColumnType("boolean"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TransactionsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchCount") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UpdateConsensusKeyCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("DelegateId"); + + b.HasIndex("Extras"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Staked"); + + b.HasIndex("Type"); + + b.ToTable("Accounts"); + + b.HasDiscriminator("Type").HasValue((byte)3); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("ActivationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AppState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountCounter") + .HasColumnType("integer"); + + b.Property("AccountsCount") + .HasColumnType("integer"); + + b.Property("ActivationOpsCount") + .HasColumnType("integer"); + + b.Property("BallotOpsCount") + .HasColumnType("integer"); + + b.Property("BigMapCounter") + .HasColumnType("integer"); + + b.Property("BigMapKeyCounter") + .HasColumnType("integer"); + + b.Property("BigMapUpdateCounter") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Chain") + .HasColumnType("text"); + + b.Property("ChainId") + .HasColumnType("text"); + + b.Property("CommitmentsCount") + .HasColumnType("integer"); + + b.Property("ConstantsCount") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("CyclesCount") + .HasColumnType("integer"); + + b.Property("DelegationOpsCount") + .HasColumnType("integer"); + + b.Property("DomainsLevel") + .HasColumnType("integer"); + + b.Property("DomainsNameRegistry") + .HasColumnType("text"); + + b.Property("DoubleBakingOpsCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsementOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardOpsCount") + .HasColumnType("integer"); + + b.Property("EventCounter") + .HasColumnType("integer"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxMessageCounter") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageOpsCount") + .HasColumnType("integer"); + + b.Property("KnownHead") + .HasColumnType("integer"); + + b.Property("LastSync") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerCounter") + .HasColumnType("integer"); + + b.Property("MigrationOpsCount") + .HasColumnType("integer"); + + b.Property("NextProtocol") + .HasColumnType("text"); + + b.Property("NonceRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("OperationCounter") + .HasColumnType("bigint"); + + b.Property("OriginationOpsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ProtocolsCount") + .HasColumnType("integer"); + + b.Property("QuoteBtc") + .HasColumnType("double precision"); + + b.Property("QuoteCny") + .HasColumnType("double precision"); + + b.Property("QuoteEth") + .HasColumnType("double precision"); + + b.Property("QuoteEur") + .HasColumnType("double precision"); + + b.Property("QuoteGbp") + .HasColumnType("double precision"); + + b.Property("QuoteJpy") + .HasColumnType("double precision"); + + b.Property("QuoteKrw") + .HasColumnType("double precision"); + + b.Property("QuoteLevel") + .HasColumnType("integer"); + + b.Property("QuoteUsd") + .HasColumnType("double precision"); + + b.Property("RefutationGameCounter") + .HasColumnType("integer"); + + b.Property("RegisterConstantOpsCount") + .HasColumnType("integer"); + + b.Property("RevealOpsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltyOpsCount") + .HasColumnType("integer"); + + b.Property("ScriptCounter") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCementOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentCounter") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteOpsCount") + .HasColumnType("integer"); + + b.Property("StorageCounter") + .HasColumnType("integer"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TransactionOpsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchOpsCount") + .HasColumnType("integer"); + + b.Property("UpdateConsensusKeyOpsCount") + .HasColumnType("integer"); + + b.Property("VdfRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("VotingEpoch") + .HasColumnType("integer"); + + b.Property("VotingPeriod") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AppState"); + + b.HasData( + new + { + Id = -1, + AccountCounter = 0, + AccountsCount = 0, + ActivationOpsCount = 0, + BallotOpsCount = 0, + BigMapCounter = 0, + BigMapKeyCounter = 0, + BigMapUpdateCounter = 0, + BlocksCount = 0, + CommitmentsCount = 0, + ConstantsCount = 0, + Cycle = -1, + CyclesCount = 0, + DelegationOpsCount = 0, + DomainsLevel = 0, + DoubleBakingOpsCount = 0, + DoubleEndorsingOpsCount = 0, + DoublePreendorsingOpsCount = 0, + DrainDelegateOpsCount = 0, + EndorsementOpsCount = 0, + EndorsingRewardOpsCount = 0, + EventCounter = 0, + EventsCount = 0, + Hash = "", + InboxMessageCounter = 0, + IncreasePaidStorageOpsCount = 0, + KnownHead = 0, + LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Level = -1, + ManagerCounter = 0, + MigrationOpsCount = 0, + NextProtocol = "", + NonceRevelationOpsCount = 0, + OperationCounter = 0L, + OriginationOpsCount = 0, + PreendorsementOpsCount = 0, + ProposalOpsCount = 0, + ProposalsCount = 0, + Protocol = "", + ProtocolsCount = 0, + QuoteBtc = 0.0, + QuoteCny = 0.0, + QuoteEth = 0.0, + QuoteEur = 0.0, + QuoteGbp = 0.0, + QuoteJpy = 0.0, + QuoteKrw = 0.0, + QuoteLevel = -1, + QuoteUsd = 0.0, + RefutationGameCounter = 0, + RegisterConstantOpsCount = 0, + RevealOpsCount = 0, + RevelationPenaltyOpsCount = 0, + ScriptCounter = 0, + SetDepositsLimitOpsCount = 0, + SmartRollupAddMessagesOpsCount = 0, + SmartRollupCementOpsCount = 0, + SmartRollupCommitmentCounter = 0, + SmartRollupExecuteOpsCount = 0, + SmartRollupOriginateOpsCount = 0, + SmartRollupPublishOpsCount = 0, + SmartRollupRecoverBondOpsCount = 0, + SmartRollupRefuteOpsCount = 0, + StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, + Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + TokenBalancesCount = 0, + TokenTransfersCount = 0, + TokensCount = 0, + TransactionOpsCount = 0, + TransferTicketOpsCount = 0, + TxRollupCommitOpsCount = 0, + TxRollupDispatchTicketsOpsCount = 0, + TxRollupFinalizeCommitmentOpsCount = 0, + TxRollupOriginationOpsCount = 0, + TxRollupRejectionOpsCount = 0, + TxRollupRemoveCommitmentOpsCount = 0, + TxRollupReturnBondOpsCount = 0, + TxRollupSubmitBatchOpsCount = 0, + UpdateConsensusKeyOpsCount = 0, + VdfRevelationOpsCount = 0, + VotingEpoch = -1, + VotingPeriod = -1 + }); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStake") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("BlockFees") + .HasColumnType("bigint"); + + b.Property("BlockRewards") + .HasColumnType("bigint"); + + b.Property("Blocks") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleBakingRewards") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingRewards") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingRewards") + .HasColumnType("bigint"); + + b.Property("EndorsementRewards") + .HasColumnType("bigint"); + + b.Property("Endorsements") + .HasColumnType("integer"); + + b.Property("ExpectedBlocks") + .HasColumnType("double precision"); + + b.Property("ExpectedEndorsements") + .HasColumnType("double precision"); + + b.Property("FutureBlockRewards") + .HasColumnType("bigint"); + + b.Property("FutureBlocks") + .HasColumnType("integer"); + + b.Property("FutureEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("FutureEndorsements") + .HasColumnType("integer"); + + b.Property("MissedBlockFees") + .HasColumnType("bigint"); + + b.Property("MissedBlockRewards") + .HasColumnType("bigint"); + + b.Property("MissedBlocks") + .HasColumnType("integer"); + + b.Property("MissedEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("MissedEndorsements") + .HasColumnType("integer"); + + b.Property("RevelationLosses") + .HasColumnType("bigint"); + + b.Property("RevelationRewards") + .HasColumnType("bigint"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Cycle", "BakerId") + .IsUnique(); + + b.ToTable("BakerCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Round") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakingRights"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Vote") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("BallotOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("ActiveKeys") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("KeyType") + .HasColumnType("bytea"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Ptr") + .HasColumnType("integer"); + + b.Property("StoragePath") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TotalKeys") + .HasColumnType("integer"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.Property("ValueType") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasAlternateKey("Ptr"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Ptr") + .IsUnique(); + + b.ToTable("BigMaps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("JsonKey") + .HasColumnType("jsonb"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("KeyHash") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawKey") + .HasColumnType("bytea"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonKey"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); + + b.HasIndex("JsonValue"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("BigMapPtr", "Active") + .HasFilter("\"Active\" = true"); + + b.HasIndex("BigMapPtr", "KeyHash"); + + b.ToTable("BigMapKeys"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("BigMapKeyId") + .HasColumnType("integer"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BigMapKeyId") + .HasFilter("\"BigMapKeyId\" is not null"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("BigMapUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlockRound") + .HasColumnType("integer"); + + b.Property("Bonus") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Events") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Fees") + .HasColumnType("bigint"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggle") + .HasColumnType("boolean"); + + b.Property("LBToggleEma") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Operations") + .HasColumnType("bigint"); + + b.Property("PayloadRound") + .HasColumnType("integer"); + + b.Property("ProducerId") + .HasColumnType("integer"); + + b.Property("ProposerId") + .HasColumnType("integer"); + + b.Property("ProtoCode") + .HasColumnType("integer"); + + b.Property("ResetBakerDeactivation") + .HasColumnType("integer"); + + b.Property("ResetProposerDeactivation") + .HasColumnType("integer"); + + b.Property("RevelationId") + .HasColumnType("bigint"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Validations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("Level") + .IsUnique(); + + b.HasIndex("ProducerId"); + + b.HasIndex("ProposerId"); + + b.HasIndex("ProtoCode"); + + b.HasIndex("RevelationId") + .IsUnique(); + + b.HasIndex("SoftwareId"); + + b.ToTable("Blocks"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character(37)") + .IsFixedLength(); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Commitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("JsonPayload") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RawPayload") + .HasColumnType("bytea"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonPayload"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("Tag"); + + b.HasIndex("TransactionId"); + + b.HasIndex("ContractCodeHash", "Tag"); + + b.HasIndex("ContractId", "Tag"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Seed") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("SelectedBakers") + .HasColumnType("integer"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("SnapshotIndex") + .HasColumnType("integer"); + + b.Property("SnapshotLevel") + .HasColumnType("integer"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalDelegated") + .HasColumnType("bigint"); + + b.Property("TotalDelegators") + .HasColumnType("integer"); + + b.Property("TotalStaking") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("Cycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevDelegateId") + .HasColumnType("integer"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("PrevDelegateId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.ToTable("DelegationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatorId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("DelegatorId"); + + b.HasIndex("Cycle", "BakerId"); + + b.HasIndex("Cycle", "DelegatorId") + .IsUnique(); + + b.ToTable("DelegatorCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("jsonb"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("Reverse") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("Address"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Level"); + + b.HasIndex("Name"); + + b.HasIndex("Owner"); + + b.ToTable("Domains"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleBakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleEndorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoublePreendorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Fee") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("TargetId"); + + b.ToTable("DrainDelegateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("EndorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Expected") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Received") + .HasColumnType("bigint"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("EndorsingRewardOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Change") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.ToTable("FreezerUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OperationId") + .HasColumnType("bigint"); + + b.Property("Payload") + .HasColumnType("bytea"); + + b.Property("PredecessorLevel") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OperationId"); + + b.HasIndex("Type", "Id"); + + b.ToTable("InboxMessages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("IncreasePaidStorageOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BalanceChange") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Level"); + + b.HasIndex("ScriptId"); + + b.HasIndex("StorageId"); + + b.ToTable("MigrationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RevealedCycle") + .HasColumnType("integer"); + + b.Property("RevealedLevel") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasAlternateKey("RevealedLevel"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RevealedCycle"); + + b.HasIndex("SenderId"); + + b.ToTable("NonceRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash") + .HasFilter("\"ContractCodeHash\" IS NOT NULL"); + + b.HasIndex("ContractId"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("ManagerId"); + + b.HasIndex("OpHash"); + + b.HasIndex("ScriptId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.ToTable("OriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("PreendorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstPeriod") + .HasColumnType("integer"); + + b.Property("Hash") + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastPeriod") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Upvotes") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Hash"); + + b.ToTable("Proposals"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Duplicated") + .HasColumnType("boolean"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("ProposalOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotQuorumMax") + .HasColumnType("integer"); + + b.Property("BallotQuorumMin") + .HasColumnType("integer"); + + b.Property("BlockDeposit") + .HasColumnType("bigint"); + + b.Property("BlockReward0") + .HasColumnType("bigint"); + + b.Property("BlockReward1") + .HasColumnType("bigint"); + + b.Property("BlocksPerCommitment") + .HasColumnType("integer"); + + b.Property("BlocksPerCycle") + .HasColumnType("integer"); + + b.Property("BlocksPerSnapshot") + .HasColumnType("integer"); + + b.Property("BlocksPerVoting") + .HasColumnType("integer"); + + b.Property("ByteCost") + .HasColumnType("integer"); + + b.Property("Code") + .HasColumnType("integer"); + + b.Property("ConsensusThreshold") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("text"); + + b.Property("DoubleBakingPunishment") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingPunishmentDenominator") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingPunishmentNumerator") + .HasColumnType("integer"); + + b.Property("EndorsementDeposit") + .HasColumnType("bigint"); + + b.Property("EndorsementReward0") + .HasColumnType("bigint"); + + b.Property("EndorsementReward1") + .HasColumnType("bigint"); + + b.Property("EndorsersPerBlock") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstCycle") + .HasColumnType("integer"); + + b.Property("FirstCycleLevel") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FrozenDepositsPercentage") + .HasColumnType("integer"); + + b.Property("HardBlockGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationStorageLimit") + .HasColumnType("integer"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBSubsidy") + .HasColumnType("integer"); + + b.Property("LBToggleThreshold") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBakingReward") + .HasColumnType("bigint"); + + b.Property("MaxEndorsingReward") + .HasColumnType("bigint"); + + b.Property("MaxSlashingPeriod") + .HasColumnType("integer"); + + b.Property("MinParticipationDenominator") + .HasColumnType("integer"); + + b.Property("MinParticipationNumerator") + .HasColumnType("integer"); + + b.Property("NoRewardCycles") + .HasColumnType("integer"); + + b.Property("OriginationSize") + .HasColumnType("integer"); + + b.Property("PreservedCycles") + .HasColumnType("integer"); + + b.Property("ProposalQuorum") + .HasColumnType("integer"); + + b.Property("RampUpCycles") + .HasColumnType("integer"); + + b.Property("RevelationReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupChallengeWindow") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentPeriod") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginationSize") + .HasColumnType("integer"); + + b.Property("SmartRollupStakeAmount") + .HasColumnType("bigint"); + + b.Property("SmartRollupTimeoutPeriod") + .HasColumnType("integer"); + + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); + + b.Property("TokensPerRoll") + .HasColumnType("bigint"); + + b.Property("TxRollupCommitmentBond") + .HasColumnType("bigint"); + + b.Property("TxRollupOriginationSize") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Protocols"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Btc") + .HasColumnType("double precision"); + + b.Property("Cny") + .HasColumnType("double precision"); + + b.Property("Eth") + .HasColumnType("double precision"); + + b.Property("Eur") + .HasColumnType("double precision"); + + b.Property("Gbp") + .HasColumnType("double precision"); + + b.Property("Jpy") + .HasColumnType("double precision"); + + b.Property("Krw") + .HasColumnType("double precision"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Usd") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("InitiatorCommitmentId") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InitiatorLoss") + .HasColumnType("bigint"); + + b.Property("InitiatorReward") + .HasColumnType("bigint"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("LastMoveId") + .HasColumnType("bigint"); + + b.Property("OpponentCommitmentId") + .HasColumnType("integer"); + + b.Property("OpponentId") + .HasColumnType("integer"); + + b.Property("OpponentLoss") + .HasColumnType("bigint"); + + b.Property("OpponentReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("InitiatorCommitmentId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("LastLevel"); + + b.HasIndex("OpponentCommitmentId"); + + b.HasIndex("OpponentId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("RefutationGames"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("Refs") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique() + .HasFilter("\"Address\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RegisterConstantOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RevealOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("MissedLevel") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("RevelationPenaltyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Script", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CodeSchema") + .HasColumnType("bytea"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("StorageSchema") + .HasColumnType("bytea"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("Views") + .HasColumnType("bytea[]"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Scripts"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Limit") + .HasColumnType("text"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SetDepositsLimitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MessagesCount") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupAddMessagesOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupCementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("PredecessorId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Stakers") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Successors") + .HasColumnType("integer"); + + b.Property("Ticks") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Hash"); + + b.HasIndex("InboxLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("PredecessorId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("Hash", "SmartRollupId"); + + b.ToTable("SmartRollupCommitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupExecuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("Kernel") + .HasColumnType("bytea"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("OriginationProof") + .HasColumnType("bytea"); + + b.Property("ParameterType") + .HasColumnType("bytea"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupOriginateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("BondStatus") + .HasColumnType("integer"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Flags") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("SmartRollupId", "BondStatus", "SenderId") + .HasFilter("\"BondStatus\" IS NOT NULL"); + + b.ToTable("SmartRollupPublishOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("StakerId"); + + b.ToTable("SmartRollupRecoverBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DissectionEnd") + .HasColumnType("bigint"); + + b.Property("DissectionStart") + .HasColumnType("bigint"); + + b.Property("DissectionSteps") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GameId") + .HasColumnType("integer"); + + b.Property("GameStatus") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Move") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupRefuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .HasFilter("\"DelegateId\" IS NULL"); + + b.ToTable("SnapshotBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("ShortHash") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character(8)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("TotalActivated") + .HasColumnType("bigint"); + + b.Property("TotalBanished") + .HasColumnType("bigint"); + + b.Property("TotalBootstrapped") + .HasColumnType("bigint"); + + b.Property("TotalBurned") + .HasColumnType("bigint"); + + b.Property("TotalCommitments") + .HasColumnType("bigint"); + + b.Property("TotalCreated") + .HasColumnType("bigint"); + + b.Property("TotalFrozen") + .HasColumnType("bigint"); + + b.Property("TotalRollupBonds") + .HasColumnType("bigint"); + + b.Property("TotalSmartRollupBonds") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle") + .IsUnique() + .HasFilter("\"Cycle\" IS NOT NULL"); + + b.HasIndex("Date") + .IsUnique() + .HasFilter("\"Date\" IS NOT NULL"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Statistics"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Storage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("Content") + .HasColumnType("bytea"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentType") + .HasColumnType("bytea"); + + b.Property("ContentTypeHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("numeric"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("TicketTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Token", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TokenId") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("ContractId", "TokenId") + .IsUnique(); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("ContractId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TokenId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "ContractId"); + + b.HasIndex("AccountId", "TokenId") + .IsUnique(); + + b.ToTable("TokenBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TokenId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("TokenTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InternalDelegations") + .HasColumnType("smallint"); + + b.Property("InternalOperations") + .HasColumnType("smallint"); + + b.Property("InternalOriginations") + .HasColumnType("smallint"); + + b.Property("InternalTransactions") + .HasColumnType("smallint"); + + b.Property("JsonParameters") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawParameters") + .HasColumnType("bytea"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetCodeHash") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("JsonParameters"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.HasIndex("TargetCodeHash") + .HasFilter("\"TargetCodeHash\" IS NOT NULL"); + + b.HasIndex("TargetId"); + + b.ToTable("TransactionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("TargetId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TransferTicketOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupCommitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupDispatchTicketsOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupFinalizeCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupOriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitterId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitterId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRejectionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRemoveCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupReturnBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupSubmitBatchOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("PublicKeyHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("UpdateConsensusKeyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Proof") + .HasColumnType("bytea"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Solution") + .HasColumnType("bytea"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotsQuorum") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("integer"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("NayBallots") + .HasColumnType("integer"); + + b.Property("NayVotingPower") + .HasColumnType("bigint"); + + b.Property("ParticipationEma") + .HasColumnType("integer"); + + b.Property("PassBallots") + .HasColumnType("integer"); + + b.Property("PassVotingPower") + .HasColumnType("bigint"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("SingleWinner") + .HasColumnType("boolean"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Supermajority") + .HasColumnType("integer"); + + b.Property("TopUpvotes") + .HasColumnType("integer"); + + b.Property("TopVotingPower") + .HasColumnType("bigint"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalVotingPower") + .HasColumnType("bigint"); + + b.Property("UpvotesQuorum") + .HasColumnType("integer"); + + b.Property("YayBallots") + .HasColumnType("integer"); + + b.Property("YayVotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Epoch"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("VotingPeriods"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Period"); + + b.HasIndex("Period", "BakerId") + .IsUnique(); + + b.ToTable("VotingSnapshots"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("smallint"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Spendable") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("WeirdDelegateId") + .HasColumnType("integer"); + + b.HasIndex("CodeHash"); + + b.HasIndex("CreatorId"); + + b.HasIndex("ManagerId"); + + b.HasIndex("TypeHash"); + + b.HasIndex("WeirdDelegateId"); + + b.HasIndex("Type", "Kind") + .HasFilter("\"Type\" = 2"); + + b.HasDiscriminator().HasValue((byte)2); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)4); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("CementedCommitments") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("ExecutedCommitments") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("LastCommitment") + .HasColumnType("text"); + + b.Property("OrphanCommitments") + .HasColumnType("integer"); + + b.Property("PendingCommitments") + .HasColumnType("integer"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("RefutedCommitments") + .HasColumnType("integer"); + + b.Property("TotalStakers") + .HasColumnType("integer"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)5); + }); + + modelBuilder.Entity("Tzkt.Data.Models.User", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("Activated") + .HasColumnType("boolean"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("RegisterConstantsCount") + .HasColumnType("integer"); + + b.Property("Revealed") + .HasColumnType("boolean"); + + b.Property("SetDepositsLimitsCount") + .HasColumnType("integer"); + + b.HasDiscriminator().HasValue((byte)0); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasBaseType("Tzkt.Data.Models.User"); + + b.Property("ActivationLevel") + .HasColumnType("integer"); + + b.Property("BallotsCount") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("DeactivationLevel") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingCount") + .HasColumnType("integer"); + + b.Property("EndorsementsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardsCount") + .HasColumnType("integer"); + + b.Property("FrozenDeposit") + .HasColumnType("bigint"); + + b.Property("FrozenDepositLimit") + .HasColumnType("bigint"); + + b.Property("NonceRevelationsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltiesCount") + .HasColumnType("integer"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.Property("VdfRevelationsCount") + .HasColumnType("integer"); + + b.HasIndex("SoftwareId"); + + b.HasIndex("Type", "Staked") + .HasFilter("\"Type\" = 1"); + + b.HasDiscriminator().HasValue((byte)1); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany("DelegatedAccounts") + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") + .WithMany("CreatedAccounts") + .HasForeignKey("FirstLevel") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Delegate"); + + b.Navigation("FirstBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.HasOne("Tzkt.Data.Models.User", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Activations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Ballots") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") + .WithMany() + .HasForeignKey("ProposerId"); + + b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") + .WithMany() + .HasForeignKey("ProtoCode") + .HasPrincipalKey("Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") + .WithOne("RevealedBlock") + .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); + + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Proposer"); + + b.Navigation("Protocol"); + + b.Navigation("Revelation"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Delegations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") + .WithMany() + .HasForeignKey("PrevDelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("PrevDelegate"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleBakings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleEndorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoublePreendorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DrainDelegateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Endorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("IncreasePaidStorageOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Migrations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Account"); + + b.Navigation("Block"); + + b.Navigation("Script"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Revelations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Contract", "Contract") + .WithMany() + .HasForeignKey("ContractId"); + + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Originations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Block"); + + b.Navigation("Contract"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("Manager"); + + b.Navigation("Script"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Preendorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Proposals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RegisterConstants") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Reveals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RevelationPenalties") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDepositsLimits") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupAddMessagesOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupCementOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupExecuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupOriginateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupPublishOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRecoverBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRefuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Ticket", "Ticket") + .WithMany() + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Ticket"); + + b.Navigation("Ticketer"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Transactions") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.HasOne("Tzkt.Data.Models.Account", "Target") + .WithMany() + .HasForeignKey("TargetId"); + + b.Navigation("Block"); + + b.Navigation("Initiator"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TransferTicketOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + + b.Navigation("Ticketer"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupCommitOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupDispatchTicketsOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupFinalizeCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupOriginationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRejectionOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRemoveCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupReturnBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupSubmitBatchOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("UpdateConsensusKeyOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("VdfRevelationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") + .WithMany() + .HasForeignKey("WeirdDelegateId"); + + b.Navigation("Creator"); + + b.Navigation("Manager"); + + b.Navigation("WeirdDelegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Navigation("Activations"); + + b.Navigation("Ballots"); + + b.Navigation("CreatedAccounts"); + + b.Navigation("Delegations"); + + b.Navigation("DoubleBakings"); + + b.Navigation("DoubleEndorsings"); + + b.Navigation("DoublePreendorsings"); + + b.Navigation("DrainDelegateOps"); + + b.Navigation("Endorsements"); + + b.Navigation("IncreasePaidStorageOps"); + + b.Navigation("Migrations"); + + b.Navigation("Originations"); + + b.Navigation("Preendorsements"); + + b.Navigation("Proposals"); + + b.Navigation("RegisterConstants"); + + b.Navigation("Reveals"); + + b.Navigation("RevelationPenalties"); + + b.Navigation("Revelations"); + + b.Navigation("SetDepositsLimits"); + + b.Navigation("SmartRollupAddMessagesOps"); + + b.Navigation("SmartRollupCementOps"); + + b.Navigation("SmartRollupExecuteOps"); + + b.Navigation("SmartRollupOriginateOps"); + + b.Navigation("SmartRollupPublishOps"); + + b.Navigation("SmartRollupRecoverBondOps"); + + b.Navigation("SmartRollupRefuteOps"); + + b.Navigation("Transactions"); + + b.Navigation("TransferTicketOps"); + + b.Navigation("TxRollupCommitOps"); + + b.Navigation("TxRollupDispatchTicketsOps"); + + b.Navigation("TxRollupFinalizeCommitmentOps"); + + b.Navigation("TxRollupOriginationOps"); + + b.Navigation("TxRollupRejectionOps"); + + b.Navigation("TxRollupRemoveCommitmentOps"); + + b.Navigation("TxRollupReturnBondOps"); + + b.Navigation("TxRollupSubmitBatchOps"); + + b.Navigation("UpdateConsensusKeyOps"); + + b.Navigation("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Navigation("RevealedBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.Navigation("DelegatedAccounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tzkt.Data/Migrations/20230730143042_test.cs b/Tzkt.Data/Migrations/20230730143042_test.cs new file mode 100644 index 000000000..a43b57c66 --- /dev/null +++ b/Tzkt.Data/Migrations/20230730143042_test.cs @@ -0,0 +1,114 @@ +using System.Globalization; +using System.Numerics; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class test : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "TicketId", + table: "Tickets"); + + migrationBuilder.AddColumn( + name: "Content", + table: "Tickets", + type: "bytea", + nullable: true); + + migrationBuilder.AddColumn( + name: "ContentType", + table: "Tickets", + type: "bytea", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId", + table: "TicketBalances", + column: "AccountId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_TicketerId", + table: "TicketBalances", + column: "TicketerId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_TicketId", + table: "TicketBalances", + column: "TicketId"); + + migrationBuilder.AddForeignKey( + name: "FK_TicketBalances_Accounts_AccountId", + table: "TicketBalances", + column: "AccountId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_TicketBalances_Accounts_TicketerId", + table: "TicketBalances", + column: "TicketerId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_TicketBalances_Tickets_TicketId", + table: "TicketBalances", + column: "TicketId", + principalTable: "Tickets", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TicketBalances_Accounts_AccountId", + table: "TicketBalances"); + + migrationBuilder.DropForeignKey( + name: "FK_TicketBalances_Accounts_TicketerId", + table: "TicketBalances"); + + migrationBuilder.DropForeignKey( + name: "FK_TicketBalances_Tickets_TicketId", + table: "TicketBalances"); + + migrationBuilder.DropIndex( + name: "IX_TicketBalances_AccountId", + table: "TicketBalances"); + + migrationBuilder.DropIndex( + name: "IX_TicketBalances_TicketerId", + table: "TicketBalances"); + + migrationBuilder.DropIndex( + name: "IX_TicketBalances_TicketId", + table: "TicketBalances"); + + migrationBuilder.DropColumn( + name: "Content", + table: "Tickets"); + + migrationBuilder.DropColumn( + name: "ContentType", + table: "Tickets"); + + migrationBuilder.AddColumn( + name: "TicketId", + table: "Tickets", + type: "numeric", + nullable: false, + defaultValue: BigInteger.Parse("0", NumberFormatInfo.InvariantInfo)); + } + } +} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index a75a20437..6701b4632 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3586,9 +3586,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("BalancesCount") .HasColumnType("integer"); + b.Property("Content") + .HasColumnType("bytea"); + b.Property("ContentHash") .HasColumnType("integer"); + b.Property("ContentType") + .HasColumnType("bytea"); + b.Property("ContentTypeHash") .HasColumnType("integer"); @@ -3610,9 +3616,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("OwnerId") .HasColumnType("integer"); - b.Property("TicketId") - .HasColumnType("numeric"); - b.Property("TicketerId") .HasColumnType("integer"); @@ -3667,6 +3670,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); + b.HasIndex("AccountId"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + b.ToTable("TicketBalances"); }); @@ -5836,6 +5845,33 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Sender"); }); + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Ticket", "Ticket") + .WithMany() + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Ticket"); + + b.Navigation("Ticketer"); + }); + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => { b.HasOne("Tzkt.Data.Models.Account", "Initiator") diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs index e6177aac3..9f4b5d58a 100644 --- a/Tzkt.Data/Models/Scripts/TIcket.cs +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -27,6 +27,9 @@ public class Ticket public int ContentHash { get; set; } public int ContentTypeHash { get; set; } + + public byte[] Content { get; set; } + public byte[] ContentType { get; set; } } public static class TicketModel diff --git a/Tzkt.Sync/Protocols/Abstract/IRpc.cs b/Tzkt.Sync/Protocols/Abstract/IRpc.cs index d9652654c..c28497e63 100644 --- a/Tzkt.Sync/Protocols/Abstract/IRpc.cs +++ b/Tzkt.Sync/Protocols/Abstract/IRpc.cs @@ -22,7 +22,7 @@ public interface IRpc Task GetActiveDelegatesAsync(int level); Task GetDelegateParticipationAsync(int level, string address); Task GetCycleAsync(int level, int cycle); - Task GetTicketBalance(int level, string address, TicketToken ticket); + Task GetTicketBalance(int level, string address, string ticket); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs index e22fdda75..8a5283c5d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs @@ -53,7 +53,7 @@ public Task GetCycleAsync(int level, int cycle) public Task GetDelegateParticipationAsync(int level, string address) => throw new InvalidOperationException(); - public Task GetTicketBalance(int level, string address, TicketToken ticket) + public Task GetTicketBalance(int level, string address, string ticket) => throw new InvalidOperationException(); #endregion } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs index 48e41bbca..7bb96720a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs @@ -51,7 +51,7 @@ public virtual Task GetCycleAsync(int level, int cycle) public virtual Task GetDelegateParticipationAsync(int level, string address) => throw new InvalidOperationException(); - public virtual Task GetTicketBalance(int level, string address, TicketToken ticket) + public virtual Task GetTicketBalance(int level, string address, string ticket) => throw new InvalidOperationException(); #endregion } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 98584ab35..47d3afed9 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -28,9 +28,8 @@ public virtual async Task Apply() { var ticketer = await Cache.Accounts.GetAsync(ticketUpdates.TicketToken.Ticketer); var contract = ticketer as Contract; - var contentHash = Script.GetHash(ticketUpdates.TicketToken.Content.ToBytes()); - var contentTypeHash = Script.GetHash(ticketUpdates.TicketToken.ContentType.ToBytes()); - var ticket = GetOrCreateTicket(op, contract, contentHash, contentTypeHash); + + var ticket = GetOrCreateTicket(op, contract, ticketUpdates.TicketToken); //TODO Match updates, if successful, transfers, if not, burns and mints foreach (var ticketUpdate in ticketUpdates.Updates) @@ -74,13 +73,17 @@ Account GetOrCreateAccount(ContractOperation op, string address) return account; } - Ticket GetOrCreateTicket(ContractOperation op, Contract contract, int contentHash, int contentTypeHash) + Ticket GetOrCreateTicket(ContractOperation op, Contract contract, TicketToken ticketToken) { + var contentHash = Script.GetHash(ticketToken.Content.ToBytes()); + var contentTypeHash = Script.GetHash(ticketToken.ContentType.ToBytes()); + if (Cache.Tickets.TryGet(contract.Id, contentHash, contentTypeHash, out var ticket)) return ticket; var state = Cache.AppState.Get(); state.TicketsCount++; + ticket = new Ticket { Id = Cache.AppState.NextSubId(op), @@ -91,6 +94,8 @@ Ticket GetOrCreateTicket(ContractOperation op, Contract contract, int contentHas TotalBurned = BigInteger.Zero, TotalMinted = BigInteger.Zero, TotalSupply = BigInteger.Zero, + Content = ticketToken.Content.ToBytes(), + ContentType = ticketToken.ContentType.ToBytes(), ContentHash = contentHash, ContentTypeHash = contentTypeHash, IndexedAt = op.Level <= state.Level ? state.Level + 1 : null diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs index fb27568cb..8da537fb8 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs @@ -1,4 +1,6 @@ -using Netezos.Encoding; +using System.Numerics; +using System.Text.Json; +using Netezos.Encoding; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto17 @@ -9,8 +11,23 @@ public Diagnostics(ProtocolHandler handler) : base(handler) { } protected override async Task TestTicketBalance(int level, TicketBalance balance) { - var a = balance. - var a = await Rpc.GetTicketBalance(level, balance., ticket); + var update = new + { + ticketer = balance.Ticketer.Address, + content_type = Micheline.FromBytes(balance.Ticket.ContentType), + content = Micheline.FromBytes(balance.Ticket.Content) + }; + var ticket = JsonSerializer.Serialize(update); + + if (BigInteger.TryParse((await Rpc.GetTicketBalance(level, balance.Account.Address, ticket)).ToString(), out var remoteBalance)) + { + if (remoteBalance != balance.Balance) + throw new Exception($"Diagnostics failed: wrong ticket balance for {balance.Account.Address}"); + } + else + { + throw new Exception("Failed to get ticket balance"); + } } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs index ffba10f66..36dba282a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs @@ -7,7 +7,7 @@ class Rpc : Proto12.Rpc { public Rpc(TezosNode node) : base(node) { } - public override Task GetTicketBalance(int level, string address, TicketToken ticket) - => Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); + public override Task GetTicketBalance(int level, string address, string ticket) + => Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); } } diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs index c4e4dec9e..06b7b60d5 100644 --- a/Tzkt.Sync/Services/Cache/TicketsCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -102,6 +102,7 @@ public async Task Preload(IEnumerable ids) } } + //TODO Fix/delete public async Task Preload(IEnumerable<(int, int, int)> ids) { var missed = ids.Where(x => !CachedByKey.ContainsKey(x)).ToHashSet(); @@ -113,7 +114,7 @@ public async Task Preload(IEnumerable<(int, int, int)> ids) var items = await Db.Tickets .FromSqlRaw($@" SELECT * FROM ""{nameof(TzktContext.Tickets)}"" - WHERE (""{nameof(Ticket.TicketerId)}"", ""{nameof(Ticket.TicketId)}"") IN ({corteges})") + WHERE (""{nameof(Ticket.TicketerId)}"", ""{nameof(Ticket.ContentHash)}"") IN ({corteges})") .ToListAsync(); foreach (var item in items) diff --git a/Tzkt.Sync/Services/TezosNode/TezosNode.cs b/Tzkt.Sync/Services/TezosNode/TezosNode.cs index cd9056037..1d8e5f2ae 100644 --- a/Tzkt.Sync/Services/TezosNode/TezosNode.cs +++ b/Tzkt.Sync/Services/TezosNode/TezosNode.cs @@ -40,9 +40,9 @@ public async Task GetAsync(string url) return doc.RootElement.Clone(); } - public async Task PostAsync(string url, object data) + public async Task PostAsync(string url, string content) { - return await Rpc.PostAsync(url, data); + return await Rpc.PostAsync(url, content); } public async Task
GetHeaderAsync() diff --git a/Tzkt.Sync/Utils/JsonContent.cs b/Tzkt.Sync/Utils/JsonContent.cs new file mode 100644 index 000000000..57997fee3 --- /dev/null +++ b/Tzkt.Sync/Utils/JsonContent.cs @@ -0,0 +1,12 @@ +using System.Net.Http.Headers; + +namespace Tzkt.Sync +{ + class JsonContent : StringContent + { + public JsonContent(string content) : base(content) + { + Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); + } + } +} \ No newline at end of file diff --git a/Tzkt.Sync/Utils/TzktClient.cs b/Tzkt.Sync/Utils/TzktClient.cs index 1303373b1..9e9f085f6 100644 --- a/Tzkt.Sync/Utils/TzktClient.cs +++ b/Tzkt.Sync/Utils/TzktClient.cs @@ -4,6 +4,7 @@ using System.Net.Http; using System.Net.Http.Headers; using System.Reflection; +using System.Text; using System.Text.Json; using System.Threading.Tasks; @@ -30,7 +31,7 @@ HttpClient HttpClient _HttpClient.BaseAddress = BaseAddress; _HttpClient.DefaultRequestHeaders.Accept.Add( - new MediaTypeWithQualityHeaderValue("application/json")); + new MediaTypeWithQualityHeaderValue("application/json")); _HttpClient.DefaultRequestHeaders.UserAgent.Add( new ProductInfoHeaderValue("TzKT-Indexer", Assembly.GetExecutingAssembly().GetName().Version.ToString())); _HttpClient.Timeout = RequestTimeout; @@ -64,11 +65,9 @@ public async Task GetObjectAsync(string path) return await JsonSerializer.DeserializeAsync(stream, SerializerOptions.Default); } - public async Task PostAsync(string path, object data) + public async Task PostAsync(string path, string content) { - var content = JsonSerializer.Serialize(data); - - var response = await HttpClient.PostAsJsonAsync(path, content); + var response = await HttpClient.PostAsync(path, new JsonContent(content)); using var stream = await response.Content.ReadAsStreamAsync(); return await JsonSerializer.DeserializeAsync(stream); From cf06a8d4e9ddf82beb24aafe3b3da72c660a27d2 Mon Sep 17 00:00:00 2001 From: dmir Date: Mon, 31 Jul 2023 20:06:19 +0300 Subject: [PATCH 08/51] Add cache for tickets --- .../Commits/Operations/TransactionsCommit.cs | 3 +- .../Operations/TransferTicketCommit.cs | 2 +- .../Handlers/Proto17/Commits/TicketsCommit.cs | 53 +++++++++++++++++++ .../Protocols/Handlers/Proto17/Rpc/Rpc.cs | 9 +++- Tzkt.Sync/Services/Cache/CacheService.cs | 4 ++ 5 files changed, 66 insertions(+), 5 deletions(-) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index ec29cdd18..0f4d310d0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -18,7 +18,6 @@ class TransactionsCommit : ProtocolCommit public TransactionOperation Transaction { get; private set; } public IEnumerable BigMapDiffs { get; private set; } public IEnumerable TicketUpdates { get; private set; } - public IEnumerable TicketReceipt { get; private set; } public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } @@ -293,7 +292,7 @@ public virtual async Task ApplyInternal(Block block, ManagerOperation parent, Js await ProcessStorage(transaction, storage); } - TicketReceipt = ParseTicketUpdates("ticket_receipt", result); + TicketUpdates = ParseTicketUpdates("ticket_receipt", result); if (transaction.Target is SmartRollup) Proto.Inbox.Push(transaction.Id); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 73cfe1bde..1c63db438 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -202,7 +202,7 @@ public virtual async Task Revert(Block block, TransferTicketOperation operation) protected virtual IEnumerable ParseTicketUpdates(JsonElement result) { - if (!result.TryGetProperty("ticket_update", out var ticketUpdates)) + if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 47d3afed9..9622455b3 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -24,8 +24,61 @@ public virtual async Task Apply() if (Updates.Count == 0) return; //TODO We need cache here; + + #region precache + + var accountsSet = new HashSet(); + var ticketsSet = new HashSet<(int, int, int)>(); + var balancesSet = new HashSet<(int, long)>(); + + foreach (var (op, update) in Updates) + { + accountsSet.Add(update.TicketToken.Ticketer); + foreach (var upd in update.Updates) + { + accountsSet.Add(upd.Account); + } + } + await Cache.Accounts.Preload(accountsSet); + + foreach (var (op, update) in Updates) + { + if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) + { + //TODO Move out + var contentHash = Script.GetHash(update.TicketToken.Content.ToBytes()); + var contentTypeHash = Script.GetHash(update.TicketToken.ContentType.ToBytes()); + ticketsSet.Add((ticketer.Id, contentHash, contentTypeHash)); + } + } + + await Cache.Tickets.Preload(ticketsSet); + + foreach (var (op, update) in Updates) + { + if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) + { + //TODO Move out + var contentHash = Script.GetHash(update.TicketToken.Content.ToBytes()); + var contentTypeHash = Script.GetHash(update.TicketToken.ContentType.ToBytes()); + if (Cache.Tickets.TryGet(ticketer.Id, contentHash, contentTypeHash, out var ticket)) + { + foreach (var upd in update.Updates) + { + if (Cache.Accounts.TryGetCached(upd.Account, out var acc)) + balancesSet.Add((acc.Id, ticket.Id)); + } + } + } + } + + await Cache.TicketBalances.Preload(balancesSet); + + #endregion + foreach (var (op, ticketUpdates) in Updates) { + //TODO GetOrCreate? var ticketer = await Cache.Accounts.GetAsync(ticketUpdates.TicketToken.Ticketer); var contract = ticketer as Contract; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs index 36dba282a..ab1d88eda 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using System.Text.RegularExpressions; using Tzkt.Sync.Services; namespace Tzkt.Sync.Protocols.Proto17 @@ -6,8 +7,12 @@ namespace Tzkt.Sync.Protocols.Proto17 class Rpc : Proto12.Rpc { public Rpc(TezosNode node) : base(node) { } - + public override Task GetTicketBalance(int level, string address, string ticket) - => Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); + { + return Regex.IsMatch(address, "^sr1[0-9A-Za-z]{33}$") + ? Node.PostAsync($"chains/main/blocks/{level}/context/smart_rollups/smart_rollup/{address}/ticket_balance", ticket) + : Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); + } } } diff --git a/Tzkt.Sync/Services/Cache/CacheService.cs b/Tzkt.Sync/Services/Cache/CacheService.cs index dab05bca0..d6371a23d 100644 --- a/Tzkt.Sync/Services/Cache/CacheService.cs +++ b/Tzkt.Sync/Services/Cache/CacheService.cs @@ -68,6 +68,8 @@ public async Task ResetAsync() BigMapKeys.Reset(); Tokens.Reset(); TokenBalances.Reset(); + Tickets.Reset(); + TicketBalances.Reset(); SmartRollupCommitments.Reset(); SmartRollupStakes.Reset(); RefutationGames.Reset(); @@ -80,6 +82,8 @@ public void Trim() { Tokens.Trim(); TokenBalances.Trim(); + Tickets.Trim(); + TicketBalances.Trim(); SmartRollupCommitments.Trim(); SmartRollupStakes.Trim(); RefutationGames.Trim(); From 69fd811bf3c0c7416731d79718e9f47d5e60999f Mon Sep 17 00:00:00 2001 From: dmir Date: Tue, 1 Aug 2023 14:15:24 +0300 Subject: [PATCH 09/51] Balances are correct here --- .../Migrations/TzktContextModelSnapshot.cs | 15 ++-- .../Operations/Base/ContractOperation.cs | 2 - .../Models/Operations/TransactionOperation.cs | 2 + .../Operations/TransferTicketOperation.cs | 4 + Tzkt.Data/Models/Scripts/TicketTransfer.cs | 6 +- .../Handlers/Proto17/Commits/TicketsCommit.cs | 88 +++++++++++++++---- .../Handlers/Proto17/Proto17Handler.cs | 2 +- Tzkt.Sync/Services/Cache/AppStateCache.cs | 7 ++ 8 files changed, 97 insertions(+), 29 deletions(-) diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 6701b4632..9fca4f600 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -2039,9 +2039,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SubIds") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3702,9 +3699,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("MigrationId") .HasColumnType("bigint"); - b.Property("OriginationId") - .HasColumnType("bigint"); - b.Property("TicketId") .HasColumnType("bigint"); @@ -3717,6 +3711,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TransactionId") .HasColumnType("bigint"); + b.Property("TransferTicketId") + .HasColumnType("bigint"); + b.HasKey("Id"); b.ToTable("TicketTransfers"); @@ -4142,9 +4139,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("TicketerId") .HasColumnType("integer"); diff --git a/Tzkt.Data/Models/Operations/Base/ContractOperation.cs b/Tzkt.Data/Models/Operations/Base/ContractOperation.cs index 359ca49d4..9d8315d1f 100644 --- a/Tzkt.Data/Models/Operations/Base/ContractOperation.cs +++ b/Tzkt.Data/Models/Operations/Base/ContractOperation.cs @@ -5,8 +5,6 @@ public class ContractOperation : InternalOperation public int? StorageId { get; set; } public int? BigMapUpdates { get; set; } public int? TokenTransfers { get; set; } - public int? TicketTransfers { get; set; } - public int? SubIds { get; set; } } } diff --git a/Tzkt.Data/Models/Operations/TransactionOperation.cs b/Tzkt.Data/Models/Operations/TransactionOperation.cs index db9e4375a..9ff983341 100644 --- a/Tzkt.Data/Models/Operations/TransactionOperation.cs +++ b/Tzkt.Data/Models/Operations/TransactionOperation.cs @@ -23,6 +23,8 @@ public class TransactionOperation : ContractOperation public short? InternalTransactions { get; set; } public int? EventsCount { get; set; } + + public int? TicketTransfers { get; set; } #region relations [ForeignKey(nameof(TargetId))] diff --git a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs index d6c0b9e3d..0c9d10233 100644 --- a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs +++ b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs @@ -16,6 +16,10 @@ public class TransferTicketOperation : ManagerOperation public byte[] RawContent { get; set; } public string JsonContent { get; set; } public string Entrypoint { get; set; } + + public int? TicketTransfers { get; set; } + public int? SubIds { get; set; } + //TODO Delete ForeignKey #region relations diff --git a/Tzkt.Data/Models/Scripts/TicketTransfer.cs b/Tzkt.Data/Models/Scripts/TicketTransfer.cs index 46a6047e2..0a768e533 100644 --- a/Tzkt.Data/Models/Scripts/TicketTransfer.cs +++ b/Tzkt.Data/Models/Scripts/TicketTransfer.cs @@ -15,7 +15,7 @@ public class TicketTransfer public int? FromId { get; set; } public int? ToId { get; set; } - public long? OriginationId { get; set; } + public long? TransferTicketId { get; set; } public long? TransactionId { get; set; } public long? MigrationId { get; set; } public int? IndexedAt { get; set; } @@ -60,8 +60,8 @@ public static void BuildTicketTransferModel(this ModelBuilder modelBuilder) .HasFilter($@"""{nameof(TicketTransfer.IndexedAt)}"" is not null"); modelBuilder.Entity() - .HasIndex(x => x.OriginationId) - .HasFilter($@"""{nameof(TicketTransfer.OriginationId)}"" is not null"); + .HasIndex(x => x.TransferTicketId) + .HasFilter($@"""{nameof(TicketTransfer.TransferTicketId)}"" is not null"); modelBuilder.Entity() .HasIndex(x => x.TransactionId) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 9622455b3..9bc15474c 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -9,15 +9,23 @@ class TicketsCommit : ProtocolCommit { public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } - readonly List<(ContractOperation op,TicketUpdate update)> Updates = new(); + readonly List<(ManagerOperation op,TicketUpdate update)> Updates = new(); + // readonly List<(TransferTicketOperation op,TicketUpdate update)> Transfers = new(); - public virtual void Append(ContractOperation op, IEnumerable updates) + public virtual void Append(ManagerOperation op, IEnumerable updates) { foreach (var update in updates) { Updates.Add((op, update)); } } + // public virtual void Append(TransferTicketOperation op, IEnumerable updates) + // { + // foreach (var update in updates) + // { + // Transfers.Add((op, update)); + // } + // } public virtual async Task Apply() { @@ -88,6 +96,7 @@ public virtual async Task Apply() foreach (var ticketUpdate in ticketUpdates.Updates) { var amount = BigInteger.Parse(ticketUpdate.Amount); + //TODO Fix here for transfer_ticket var account = GetOrCreateAccount(op, ticketUpdate.Account); var balance = GetOrCreateTicketBalance(op, ticket, account); MintOrBurnTickets(op, ticket, account, balance, amount); @@ -96,7 +105,7 @@ public virtual async Task Apply() } } - Account GetOrCreateAccount(ContractOperation op, string address) + Account GetOrCreateAccount(ManagerOperation op, string address) { if (!Cache.Accounts.TryGetCached(address, out var account)) { @@ -126,7 +135,7 @@ Account GetOrCreateAccount(ContractOperation op, string address) return account; } - Ticket GetOrCreateTicket(ContractOperation op, Contract contract, TicketToken ticketToken) + Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken ticketToken) { var contentHash = Script.GetHash(ticketToken.Content.ToBytes()); var contentTypeHash = Script.GetHash(ticketToken.ContentType.ToBytes()); @@ -136,12 +145,23 @@ Ticket GetOrCreateTicket(ContractOperation op, Contract contract, TicketToken ti var state = Cache.AppState.Get(); state.TicketsCount++; - + //Initiator to internal tx, sender for transfer_ticket and parent transaction + ticket = new Ticket { - Id = Cache.AppState.NextSubId(op), + Id = op switch + { + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, TicketerId = contract.Id, - FirstMinterId = op.InitiatorId ?? op.SenderId, + FirstMinterId = op switch + { + ContractOperation contractOperation => contractOperation.InitiatorId ?? contractOperation.SenderId, + TransferTicketOperation transfer => transfer.SenderId, + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, FirstLevel = op.Level, LastLevel = op.Level, TotalBurned = BigInteger.Zero, @@ -153,6 +173,7 @@ Ticket GetOrCreateTicket(ContractOperation op, Contract contract, TicketToken ti ContentTypeHash = contentTypeHash, IndexedAt = op.Level <= state.Level ? state.Level + 1 : null }; + Db.Tickets.Add(ticket); Cache.Tickets.Add(ticket); @@ -164,7 +185,7 @@ Ticket GetOrCreateTicket(ContractOperation op, Contract contract, TicketToken ti return ticket; } - TicketBalance GetOrCreateTicketBalance(ContractOperation op, Ticket ticket, Account account) + TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Account account) { if (!Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) { @@ -173,7 +194,12 @@ TicketBalance GetOrCreateTicketBalance(ContractOperation op, Ticket ticket, Acco ticketBalance = new TicketBalance { - Id = Cache.AppState.NextSubId(op), + Id = op switch + { + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, AccountId = account.Id, TicketId = ticket.Id, TicketerId = ticket.TicketerId, @@ -199,12 +225,21 @@ TicketBalance GetOrCreateTicketBalance(ContractOperation op, Ticket ticket, Acco return ticketBalance; } - void TransferTickets(ContractOperation op, Contract contract, Ticket ticket, + void TransferTickets(ManagerOperation op, Contract contract, Ticket ticket, Account from, TicketBalance fromBalance, Account to, TicketBalance toBalance, BigInteger amount) { - op.TicketTransfers = (op.TicketTransfers ?? 0) + 1; + //TODO Need to be tested + switch (op) + { + case TransferTicketOperation transfer1: + transfer1.TicketTransfers = (transfer1.TicketTransfers ?? 0) + 1; + break; + case TransactionOperation tx: + tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; + break; + } Db.TryAttach(from); from.TicketTransfersCount++; @@ -244,7 +279,12 @@ void TransferTickets(ContractOperation op, Contract contract, Ticket ticket, Db.TicketTransfers.Add(new TicketTransfer { - Id = Cache.AppState.NextSubId(op), + Id = op switch + { + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, Amount = amount, FromId = from.Id, ToId = to.Id, @@ -252,16 +292,25 @@ void TransferTickets(ContractOperation op, Contract contract, Ticket ticket, TicketId = ticket.Id, TicketerId = ticket.TicketerId, TransactionId = (op as TransactionOperation)?.Id, - OriginationId = (op as OriginationOperation)?.Id, + TransferTicketId = (op as OriginationOperation)?.Id, IndexedAt = op.Level <= state.Level ? state.Level + 1 : null }); } - void MintOrBurnTickets(ContractOperation op, Ticket ticket, + void MintOrBurnTickets(ManagerOperation op, Ticket ticket, Account account, TicketBalance balance, BigInteger diff) { - op.TicketTransfers = (op.TicketTransfers ?? 0) + 1; + //TODO Need to be tested + switch (op) + { + case TransferTicketOperation transfer1: + transfer1.TicketTransfers = (transfer1.TicketTransfers ?? 0) + 1; + break; + case TransactionOperation tx: + tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; + break; + } Db.TryAttach(account); account.TicketTransfersCount++; @@ -291,7 +340,12 @@ void MintOrBurnTickets(ContractOperation op, Ticket ticket, Db.TicketTransfers.Add(new TicketTransfer { - Id = Cache.AppState.NextSubId(op), + Id = op switch + { + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, Amount = diff > BigInteger.Zero ? diff : -diff, FromId = diff < BigInteger.Zero ? account.Id : null, ToId = diff > BigInteger.Zero ? account.Id : null, @@ -299,7 +353,7 @@ void MintOrBurnTickets(ContractOperation op, Ticket ticket, TicketId = ticket.Id, TicketerId = ticket.TicketerId, TransactionId = (op as TransactionOperation)?.Id, - OriginationId = (op as OriginationOperation)?.Id, + TransferTicketId = (op as TransferTicketOperation)?.Id, IndexedAt = op.Level <= state.Level ? state.Level + 1 : null }); } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index 30779d6b2..02b14bc08 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -234,7 +234,7 @@ public override async Task Commit(JsonElement block) await parent1.Apply(blockCommit.Block, operation, content); if (parent1.TicketUpdates != null) //TODO Figure out behaviour for the transfer_ticket - ticketsCommit.Append(null, parent1.TicketUpdates); + ticketsCommit.Append(parent1.Operation, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) diff --git a/Tzkt.Sync/Services/Cache/AppStateCache.cs b/Tzkt.Sync/Services/Cache/AppStateCache.cs index 6b064d1ab..b7cc718cd 100644 --- a/Tzkt.Sync/Services/Cache/AppStateCache.cs +++ b/Tzkt.Sync/Services/Cache/AppStateCache.cs @@ -177,6 +177,13 @@ public long NextSubId(ContractOperation op) return op.Id + (int)op.SubIds; } + public long NextSubId(TransferTicketOperation op) + { + op.SubIds = (op.SubIds ?? 0) + 1; + if (op.SubIds >= 1 << AppState.SubIdBits) throw new Exception("SubId overflow"); + return op.Id + (int)op.SubIds; + } + public long NextSubId(MigrationOperation op) { op.SubIds = (op.SubIds ?? 0) + 1; From efdc193650b56192232a5861207ee8329cd788e7 Mon Sep 17 00:00:00 2001 From: dmir Date: Tue, 1 Aug 2023 14:22:15 +0300 Subject: [PATCH 10/51] Test migration --- .../20230801105851_toDelete.Designer.cs | 6266 +++++++++++++++++ .../Migrations/20230801105851_toDelete.cs | 58 + 2 files changed, 6324 insertions(+) create mode 100644 Tzkt.Data/Migrations/20230801105851_toDelete.Designer.cs create mode 100644 Tzkt.Data/Migrations/20230801105851_toDelete.cs diff --git a/Tzkt.Data/Migrations/20230801105851_toDelete.Designer.cs b/Tzkt.Data/Migrations/20230801105851_toDelete.Designer.cs new file mode 100644 index 000000000..228b8a5ff --- /dev/null +++ b/Tzkt.Data/Migrations/20230801105851_toDelete.Designer.cs @@ -0,0 +1,6266 @@ +// +using System; +using System.Numerics; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Tzkt.Data; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + [DbContext(typeof(TzktContext))] + [Migration("20230801105851_toDelete")] + partial class toDelete + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveRefutationGamesCount") + .HasColumnType("integer"); + + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + + b.Property("ActiveTokensCount") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character varying(37)"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("ContractsCount") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegationLevel") + .HasColumnType("integer"); + + b.Property("DelegationsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageCount") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("MigrationsCount") + .HasColumnType("integer"); + + b.Property("OriginationsCount") + .HasColumnType("integer"); + + b.Property("RefutationGamesCount") + .HasColumnType("integer"); + + b.Property("RevealsCount") + .HasColumnType("integer"); + + b.Property("RollupBonds") + .HasColumnType("bigint"); + + b.Property("RollupsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesCount") + .HasColumnType("integer"); + + b.Property("SmartRollupBonds") + .HasColumnType("bigint"); + + b.Property("SmartRollupCementCount") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupsCount") + .HasColumnType("integer"); + + b.Property("Staked") + .HasColumnType("boolean"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TransactionsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchCount") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UpdateConsensusKeyCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("DelegateId"); + + b.HasIndex("Extras"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Staked"); + + b.HasIndex("Type"); + + b.ToTable("Accounts"); + + b.HasDiscriminator("Type").HasValue((byte)3); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("ActivationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AppState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountCounter") + .HasColumnType("integer"); + + b.Property("AccountsCount") + .HasColumnType("integer"); + + b.Property("ActivationOpsCount") + .HasColumnType("integer"); + + b.Property("BallotOpsCount") + .HasColumnType("integer"); + + b.Property("BigMapCounter") + .HasColumnType("integer"); + + b.Property("BigMapKeyCounter") + .HasColumnType("integer"); + + b.Property("BigMapUpdateCounter") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Chain") + .HasColumnType("text"); + + b.Property("ChainId") + .HasColumnType("text"); + + b.Property("CommitmentsCount") + .HasColumnType("integer"); + + b.Property("ConstantsCount") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("CyclesCount") + .HasColumnType("integer"); + + b.Property("DelegationOpsCount") + .HasColumnType("integer"); + + b.Property("DomainsLevel") + .HasColumnType("integer"); + + b.Property("DomainsNameRegistry") + .HasColumnType("text"); + + b.Property("DoubleBakingOpsCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsementOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardOpsCount") + .HasColumnType("integer"); + + b.Property("EventCounter") + .HasColumnType("integer"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxMessageCounter") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageOpsCount") + .HasColumnType("integer"); + + b.Property("KnownHead") + .HasColumnType("integer"); + + b.Property("LastSync") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerCounter") + .HasColumnType("integer"); + + b.Property("MigrationOpsCount") + .HasColumnType("integer"); + + b.Property("NextProtocol") + .HasColumnType("text"); + + b.Property("NonceRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("OperationCounter") + .HasColumnType("bigint"); + + b.Property("OriginationOpsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ProtocolsCount") + .HasColumnType("integer"); + + b.Property("QuoteBtc") + .HasColumnType("double precision"); + + b.Property("QuoteCny") + .HasColumnType("double precision"); + + b.Property("QuoteEth") + .HasColumnType("double precision"); + + b.Property("QuoteEur") + .HasColumnType("double precision"); + + b.Property("QuoteGbp") + .HasColumnType("double precision"); + + b.Property("QuoteJpy") + .HasColumnType("double precision"); + + b.Property("QuoteKrw") + .HasColumnType("double precision"); + + b.Property("QuoteLevel") + .HasColumnType("integer"); + + b.Property("QuoteUsd") + .HasColumnType("double precision"); + + b.Property("RefutationGameCounter") + .HasColumnType("integer"); + + b.Property("RegisterConstantOpsCount") + .HasColumnType("integer"); + + b.Property("RevealOpsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltyOpsCount") + .HasColumnType("integer"); + + b.Property("ScriptCounter") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCementOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentCounter") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteOpsCount") + .HasColumnType("integer"); + + b.Property("StorageCounter") + .HasColumnType("integer"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TransactionOpsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchOpsCount") + .HasColumnType("integer"); + + b.Property("UpdateConsensusKeyOpsCount") + .HasColumnType("integer"); + + b.Property("VdfRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("VotingEpoch") + .HasColumnType("integer"); + + b.Property("VotingPeriod") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AppState"); + + b.HasData( + new + { + Id = -1, + AccountCounter = 0, + AccountsCount = 0, + ActivationOpsCount = 0, + BallotOpsCount = 0, + BigMapCounter = 0, + BigMapKeyCounter = 0, + BigMapUpdateCounter = 0, + BlocksCount = 0, + CommitmentsCount = 0, + ConstantsCount = 0, + Cycle = -1, + CyclesCount = 0, + DelegationOpsCount = 0, + DomainsLevel = 0, + DoubleBakingOpsCount = 0, + DoubleEndorsingOpsCount = 0, + DoublePreendorsingOpsCount = 0, + DrainDelegateOpsCount = 0, + EndorsementOpsCount = 0, + EndorsingRewardOpsCount = 0, + EventCounter = 0, + EventsCount = 0, + Hash = "", + InboxMessageCounter = 0, + IncreasePaidStorageOpsCount = 0, + KnownHead = 0, + LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Level = -1, + ManagerCounter = 0, + MigrationOpsCount = 0, + NextProtocol = "", + NonceRevelationOpsCount = 0, + OperationCounter = 0L, + OriginationOpsCount = 0, + PreendorsementOpsCount = 0, + ProposalOpsCount = 0, + ProposalsCount = 0, + Protocol = "", + ProtocolsCount = 0, + QuoteBtc = 0.0, + QuoteCny = 0.0, + QuoteEth = 0.0, + QuoteEur = 0.0, + QuoteGbp = 0.0, + QuoteJpy = 0.0, + QuoteKrw = 0.0, + QuoteLevel = -1, + QuoteUsd = 0.0, + RefutationGameCounter = 0, + RegisterConstantOpsCount = 0, + RevealOpsCount = 0, + RevelationPenaltyOpsCount = 0, + ScriptCounter = 0, + SetDepositsLimitOpsCount = 0, + SmartRollupAddMessagesOpsCount = 0, + SmartRollupCementOpsCount = 0, + SmartRollupCommitmentCounter = 0, + SmartRollupExecuteOpsCount = 0, + SmartRollupOriginateOpsCount = 0, + SmartRollupPublishOpsCount = 0, + SmartRollupRecoverBondOpsCount = 0, + SmartRollupRefuteOpsCount = 0, + StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, + Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + TokenBalancesCount = 0, + TokenTransfersCount = 0, + TokensCount = 0, + TransactionOpsCount = 0, + TransferTicketOpsCount = 0, + TxRollupCommitOpsCount = 0, + TxRollupDispatchTicketsOpsCount = 0, + TxRollupFinalizeCommitmentOpsCount = 0, + TxRollupOriginationOpsCount = 0, + TxRollupRejectionOpsCount = 0, + TxRollupRemoveCommitmentOpsCount = 0, + TxRollupReturnBondOpsCount = 0, + TxRollupSubmitBatchOpsCount = 0, + UpdateConsensusKeyOpsCount = 0, + VdfRevelationOpsCount = 0, + VotingEpoch = -1, + VotingPeriod = -1 + }); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStake") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("BlockFees") + .HasColumnType("bigint"); + + b.Property("BlockRewards") + .HasColumnType("bigint"); + + b.Property("Blocks") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleBakingRewards") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingRewards") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingRewards") + .HasColumnType("bigint"); + + b.Property("EndorsementRewards") + .HasColumnType("bigint"); + + b.Property("Endorsements") + .HasColumnType("integer"); + + b.Property("ExpectedBlocks") + .HasColumnType("double precision"); + + b.Property("ExpectedEndorsements") + .HasColumnType("double precision"); + + b.Property("FutureBlockRewards") + .HasColumnType("bigint"); + + b.Property("FutureBlocks") + .HasColumnType("integer"); + + b.Property("FutureEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("FutureEndorsements") + .HasColumnType("integer"); + + b.Property("MissedBlockFees") + .HasColumnType("bigint"); + + b.Property("MissedBlockRewards") + .HasColumnType("bigint"); + + b.Property("MissedBlocks") + .HasColumnType("integer"); + + b.Property("MissedEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("MissedEndorsements") + .HasColumnType("integer"); + + b.Property("RevelationLosses") + .HasColumnType("bigint"); + + b.Property("RevelationRewards") + .HasColumnType("bigint"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Cycle", "BakerId") + .IsUnique(); + + b.ToTable("BakerCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Round") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakingRights"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Vote") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("BallotOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("ActiveKeys") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("KeyType") + .HasColumnType("bytea"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Ptr") + .HasColumnType("integer"); + + b.Property("StoragePath") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TotalKeys") + .HasColumnType("integer"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.Property("ValueType") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasAlternateKey("Ptr"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Ptr") + .IsUnique(); + + b.ToTable("BigMaps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("JsonKey") + .HasColumnType("jsonb"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("KeyHash") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawKey") + .HasColumnType("bytea"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonKey"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); + + b.HasIndex("JsonValue"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("BigMapPtr", "Active") + .HasFilter("\"Active\" = true"); + + b.HasIndex("BigMapPtr", "KeyHash"); + + b.ToTable("BigMapKeys"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("BigMapKeyId") + .HasColumnType("integer"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BigMapKeyId") + .HasFilter("\"BigMapKeyId\" is not null"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("BigMapUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlockRound") + .HasColumnType("integer"); + + b.Property("Bonus") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Events") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Fees") + .HasColumnType("bigint"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggle") + .HasColumnType("boolean"); + + b.Property("LBToggleEma") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Operations") + .HasColumnType("bigint"); + + b.Property("PayloadRound") + .HasColumnType("integer"); + + b.Property("ProducerId") + .HasColumnType("integer"); + + b.Property("ProposerId") + .HasColumnType("integer"); + + b.Property("ProtoCode") + .HasColumnType("integer"); + + b.Property("ResetBakerDeactivation") + .HasColumnType("integer"); + + b.Property("ResetProposerDeactivation") + .HasColumnType("integer"); + + b.Property("RevelationId") + .HasColumnType("bigint"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Validations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("Level") + .IsUnique(); + + b.HasIndex("ProducerId"); + + b.HasIndex("ProposerId"); + + b.HasIndex("ProtoCode"); + + b.HasIndex("RevelationId") + .IsUnique(); + + b.HasIndex("SoftwareId"); + + b.ToTable("Blocks"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character(37)") + .IsFixedLength(); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Commitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("JsonPayload") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RawPayload") + .HasColumnType("bytea"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonPayload"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("Tag"); + + b.HasIndex("TransactionId"); + + b.HasIndex("ContractCodeHash", "Tag"); + + b.HasIndex("ContractId", "Tag"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Seed") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("SelectedBakers") + .HasColumnType("integer"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("SnapshotIndex") + .HasColumnType("integer"); + + b.Property("SnapshotLevel") + .HasColumnType("integer"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalDelegated") + .HasColumnType("bigint"); + + b.Property("TotalDelegators") + .HasColumnType("integer"); + + b.Property("TotalStaking") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("Cycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevDelegateId") + .HasColumnType("integer"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("PrevDelegateId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.ToTable("DelegationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatorId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("DelegatorId"); + + b.HasIndex("Cycle", "BakerId"); + + b.HasIndex("Cycle", "DelegatorId") + .IsUnique(); + + b.ToTable("DelegatorCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("jsonb"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("Reverse") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("Address"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Level"); + + b.HasIndex("Name"); + + b.HasIndex("Owner"); + + b.ToTable("Domains"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleBakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleEndorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoublePreendorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Fee") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("TargetId"); + + b.ToTable("DrainDelegateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("EndorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Expected") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Received") + .HasColumnType("bigint"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("EndorsingRewardOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Change") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.ToTable("FreezerUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OperationId") + .HasColumnType("bigint"); + + b.Property("Payload") + .HasColumnType("bytea"); + + b.Property("PredecessorLevel") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OperationId"); + + b.HasIndex("Type", "Id"); + + b.ToTable("InboxMessages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("IncreasePaidStorageOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BalanceChange") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Level"); + + b.HasIndex("ScriptId"); + + b.HasIndex("StorageId"); + + b.ToTable("MigrationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RevealedCycle") + .HasColumnType("integer"); + + b.Property("RevealedLevel") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasAlternateKey("RevealedLevel"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RevealedCycle"); + + b.HasIndex("SenderId"); + + b.ToTable("NonceRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash") + .HasFilter("\"ContractCodeHash\" IS NOT NULL"); + + b.HasIndex("ContractId"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("ManagerId"); + + b.HasIndex("OpHash"); + + b.HasIndex("ScriptId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.ToTable("OriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("PreendorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstPeriod") + .HasColumnType("integer"); + + b.Property("Hash") + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastPeriod") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Upvotes") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Hash"); + + b.ToTable("Proposals"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Duplicated") + .HasColumnType("boolean"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("ProposalOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotQuorumMax") + .HasColumnType("integer"); + + b.Property("BallotQuorumMin") + .HasColumnType("integer"); + + b.Property("BlockDeposit") + .HasColumnType("bigint"); + + b.Property("BlockReward0") + .HasColumnType("bigint"); + + b.Property("BlockReward1") + .HasColumnType("bigint"); + + b.Property("BlocksPerCommitment") + .HasColumnType("integer"); + + b.Property("BlocksPerCycle") + .HasColumnType("integer"); + + b.Property("BlocksPerSnapshot") + .HasColumnType("integer"); + + b.Property("BlocksPerVoting") + .HasColumnType("integer"); + + b.Property("ByteCost") + .HasColumnType("integer"); + + b.Property("Code") + .HasColumnType("integer"); + + b.Property("ConsensusThreshold") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("text"); + + b.Property("DoubleBakingPunishment") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingPunishmentDenominator") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingPunishmentNumerator") + .HasColumnType("integer"); + + b.Property("EndorsementDeposit") + .HasColumnType("bigint"); + + b.Property("EndorsementReward0") + .HasColumnType("bigint"); + + b.Property("EndorsementReward1") + .HasColumnType("bigint"); + + b.Property("EndorsersPerBlock") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstCycle") + .HasColumnType("integer"); + + b.Property("FirstCycleLevel") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FrozenDepositsPercentage") + .HasColumnType("integer"); + + b.Property("HardBlockGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationStorageLimit") + .HasColumnType("integer"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBSubsidy") + .HasColumnType("integer"); + + b.Property("LBToggleThreshold") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBakingReward") + .HasColumnType("bigint"); + + b.Property("MaxEndorsingReward") + .HasColumnType("bigint"); + + b.Property("MaxSlashingPeriod") + .HasColumnType("integer"); + + b.Property("MinParticipationDenominator") + .HasColumnType("integer"); + + b.Property("MinParticipationNumerator") + .HasColumnType("integer"); + + b.Property("NoRewardCycles") + .HasColumnType("integer"); + + b.Property("OriginationSize") + .HasColumnType("integer"); + + b.Property("PreservedCycles") + .HasColumnType("integer"); + + b.Property("ProposalQuorum") + .HasColumnType("integer"); + + b.Property("RampUpCycles") + .HasColumnType("integer"); + + b.Property("RevelationReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupChallengeWindow") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentPeriod") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginationSize") + .HasColumnType("integer"); + + b.Property("SmartRollupStakeAmount") + .HasColumnType("bigint"); + + b.Property("SmartRollupTimeoutPeriod") + .HasColumnType("integer"); + + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); + + b.Property("TokensPerRoll") + .HasColumnType("bigint"); + + b.Property("TxRollupCommitmentBond") + .HasColumnType("bigint"); + + b.Property("TxRollupOriginationSize") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Protocols"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Btc") + .HasColumnType("double precision"); + + b.Property("Cny") + .HasColumnType("double precision"); + + b.Property("Eth") + .HasColumnType("double precision"); + + b.Property("Eur") + .HasColumnType("double precision"); + + b.Property("Gbp") + .HasColumnType("double precision"); + + b.Property("Jpy") + .HasColumnType("double precision"); + + b.Property("Krw") + .HasColumnType("double precision"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Usd") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("InitiatorCommitmentId") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InitiatorLoss") + .HasColumnType("bigint"); + + b.Property("InitiatorReward") + .HasColumnType("bigint"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("LastMoveId") + .HasColumnType("bigint"); + + b.Property("OpponentCommitmentId") + .HasColumnType("integer"); + + b.Property("OpponentId") + .HasColumnType("integer"); + + b.Property("OpponentLoss") + .HasColumnType("bigint"); + + b.Property("OpponentReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("InitiatorCommitmentId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("LastLevel"); + + b.HasIndex("OpponentCommitmentId"); + + b.HasIndex("OpponentId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("RefutationGames"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("Refs") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique() + .HasFilter("\"Address\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RegisterConstantOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RevealOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("MissedLevel") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("RevelationPenaltyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Script", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CodeSchema") + .HasColumnType("bytea"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("StorageSchema") + .HasColumnType("bytea"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("Views") + .HasColumnType("bytea[]"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Scripts"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Limit") + .HasColumnType("text"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SetDepositsLimitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MessagesCount") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupAddMessagesOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupCementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("PredecessorId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Stakers") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Successors") + .HasColumnType("integer"); + + b.Property("Ticks") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Hash"); + + b.HasIndex("InboxLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("PredecessorId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("Hash", "SmartRollupId"); + + b.ToTable("SmartRollupCommitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupExecuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("Kernel") + .HasColumnType("bytea"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("OriginationProof") + .HasColumnType("bytea"); + + b.Property("ParameterType") + .HasColumnType("bytea"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupOriginateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("BondStatus") + .HasColumnType("integer"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Flags") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("SmartRollupId", "BondStatus", "SenderId") + .HasFilter("\"BondStatus\" IS NOT NULL"); + + b.ToTable("SmartRollupPublishOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("StakerId"); + + b.ToTable("SmartRollupRecoverBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DissectionEnd") + .HasColumnType("bigint"); + + b.Property("DissectionStart") + .HasColumnType("bigint"); + + b.Property("DissectionSteps") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GameId") + .HasColumnType("integer"); + + b.Property("GameStatus") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Move") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupRefuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .HasFilter("\"DelegateId\" IS NULL"); + + b.ToTable("SnapshotBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("ShortHash") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character(8)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("TotalActivated") + .HasColumnType("bigint"); + + b.Property("TotalBanished") + .HasColumnType("bigint"); + + b.Property("TotalBootstrapped") + .HasColumnType("bigint"); + + b.Property("TotalBurned") + .HasColumnType("bigint"); + + b.Property("TotalCommitments") + .HasColumnType("bigint"); + + b.Property("TotalCreated") + .HasColumnType("bigint"); + + b.Property("TotalFrozen") + .HasColumnType("bigint"); + + b.Property("TotalRollupBonds") + .HasColumnType("bigint"); + + b.Property("TotalSmartRollupBonds") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle") + .IsUnique() + .HasFilter("\"Cycle\" IS NOT NULL"); + + b.HasIndex("Date") + .IsUnique() + .HasFilter("\"Date\" IS NOT NULL"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Statistics"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Storage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("Content") + .HasColumnType("bytea"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentType") + .HasColumnType("bytea"); + + b.Property("ContentTypeHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .HasColumnType("numeric"); + + b.Property("TotalMinted") + .HasColumnType("numeric"); + + b.Property("TotalSupply") + .HasColumnType("numeric"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("numeric"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("numeric"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("TransferTicketId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.ToTable("TicketTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Token", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TokenId") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("ContractId", "TokenId") + .IsUnique(); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("ContractId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TokenId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "ContractId"); + + b.HasIndex("AccountId", "TokenId") + .IsUnique(); + + b.ToTable("TokenBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TokenId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("TokenTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InternalDelegations") + .HasColumnType("smallint"); + + b.Property("InternalOperations") + .HasColumnType("smallint"); + + b.Property("InternalOriginations") + .HasColumnType("smallint"); + + b.Property("InternalTransactions") + .HasColumnType("smallint"); + + b.Property("JsonParameters") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawParameters") + .HasColumnType("bytea"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetCodeHash") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("JsonParameters"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.HasIndex("TargetCodeHash") + .HasFilter("\"TargetCodeHash\" IS NOT NULL"); + + b.HasIndex("TargetId"); + + b.ToTable("TransactionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("TargetId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TransferTicketOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupCommitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupDispatchTicketsOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupFinalizeCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupOriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitterId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitterId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRejectionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRemoveCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupReturnBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupSubmitBatchOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("PublicKeyHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("UpdateConsensusKeyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Proof") + .HasColumnType("bytea"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Solution") + .HasColumnType("bytea"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotsQuorum") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("integer"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("NayBallots") + .HasColumnType("integer"); + + b.Property("NayVotingPower") + .HasColumnType("bigint"); + + b.Property("ParticipationEma") + .HasColumnType("integer"); + + b.Property("PassBallots") + .HasColumnType("integer"); + + b.Property("PassVotingPower") + .HasColumnType("bigint"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("SingleWinner") + .HasColumnType("boolean"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Supermajority") + .HasColumnType("integer"); + + b.Property("TopUpvotes") + .HasColumnType("integer"); + + b.Property("TopVotingPower") + .HasColumnType("bigint"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalVotingPower") + .HasColumnType("bigint"); + + b.Property("UpvotesQuorum") + .HasColumnType("integer"); + + b.Property("YayBallots") + .HasColumnType("integer"); + + b.Property("YayVotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Epoch"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("VotingPeriods"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Period"); + + b.HasIndex("Period", "BakerId") + .IsUnique(); + + b.ToTable("VotingSnapshots"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("smallint"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Spendable") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("WeirdDelegateId") + .HasColumnType("integer"); + + b.HasIndex("CodeHash"); + + b.HasIndex("CreatorId"); + + b.HasIndex("ManagerId"); + + b.HasIndex("TypeHash"); + + b.HasIndex("WeirdDelegateId"); + + b.HasIndex("Type", "Kind") + .HasFilter("\"Type\" = 2"); + + b.HasDiscriminator().HasValue((byte)2); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)4); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("CementedCommitments") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("ExecutedCommitments") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("LastCommitment") + .HasColumnType("text"); + + b.Property("OrphanCommitments") + .HasColumnType("integer"); + + b.Property("PendingCommitments") + .HasColumnType("integer"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("RefutedCommitments") + .HasColumnType("integer"); + + b.Property("TotalStakers") + .HasColumnType("integer"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)5); + }); + + modelBuilder.Entity("Tzkt.Data.Models.User", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("Activated") + .HasColumnType("boolean"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("RegisterConstantsCount") + .HasColumnType("integer"); + + b.Property("Revealed") + .HasColumnType("boolean"); + + b.Property("SetDepositsLimitsCount") + .HasColumnType("integer"); + + b.HasDiscriminator().HasValue((byte)0); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasBaseType("Tzkt.Data.Models.User"); + + b.Property("ActivationLevel") + .HasColumnType("integer"); + + b.Property("BallotsCount") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("DeactivationLevel") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingCount") + .HasColumnType("integer"); + + b.Property("EndorsementsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardsCount") + .HasColumnType("integer"); + + b.Property("FrozenDeposit") + .HasColumnType("bigint"); + + b.Property("FrozenDepositLimit") + .HasColumnType("bigint"); + + b.Property("NonceRevelationsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltiesCount") + .HasColumnType("integer"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.Property("VdfRevelationsCount") + .HasColumnType("integer"); + + b.HasIndex("SoftwareId"); + + b.HasIndex("Type", "Staked") + .HasFilter("\"Type\" = 1"); + + b.HasDiscriminator().HasValue((byte)1); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany("DelegatedAccounts") + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") + .WithMany("CreatedAccounts") + .HasForeignKey("FirstLevel") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Delegate"); + + b.Navigation("FirstBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.HasOne("Tzkt.Data.Models.User", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Activations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Ballots") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") + .WithMany() + .HasForeignKey("ProposerId"); + + b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") + .WithMany() + .HasForeignKey("ProtoCode") + .HasPrincipalKey("Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") + .WithOne("RevealedBlock") + .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); + + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Proposer"); + + b.Navigation("Protocol"); + + b.Navigation("Revelation"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Delegations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") + .WithMany() + .HasForeignKey("PrevDelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("PrevDelegate"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleBakings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleEndorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoublePreendorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DrainDelegateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Endorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("IncreasePaidStorageOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Migrations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Account"); + + b.Navigation("Block"); + + b.Navigation("Script"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Revelations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Contract", "Contract") + .WithMany() + .HasForeignKey("ContractId"); + + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Originations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Block"); + + b.Navigation("Contract"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("Manager"); + + b.Navigation("Script"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Preendorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Proposals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RegisterConstants") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Reveals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RevelationPenalties") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDepositsLimits") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupAddMessagesOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupCementOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupExecuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupOriginateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupPublishOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRecoverBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRefuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Ticket", "Ticket") + .WithMany() + .HasForeignKey("TicketId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Ticket"); + + b.Navigation("Ticketer"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Transactions") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.HasOne("Tzkt.Data.Models.Account", "Target") + .WithMany() + .HasForeignKey("TargetId"); + + b.Navigation("Block"); + + b.Navigation("Initiator"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TransferTicketOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Ticketer") + .WithMany() + .HasForeignKey("TicketerId"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + + b.Navigation("Ticketer"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupCommitOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupDispatchTicketsOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupFinalizeCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupOriginationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRejectionOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRemoveCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupReturnBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupSubmitBatchOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("UpdateConsensusKeyOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("VdfRevelationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") + .WithMany() + .HasForeignKey("WeirdDelegateId"); + + b.Navigation("Creator"); + + b.Navigation("Manager"); + + b.Navigation("WeirdDelegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Navigation("Activations"); + + b.Navigation("Ballots"); + + b.Navigation("CreatedAccounts"); + + b.Navigation("Delegations"); + + b.Navigation("DoubleBakings"); + + b.Navigation("DoubleEndorsings"); + + b.Navigation("DoublePreendorsings"); + + b.Navigation("DrainDelegateOps"); + + b.Navigation("Endorsements"); + + b.Navigation("IncreasePaidStorageOps"); + + b.Navigation("Migrations"); + + b.Navigation("Originations"); + + b.Navigation("Preendorsements"); + + b.Navigation("Proposals"); + + b.Navigation("RegisterConstants"); + + b.Navigation("Reveals"); + + b.Navigation("RevelationPenalties"); + + b.Navigation("Revelations"); + + b.Navigation("SetDepositsLimits"); + + b.Navigation("SmartRollupAddMessagesOps"); + + b.Navigation("SmartRollupCementOps"); + + b.Navigation("SmartRollupExecuteOps"); + + b.Navigation("SmartRollupOriginateOps"); + + b.Navigation("SmartRollupPublishOps"); + + b.Navigation("SmartRollupRecoverBondOps"); + + b.Navigation("SmartRollupRefuteOps"); + + b.Navigation("Transactions"); + + b.Navigation("TransferTicketOps"); + + b.Navigation("TxRollupCommitOps"); + + b.Navigation("TxRollupDispatchTicketsOps"); + + b.Navigation("TxRollupFinalizeCommitmentOps"); + + b.Navigation("TxRollupOriginationOps"); + + b.Navigation("TxRollupRejectionOps"); + + b.Navigation("TxRollupRemoveCommitmentOps"); + + b.Navigation("TxRollupReturnBondOps"); + + b.Navigation("TxRollupSubmitBatchOps"); + + b.Navigation("UpdateConsensusKeyOps"); + + b.Navigation("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Navigation("RevealedBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.Navigation("DelegatedAccounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tzkt.Data/Migrations/20230801105851_toDelete.cs b/Tzkt.Data/Migrations/20230801105851_toDelete.cs new file mode 100644 index 000000000..e4242f791 --- /dev/null +++ b/Tzkt.Data/Migrations/20230801105851_toDelete.cs @@ -0,0 +1,58 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class toDelete : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "OriginationOps"); + + migrationBuilder.RenameColumn( + name: "OriginationId", + table: "TicketTransfers", + newName: "TransferTicketId"); + + migrationBuilder.AddColumn( + name: "SubIds", + table: "TransferTicketOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "TransferTicketOps", + type: "integer", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "SubIds", + table: "TransferTicketOps"); + + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "TransferTicketOps"); + + migrationBuilder.RenameColumn( + name: "TransferTicketId", + table: "TicketTransfers", + newName: "OriginationId"); + + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "OriginationOps", + type: "integer", + nullable: true); + } + } +} From edf4c192cdac569831c44406da78b1e60f170b68 Mon Sep 17 00:00:00 2001 From: dmir Date: Tue, 1 Aug 2023 18:56:30 +0300 Subject: [PATCH 11/51] WIP Revert --- .../Operations/SmartRollupExecuteCommit.cs | 33 +++ .../Handlers/Proto17/Commits/TicketsCommit.cs | 215 +++++++++++++++++- .../Handlers/Proto17/Proto17Handler.cs | 5 +- 3 files changed, 248 insertions(+), 5 deletions(-) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index 38b4a2802..4e1697a50 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using Netezos.Encoding; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -7,6 +8,7 @@ namespace Tzkt.Sync.Protocols.Proto16 class SmartRollupExecuteCommit : ProtocolCommit { public SmartRollupExecuteOperation Operation { get; private set; } + public IEnumerable TicketUpdates { get; private set; } public SmartRollupExecuteCommit(ProtocolHandler protocol) : base(protocol) { } @@ -104,6 +106,8 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content if (senderDelegate.Id != sender.Id) senderDelegate.DelegatedBalance -= burned; } + + TicketUpdates = ParseTicketUpdates(result); rollup.ExecutedCommitments++; @@ -186,5 +190,34 @@ public virtual async Task Revert(Block block, SmartRollupExecuteOperation operat Cache.AppState.ReleaseManagerCounter(); Cache.AppState.ReleaseOperationId(); } + + protected virtual IEnumerable ParseTicketUpdates(JsonElement result) + { + if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) + return null; + + return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + { + TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) + ? new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + ContentType = ticketToken.TryGetProperty("content_type", out var contentType) + ? Micheline.FromJson(contentType) + : null, + Content = ticketToken.TryGetProperty("content", out var content) + ? Micheline.FromJson(content) + : null, + } + : null, + Updates = x.TryGetProperty("updates", out var updates) + ? updates.RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = y.RequiredString("amount") + }) + : null + }); + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 9bc15474c..483bf191b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -1,4 +1,5 @@ using System.Numerics; +using Microsoft.EntityFrameworkCore; using Netezos.Encoding; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -171,7 +172,7 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic ContentType = ticketToken.ContentType.ToBytes(), ContentHash = contentHash, ContentTypeHash = contentTypeHash, - IndexedAt = op.Level <= state.Level ? state.Level + 1 : null + IndexedAt = op.Level <= state.Level ? state.Level + 1 : null //TODO Can be not null? }; Db.Tickets.Add(ticket); @@ -301,7 +302,6 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, Account account, TicketBalance balance, BigInteger diff) { - //TODO Need to be tested switch (op) { case TransferTicketOperation transfer1: @@ -360,9 +360,216 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, public virtual async Task Revert(Block block) { - //TODO Implement revert + if (!block.Events.HasFlag(BlockEvents.Tickets)) + return; + + var state = Cache.AppState.Get(); + + var transfers = await Db.TicketTransfers + .AsNoTracking() + .Where(x => x.Level == block.Level) + .OrderByDescending(x => x.Id) + .ToListAsync(); + + #region precache + var accountsSet = new HashSet(); + var ticketsSet = new HashSet(); + var balancesSet = new HashSet<(int, long)>(); + + foreach (var tr in transfers) + ticketsSet.Add(tr.TicketId); + + await Cache.Tokens.Preload(ticketsSet); + + foreach (var tr in transfers) + { + if (tr.FromId is int fromId) + { + accountsSet.Add(fromId); + balancesSet.Add((fromId, tr.TicketId)); + } + + if (tr.ToId is int toId) + { + accountsSet.Add(toId); + balancesSet.Add((toId, tr.TicketId)); + } + } + + foreach (var id in ticketsSet) + { + var ticket = Cache.Tickets.Get(id); + accountsSet.Add(ticket.TicketerId); + } + + await Cache.Accounts.Preload(accountsSet); + await Cache.TicketBalances.Preload(balancesSet); + #endregion + + var ticketsToRemove = new HashSet(); + var ticketBalancesToRemove = new HashSet(); + + foreach (var transfer in transfers) + { + var ticket = Cache.Tickets.Get(transfer.TicketId); + var contract = (Contract)Cache.Accounts.GetCached(ticket.TicketerId); + Db.TryAttach(ticket); + ticket.LastLevel = block.Level; + if (ticket.FirstLevel == block.Level) + ticketsToRemove.Add(ticket); + + if (transfer.FromId is int fromId && transfer.ToId is int toId) + { + #region revert transfer + var from = Cache.Accounts.GetCached(fromId); + var to = Cache.Accounts.GetCached(toId); + var fromBalance = Cache.TicketBalances.Get(from.Id, ticket.Id); + var toBalance = Cache.TicketBalances.Get(to.Id, ticket.Id); + + Db.TryAttach(from); + Db.TryAttach(to); + Db.TryAttach(fromBalance); + Db.TryAttach(toBalance); + + from.TicketTransfersCount--; + if (to != from) to.TicketTransfersCount--; + + fromBalance.Balance += transfer.Amount; + fromBalance.TransfersCount--; + fromBalance.LastLevel = block.Level; + if (fromBalance.FirstLevel == block.Level) + ticketBalancesToRemove.Add(fromBalance); + + toBalance.Balance -= transfer.Amount; + if (toBalance != fromBalance) toBalance.TransfersCount--; + toBalance.LastLevel = block.Level; + if (toBalance.FirstLevel == block.Level) + ticketBalancesToRemove.Add(toBalance); + + ticket.TransfersCount--; + if (transfer.Amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) + { + if (fromBalance.Balance == transfer.Amount) + { + from.ActiveTicketsCount++; + ticket.HoldersCount++; + } + if (toBalance.Balance == BigInteger.Zero) + { + to.ActiveTicketsCount--; + ticket.HoldersCount--; + } + + if (contract.Tags.HasFlag(ContractTags.Nft)) + ticket.OwnerId = from.Id; + } + + state.TicketTransfersCount--; + #endregion + } + else if (transfer.ToId != null) + { + #region revert mint + var to = Cache.Accounts.GetCached((int)transfer.ToId); + var toBalance = Cache.TicketBalances.Get(to.Id, ticket.Id); + + Db.TryAttach(to); + Db.TryAttach(toBalance); + + to.TicketTransfersCount--; + + toBalance.Balance -= transfer.Amount; + toBalance.TransfersCount--; + toBalance.LastLevel = block.Level; + if (toBalance.FirstLevel == block.Level) + ticketBalancesToRemove.Add(toBalance); + + ticket.TransfersCount--; + if (transfer.Amount != BigInteger.Zero) + { + if (toBalance.Balance == BigInteger.Zero) + { + to.ActiveTicketsCount--; + ticket.HoldersCount--; + } + + if (contract.Tags.HasFlag(ContractTags.Nft)) + ticket.OwnerId = null; + } + + state.TicketTransfersCount--; + #endregion + } + else + { + #region revert burn + var from = Cache.Accounts.GetCached((int)transfer.FromId); + var fromBalance = Cache.TicketBalances.Get(from.Id, ticket.Id); + + Db.TryAttach(from); + Db.TryAttach(fromBalance); + + from.TicketTransfersCount--; + + fromBalance.Balance += transfer.Amount; + fromBalance.TransfersCount--; + fromBalance.LastLevel = block.Level; + if (fromBalance.FirstLevel == block.Level) + ticketBalancesToRemove.Add(fromBalance); + + ticket.TransfersCount--; + if (transfer.Amount != BigInteger.Zero) + { + if (fromBalance.Balance == transfer.Amount) + { + from.ActiveTicketsCount++; + ticket.HoldersCount++; + } + + if (contract.Tags.HasFlag(ContractTags.Nft)) + ticket.OwnerId = from.Id; + } + + state.TicketTransfersCount--; + #endregion + } + } + + foreach (var ticketBalance in ticketBalancesToRemove) + { + if (ticketBalance.FirstLevel == block.Level) + { + Db.TicketBalances.Remove(ticketBalance); + Cache.TicketBalances.Remove(ticketBalance); + + var t = Cache.Tickets.Get(ticketBalance.TicketId); + Db.TryAttach(t); + t.BalancesCount--; + + var a = Cache.Accounts.GetCached(ticketBalance.AccountId); + Db.TryAttach(a); + a.TicketBalancesCount--; + + state.TicketBalancesCount--; + } + } + + foreach (var ticket in ticketsToRemove) + { + if (ticket.FirstLevel == block.Level) + { + Db.Tickets.Remove(ticket); + Cache.Tickets.Remove(ticket); + + var c = (Contract)Cache.Accounts.GetCached(ticket.TicketerId); + Db.TryAttach(c); + c.TicketsCount--; + + state.TicketsCount--; + } + } - throw new NotImplementedException("Revert for Tickets commit not implemented yet"); + await Db.Database.ExecuteSqlRawAsync($@"DELETE FROM ""TicketTransfers"" WHERE ""Level"" = {block.Level};"); } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index 02b14bc08..516245af1 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -233,7 +233,6 @@ public override async Task Commit(JsonElement block) var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); if (parent1.TicketUpdates != null) - //TODO Figure out behaviour for the transfer_ticket ticketsCommit.Append(parent1.Operation, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { @@ -264,6 +263,8 @@ public override async Task Commit(JsonElement block) case "smart_rollup_execute_outbox_message": var parent2 = new SmartRollupExecuteCommit(this); await parent2.Apply(blockCommit.Block, operation, content); + if (parent2.TicketUpdates != null) + ticketsCommit.Append(parent2.Operation, parent2.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult2)) { foreach (var internalContent in internalResult2.EnumerateArray()) @@ -284,6 +285,8 @@ public override async Task Commit(JsonElement block) await internalTx.ApplyInternal(blockCommit.Block, parent2.Operation, internalContent); if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); From 2b85b4d656a4bba363f335c21e4ad8eb8e096163 Mon Sep 17 00:00:00 2001 From: dmir Date: Wed, 2 Aug 2023 16:11:34 +0300 Subject: [PATCH 12/51] Revert seems working --- Makefile | 5 ++++- .../Handlers/Proto17/Commits/TicketsCommit.cs | 11 ++--------- .../Protocols/Handlers/Proto17/Proto17Handler.cs | 1 + 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index d527d69cb..b6438cff9 100644 --- a/Makefile +++ b/Makefile @@ -109,4 +109,7 @@ mumbai-stop: docker-compose -f docker-compose.mumbai.yml down mumbai-db-start: - docker-compose -f docker-compose.mumbai.yml up -d mumbai-db \ No newline at end of file + docker-compose -f docker-compose.mumbai.yml up -d mumbai-db +reset: + docker-compose -f docker-compose.nairobi.yml down --volumes + docker-compose -f docker-compose.nairobi.yml up -d nairobi-db \ No newline at end of file diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 483bf191b..6e7f25ee8 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -11,7 +11,6 @@ class TicketsCommit : ProtocolCommit public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } readonly List<(ManagerOperation op,TicketUpdate update)> Updates = new(); - // readonly List<(TransferTicketOperation op,TicketUpdate update)> Transfers = new(); public virtual void Append(ManagerOperation op, IEnumerable updates) { @@ -20,13 +19,6 @@ public virtual void Append(ManagerOperation op, IEnumerable update Updates.Add((op, update)); } } - // public virtual void Append(TransferTicketOperation op, IEnumerable updates) - // { - // foreach (var update in updates) - // { - // Transfers.Add((op, update)); - // } - // } public virtual async Task Apply() { @@ -379,7 +371,8 @@ public virtual async Task Revert(Block block) foreach (var tr in transfers) ticketsSet.Add(tr.TicketId); - await Cache.Tokens.Preload(ticketsSet); + //TODO If I throw an exception here, balances will be broken. + await Cache.Tickets.Preload(ticketsSet); foreach (var tr in transfers) { diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index 516245af1..4c06838c6 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -500,6 +500,7 @@ public override async Task Revert() await new DelegatorCycleCommit(this).Revert(currBlock); await new BakingRightsCommit(this).Revert(currBlock); await new TokensCommit(this).Revert(currBlock); + await new TicketsCommit(this).Revert(currBlock); await new BigMapCommit(this).Revert(currBlock); await new ContractEventCommit(this).Revert(currBlock); await new InboxCommit(this).Revert(currBlock); From 494ffd3cf857f6a284fdce20e5fd7d4eec9beb1c Mon Sep 17 00:00:00 2001 From: dmir Date: Sat, 5 Aug 2023 13:12:54 +0300 Subject: [PATCH 13/51] revert test --- Tzkt.Sync/Services/Observer/Observer.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Tzkt.Sync/Services/Observer/Observer.cs b/Tzkt.Sync/Services/Observer/Observer.cs index f4401f066..145ec5d7e 100644 --- a/Tzkt.Sync/Services/Observer/Observer.cs +++ b/Tzkt.Sync/Services/Observer/Observer.cs @@ -150,7 +150,12 @@ private async Task RebaseLocalBranchAsync(CancellationToken cancelToken) while (AppState.Level >= 0 && !cancelToken.IsCancellationRequested) { var header = await Node.GetHeaderAsync(AppState.Level); - if (AppState.Hash == header.Hash) break; + + var initRevert = false; + if (!initRevert) + { + if (AppState.Hash == header.Hash) break; + } Logger.LogError("Invalid head [{level}:{hash}]. Reverting...", AppState.Level, AppState.Hash); using (Metrics.Measure.Timer.Time(MetricsRegistry.RevertBlockTime)) @@ -172,8 +177,12 @@ private async Task ApplyUpdatesAsync(CancellationToken cancelToken) var header = await Node.GetHeaderAsync(); if (AppState.Level == header.Level) break; - //if (AppState.Level >= 0) - // throw new ValidationException("Test", true); + var initRevert = false; + if (initRevert) + { + if (AppState.Level >= 0) + throw new ValidationException("Test", true); + } Logger.LogDebug($"Applying block..."); using (Metrics.Measure.Timer.Time(MetricsRegistry.ApplyBlockTime)) From dc3cac62a7489548e26bc59eda0e7a4b362c27c9 Mon Sep 17 00:00:00 2001 From: dmir Date: Sat, 5 Aug 2023 19:39:04 +0300 Subject: [PATCH 14/51] revert seems fine --- .../Protocols/Handlers/Proto17/Commits/TicketsCommit.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 6e7f25ee8..9d19aa4fd 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -79,12 +79,16 @@ public virtual async Task Apply() foreach (var (op, ticketUpdates) in Updates) { + op.Block.Events |= BlockEvents.Tickets; + //TODO GetOrCreate? var ticketer = await Cache.Accounts.GetAsync(ticketUpdates.TicketToken.Ticketer); var contract = ticketer as Contract; var ticket = GetOrCreateTicket(op, contract, ticketUpdates.TicketToken); + + //TODO First, group by opHash? //TODO Match updates, if successful, transfers, if not, burns and mints foreach (var ticketUpdate in ticketUpdates.Updates) { @@ -174,7 +178,6 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic contract.TicketsCount++; Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.Tickets; return ticket; } From 6b0e2af7020aed22e5453d35883d81d3695a8453 Mon Sep 17 00:00:00 2001 From: dmir Date: Mon, 7 Aug 2023 14:11:51 +0300 Subject: [PATCH 15/51] Clean up --- .../20230717085608_ticket.Designer.cs | 6118 ---------------- Tzkt.Data/Migrations/20230717085608_ticket.cs | 87 - .../20230718133721_tickets.Designer.cs | 6124 ---------------- .../Migrations/20230718133721_tickets.cs | 50 - .../20230730143042_test.Designer.cs | 6263 ---------------- Tzkt.Data/Migrations/20230730143042_test.cs | 114 - .../20230801105851_toDelete.Designer.cs | 6266 ----------------- .../Migrations/20230801105851_toDelete.cs | 58 - ....cs => 20230807105327_tickets.Designer.cs} | 34 +- ...etUpdates.cs => 20230807105327_tickets.cs} | 78 +- .../Migrations/TzktContextModelSnapshot.cs | 39 - .../Operations/Fictive/MigrationOperation.cs | 2 +- .../Operations/TransferTicketOperation.cs | 7 - Tzkt.Data/Models/Scripts/TicketBalance.cs | 12 - .../Handlers/Proto17/Commits/TicketsCommit.cs | 14 +- .../Proto17/Diagnostics/Diagnostics.cs | 16 +- 16 files changed, 110 insertions(+), 25172 deletions(-) delete mode 100644 Tzkt.Data/Migrations/20230717085608_ticket.Designer.cs delete mode 100644 Tzkt.Data/Migrations/20230717085608_ticket.cs delete mode 100644 Tzkt.Data/Migrations/20230718133721_tickets.Designer.cs delete mode 100644 Tzkt.Data/Migrations/20230718133721_tickets.cs delete mode 100644 Tzkt.Data/Migrations/20230730143042_test.Designer.cs delete mode 100644 Tzkt.Data/Migrations/20230730143042_test.cs delete mode 100644 Tzkt.Data/Migrations/20230801105851_toDelete.Designer.cs delete mode 100644 Tzkt.Data/Migrations/20230801105851_toDelete.cs rename Tzkt.Data/Migrations/{20230718171450_ticketUpdates.Designer.cs => 20230807105327_tickets.Designer.cs} (99%) rename Tzkt.Data/Migrations/{20230718171450_ticketUpdates.cs => 20230807105327_tickets.cs} (63%) diff --git a/Tzkt.Data/Migrations/20230717085608_ticket.Designer.cs b/Tzkt.Data/Migrations/20230717085608_ticket.Designer.cs deleted file mode 100644 index b650cd0a4..000000000 --- a/Tzkt.Data/Migrations/20230717085608_ticket.Designer.cs +++ /dev/null @@ -1,6118 +0,0 @@ -// -using System; -using System.Numerics; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Tzkt.Data; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - [DbContext(typeof(TzktContext))] - [Migration("20230717085608_ticket")] - partial class ticket - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveRefutationGamesCount") - .HasColumnType("integer"); - - b.Property("ActiveTokensCount") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character varying(37)"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("ContractsCount") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegationLevel") - .HasColumnType("integer"); - - b.Property("DelegationsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageCount") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MigrationsCount") - .HasColumnType("integer"); - - b.Property("OriginationsCount") - .HasColumnType("integer"); - - b.Property("RefutationGamesCount") - .HasColumnType("integer"); - - b.Property("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesCount") - .HasColumnType("integer"); - - b.Property("SmartRollupBonds") - .HasColumnType("bigint"); - - b.Property("SmartRollupCementCount") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TransactionsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchCount") - .HasColumnType("integer"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.Property("UpdateConsensusKeyCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("DelegateId"); - - b.HasIndex("Extras"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); - - b.HasIndex("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - b.ToTable("Accounts"); - - b.HasDiscriminator("Type").HasValue((byte)3); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("ActivationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.AppState", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountCounter") - .HasColumnType("integer"); - - b.Property("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .HasColumnType("integer"); - - b.Property("BallotOpsCount") - .HasColumnType("integer"); - - b.Property("BigMapCounter") - .HasColumnType("integer"); - - b.Property("BigMapKeyCounter") - .HasColumnType("integer"); - - b.Property("BigMapUpdateCounter") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Chain") - .HasColumnType("text"); - - b.Property("ChainId") - .HasColumnType("text"); - - b.Property("CommitmentsCount") - .HasColumnType("integer"); - - b.Property("ConstantsCount") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("CyclesCount") - .HasColumnType("integer"); - - b.Property("DelegationOpsCount") - .HasColumnType("integer"); - - b.Property("DomainsLevel") - .HasColumnType("integer"); - - b.Property("DomainsNameRegistry") - .HasColumnType("text"); - - b.Property("DoubleBakingOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsementOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardOpsCount") - .HasColumnType("integer"); - - b.Property("EventCounter") - .HasColumnType("integer"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxMessageCounter") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageOpsCount") - .HasColumnType("integer"); - - b.Property("KnownHead") - .HasColumnType("integer"); - - b.Property("LastSync") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerCounter") - .HasColumnType("integer"); - - b.Property("MigrationOpsCount") - .HasColumnType("integer"); - - b.Property("NextProtocol") - .HasColumnType("text"); - - b.Property("NonceRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("OperationCounter") - .HasColumnType("bigint"); - - b.Property("OriginationOpsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("ProtocolsCount") - .HasColumnType("integer"); - - b.Property("QuoteBtc") - .HasColumnType("double precision"); - - b.Property("QuoteCny") - .HasColumnType("double precision"); - - b.Property("QuoteEth") - .HasColumnType("double precision"); - - b.Property("QuoteEur") - .HasColumnType("double precision"); - - b.Property("QuoteGbp") - .HasColumnType("double precision"); - - b.Property("QuoteJpy") - .HasColumnType("double precision"); - - b.Property("QuoteKrw") - .HasColumnType("double precision"); - - b.Property("QuoteLevel") - .HasColumnType("integer"); - - b.Property("QuoteUsd") - .HasColumnType("double precision"); - - b.Property("RefutationGameCounter") - .HasColumnType("integer"); - - b.Property("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCementOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentCounter") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TransactionOpsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchOpsCount") - .HasColumnType("integer"); - - b.Property("UpdateConsensusKeyOpsCount") - .HasColumnType("integer"); - - b.Property("VdfRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("VotingEpoch") - .HasColumnType("integer"); - - b.Property("VotingPeriod") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("AppState"); - - b.HasData( - new - { - Id = -1, - AccountCounter = 0, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DomainsLevel = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - DrainDelegateOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - InboxMessageCounter = 0, - IncreasePaidStorageOpsCount = 0, - KnownHead = 0, - LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Level = -1, - ManagerCounter = 0, - MigrationOpsCount = 0, - NextProtocol = "", - NonceRevelationOpsCount = 0, - OperationCounter = 0L, - OriginationOpsCount = 0, - PreendorsementOpsCount = 0, - ProposalOpsCount = 0, - ProposalsCount = 0, - Protocol = "", - ProtocolsCount = 0, - QuoteBtc = 0.0, - QuoteCny = 0.0, - QuoteEth = 0.0, - QuoteEur = 0.0, - QuoteGbp = 0.0, - QuoteJpy = 0.0, - QuoteKrw = 0.0, - QuoteLevel = -1, - QuoteUsd = 0.0, - RefutationGameCounter = 0, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - SmartRollupAddMessagesOpsCount = 0, - SmartRollupCementOpsCount = 0, - SmartRollupCommitmentCounter = 0, - SmartRollupExecuteOpsCount = 0, - SmartRollupOriginateOpsCount = 0, - SmartRollupPublishOpsCount = 0, - SmartRollupRecoverBondOpsCount = 0, - SmartRollupRefuteOpsCount = 0, - StorageCounter = 0, - TicketsCount = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), - TokenBalancesCount = 0, - TokenTransfersCount = 0, - TokensCount = 0, - TransactionOpsCount = 0, - TransferTicketOpsCount = 0, - TxRollupCommitOpsCount = 0, - TxRollupDispatchTicketsOpsCount = 0, - TxRollupFinalizeCommitmentOpsCount = 0, - TxRollupOriginationOpsCount = 0, - TxRollupRejectionOpsCount = 0, - TxRollupRemoveCommitmentOpsCount = 0, - TxRollupReturnBondOpsCount = 0, - TxRollupSubmitBatchOpsCount = 0, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - b.Property("FutureBlockRewards") - .HasColumnType("bigint"); - - b.Property("FutureBlocks") - .HasColumnType("integer"); - - b.Property("FutureEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("FutureEndorsements") - .HasColumnType("integer"); - - b.Property("MissedBlockFees") - .HasColumnType("bigint"); - - b.Property("MissedBlockRewards") - .HasColumnType("bigint"); - - b.Property("MissedBlocks") - .HasColumnType("integer"); - - b.Property("MissedEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("MissedEndorsements") - .HasColumnType("integer"); - - b.Property("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - b.ToTable("BakerCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Round") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("Cycle", "BakerId"); - - b.ToTable("BakingRights"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Vote") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("BallotOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("ActiveKeys") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("KeyType") - .HasColumnType("bytea"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Ptr") - .HasColumnType("integer"); - - b.Property("StoragePath") - .HasColumnType("text"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TotalKeys") - .HasColumnType("integer"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.Property("ValueType") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Ptr") - .IsUnique(); - - b.ToTable("BigMaps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("JsonKey") - .HasColumnType("jsonb"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("KeyHash") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("RawKey") - .HasColumnType("bytea"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonKey"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); - - b.HasIndex("JsonValue"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); - - b.HasIndex("LastLevel"); - - b.HasIndex("BigMapPtr", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - b.ToTable("BigMapKeys"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Action") - .HasColumnType("integer"); - - b.Property("BigMapKeyId") - .HasColumnType("integer"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Fees") - .HasColumnType("bigint"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBToggle") - .HasColumnType("boolean"); - - b.Property("LBToggleEma") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Operations") - .HasColumnType("bigint"); - - b.Property("PayloadRound") - .HasColumnType("integer"); - - b.Property("ProducerId") - .HasColumnType("integer"); - - b.Property("ProposerId") - .HasColumnType("integer"); - - b.Property("ProtoCode") - .HasColumnType("integer"); - - b.Property("ResetBakerDeactivation") - .HasColumnType("integer"); - - b.Property("ResetProposerDeactivation") - .HasColumnType("integer"); - - b.Property("RevelationId") - .HasColumnType("bigint"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Validations") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Hash") - .IsUnique(); - - b.HasIndex("Level") - .IsUnique(); - - b.HasIndex("ProducerId"); - - b.HasIndex("ProposerId"); - - b.HasIndex("ProtoCode"); - - b.HasIndex("RevelationId") - .IsUnique(); - - b.HasIndex("SoftwareId"); - - b.ToTable("Blocks"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character(37)") - .IsFixedLength(); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("Commitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("JsonPayload") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("RawPayload") - .HasColumnType("bytea"); - - b.Property("Tag") - .HasColumnType("text"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("Type") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonPayload"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("Tag"); - - b.HasIndex("TransactionId"); - - b.HasIndex("ContractCodeHash", "Tag"); - - b.HasIndex("ContractId", "Tag"); - - b.ToTable("Events"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PrevDelegateId") - .HasColumnType("integer"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("PrevDelegateId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.ToTable("DelegationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasColumnType("text"); - - b.Property("Data") - .HasColumnType("jsonb"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("Reverse") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.HasIndex("Address"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Level"); - - b.HasIndex("Name"); - - b.HasIndex("Owner"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleBakingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleEndorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoublePreendorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Fee") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("TargetId"); - - b.ToTable("DrainDelegateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("EndorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Expected") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Received") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("EndorsingRewardOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OperationId") - .HasColumnType("bigint"); - - b.Property("Payload") - .HasColumnType("bytea"); - - b.Property("PredecessorLevel") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("Type") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OperationId"); - - b.HasIndex("Type", "Id"); - - b.ToTable("InboxMessages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("IncreasePaidStorageOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("BalanceChange") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("Level"); - - b.HasIndex("ScriptId"); - - b.HasIndex("StorageId"); - - b.ToTable("MigrationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RevealedCycle") - .HasColumnType("integer"); - - b.Property("RevealedLevel") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RevealedCycle"); - - b.HasIndex("SenderId"); - - b.ToTable("NonceRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash") - .HasFilter("\"ContractCodeHash\" IS NOT NULL"); - - b.HasIndex("ContractId"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("ManagerId"); - - b.HasIndex("OpHash"); - - b.HasIndex("ScriptId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.ToTable("OriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("PreendorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - b.ToTable("Proposals"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Duplicated") - .HasColumnType("boolean"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("ProposalOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotQuorumMax") - .HasColumnType("integer"); - - b.Property("BallotQuorumMin") - .HasColumnType("integer"); - - b.Property("BlockDeposit") - .HasColumnType("bigint"); - - b.Property("BlockReward0") - .HasColumnType("bigint"); - - b.Property("BlockReward1") - .HasColumnType("bigint"); - - b.Property("BlocksPerCommitment") - .HasColumnType("integer"); - - b.Property("BlocksPerCycle") - .HasColumnType("integer"); - - b.Property("BlocksPerSnapshot") - .HasColumnType("integer"); - - b.Property("BlocksPerVoting") - .HasColumnType("integer"); - - b.Property("ByteCost") - .HasColumnType("integer"); - - b.Property("Code") - .HasColumnType("integer"); - - b.Property("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - - b.Property("HardBlockGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationStorageLimit") - .HasColumnType("integer"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupChallengeWindow") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentPeriod") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginationSize") - .HasColumnType("integer"); - - b.Property("SmartRollupStakeAmount") - .HasColumnType("bigint"); - - b.Property("SmartRollupTimeoutPeriod") - .HasColumnType("integer"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Protocols"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Btc") - .HasColumnType("double precision"); - - b.Property("Cny") - .HasColumnType("double precision"); - - b.Property("Eth") - .HasColumnType("double precision"); - - b.Property("Eur") - .HasColumnType("double precision"); - - b.Property("Gbp") - .HasColumnType("double precision"); - - b.Property("Jpy") - .HasColumnType("double precision"); - - b.Property("Krw") - .HasColumnType("double precision"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Usd") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Quotes"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("InitiatorCommitmentId") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InitiatorLoss") - .HasColumnType("bigint"); - - b.Property("InitiatorReward") - .HasColumnType("bigint"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("LastMoveId") - .HasColumnType("bigint"); - - b.Property("OpponentCommitmentId") - .HasColumnType("integer"); - - b.Property("OpponentId") - .HasColumnType("integer"); - - b.Property("OpponentLoss") - .HasColumnType("bigint"); - - b.Property("OpponentReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("InitiatorCommitmentId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("LastLevel"); - - b.HasIndex("OpponentCommitmentId"); - - b.HasIndex("OpponentId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("RefutationGames"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("Refs") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Value") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique() - .HasFilter("\"Address\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RegisterConstantOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RevealOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("MissedLevel") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("RevelationPenaltyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Script", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CodeSchema") - .HasColumnType("bytea"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ParameterSchema") - .HasColumnType("bytea"); - - b.Property("StorageSchema") - .HasColumnType("bytea"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("Views") - .HasColumnType("bytea[]"); - - b.HasKey("Id"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Limit") - .HasColumnType("text"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SetDepositsLimitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MessagesCount") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupAddMessagesOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupCementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("PredecessorId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Stakers") - .HasColumnType("integer"); - - b.Property("State") - .HasColumnType("text"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Successors") - .HasColumnType("integer"); - - b.Property("Ticks") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Hash"); - - b.HasIndex("InboxLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("PredecessorId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("Hash", "SmartRollupId"); - - b.ToTable("SmartRollupCommitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupExecuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("Kernel") - .HasColumnType("bytea"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("OriginationProof") - .HasColumnType("bytea"); - - b.Property("ParameterType") - .HasColumnType("bytea"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupOriginateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("BondStatus") - .HasColumnType("integer"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Flags") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("SmartRollupId", "BondStatus", "SenderId") - .HasFilter("\"BondStatus\" IS NOT NULL"); - - b.ToTable("SmartRollupPublishOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("StakerId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("StakerId"); - - b.ToTable("SmartRollupRecoverBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DissectionEnd") - .HasColumnType("bigint"); - - b.Property("DissectionStart") - .HasColumnType("bigint"); - - b.Property("DissectionSteps") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GameId") - .HasColumnType("integer"); - - b.Property("GameStatus") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Move") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("GameId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupRefuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - b.ToTable("SnapshotBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("TotalActivated") - .HasColumnType("bigint"); - - b.Property("TotalBanished") - .HasColumnType("bigint"); - - b.Property("TotalBootstrapped") - .HasColumnType("bigint"); - - b.Property("TotalBurned") - .HasColumnType("bigint"); - - b.Property("TotalCommitments") - .HasColumnType("bigint"); - - b.Property("TotalCreated") - .HasColumnType("bigint"); - - b.Property("TotalFrozen") - .HasColumnType("bigint"); - - b.Property("TotalRollupBonds") - .HasColumnType("bigint"); - - b.Property("TotalSmartRollupBonds") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle") - .IsUnique() - .HasFilter("\"Cycle\" IS NOT NULL"); - - b.HasIndex("Date") - .IsUnique() - .HasFilter("\"Date\" IS NOT NULL"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Storage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("TicketId") - .HasColumnType("numeric"); - - b.Property("TotalBurned") - .HasColumnType("numeric"); - - b.Property("TotalMinted") - .HasColumnType("numeric"); - - b.Property("TotalSupply") - .HasColumnType("numeric"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Token", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("ContractId", "TokenId") - .IsUnique(); - - b.ToTable("Tokens"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); - - b.HasIndex("TokenId"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("TokenTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InternalDelegations") - .HasColumnType("smallint"); - - b.Property("InternalOperations") - .HasColumnType("smallint"); - - b.Property("InternalOriginations") - .HasColumnType("smallint"); - - b.Property("InternalTransactions") - .HasColumnType("smallint"); - - b.Property("JsonParameters") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawParameters") - .HasColumnType("bytea"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("TargetCodeHash") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("JsonParameters"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.HasIndex("TargetCodeHash") - .HasFilter("\"TargetCodeHash\" IS NOT NULL"); - - b.HasIndex("TargetId"); - - b.ToTable("TransactionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("JsonContent") - .HasColumnType("text"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawContent") - .HasColumnType("bytea"); - - b.Property("RawType") - .HasColumnType("bytea"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("TargetId"); - - b.HasIndex("TicketerId"); - - b.ToTable("TransferTicketOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupCommitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupDispatchTicketsOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupFinalizeCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupOriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitterId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitterId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRejectionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRemoveCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupReturnBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupSubmitBatchOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActivationCycle") - .HasColumnType("integer"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("PublicKeyHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("UpdateConsensusKeyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Proof") - .HasColumnType("bytea"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotsQuorum") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("integer"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("NayBallots") - .HasColumnType("integer"); - - b.Property("NayVotingPower") - .HasColumnType("bigint"); - - b.Property("ParticipationEma") - .HasColumnType("integer"); - - b.Property("PassBallots") - .HasColumnType("integer"); - - b.Property("PassVotingPower") - .HasColumnType("bigint"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("SingleWinner") - .HasColumnType("boolean"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Supermajority") - .HasColumnType("integer"); - - b.Property("TopUpvotes") - .HasColumnType("integer"); - - b.Property("TopVotingPower") - .HasColumnType("bigint"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalVotingPower") - .HasColumnType("bigint"); - - b.Property("UpvotesQuorum") - .HasColumnType("integer"); - - b.Property("YayBallots") - .HasColumnType("integer"); - - b.Property("YayVotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("VotingPeriods"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Period"); - - b.HasIndex("Period", "BakerId") - .IsUnique(); - - b.ToTable("VotingSnapshots"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("smallint"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Spendable") - .HasColumnType("boolean"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("WeirdDelegateId") - .HasColumnType("integer"); - - b.HasIndex("CodeHash"); - - b.HasIndex("CreatorId"); - - b.HasIndex("ManagerId"); - - b.HasIndex("TypeHash"); - - b.HasIndex("WeirdDelegateId"); - - b.HasIndex("Type", "Kind") - .HasFilter("\"Type\" = 2"); - - b.HasDiscriminator().HasValue((byte)2); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)4); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("CementedCommitments") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("ExecutedCommitments") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("LastCommitment") - .HasColumnType("text"); - - b.Property("OrphanCommitments") - .HasColumnType("integer"); - - b.Property("PendingCommitments") - .HasColumnType("integer"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("RefutedCommitments") - .HasColumnType("integer"); - - b.Property("TotalStakers") - .HasColumnType("integer"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)5); - }); - - modelBuilder.Entity("Tzkt.Data.Models.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - b.HasDiscriminator().HasValue((byte)0); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasBaseType("Tzkt.Data.Models.User"); - - b.Property("ActivationLevel") - .HasColumnType("integer"); - - b.Property("BallotsCount") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("DeactivationLevel") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingCount") - .HasColumnType("integer"); - - b.Property("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .HasFilter("\"Type\" = 1"); - - b.HasDiscriminator().HasValue((byte)1); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany("DelegatedAccounts") - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") - .WithMany("CreatedAccounts") - .HasForeignKey("FirstLevel") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Delegate"); - - b.Navigation("FirstBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.HasOne("Tzkt.Data.Models.User", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Activations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Ballots") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") - .WithMany() - .HasForeignKey("ProposerId"); - - b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") - .WithMany() - .HasForeignKey("ProtoCode") - .HasPrincipalKey("Code") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") - .WithOne("RevealedBlock") - .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); - - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Proposer"); - - b.Navigation("Protocol"); - - b.Navigation("Revelation"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Delegations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") - .WithMany() - .HasForeignKey("PrevDelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("PrevDelegate"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleBakings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleEndorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoublePreendorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DrainDelegateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Endorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("IncreasePaidStorageOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Migrations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Account"); - - b.Navigation("Block"); - - b.Navigation("Script"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Revelations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Contract", "Contract") - .WithMany() - .HasForeignKey("ContractId"); - - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Originations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Block"); - - b.Navigation("Contract"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("Manager"); - - b.Navigation("Script"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Preendorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Proposals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RegisterConstants") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Reveals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RevelationPenalties") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SetDepositsLimits") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupAddMessagesOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupCementOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupExecuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupOriginateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupPublishOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRecoverBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRefuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Transactions") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.HasOne("Tzkt.Data.Models.Account", "Target") - .WithMany() - .HasForeignKey("TargetId"); - - b.Navigation("Block"); - - b.Navigation("Initiator"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - - b.Navigation("Target"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TransferTicketOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - - b.Navigation("Ticketer"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupCommitOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupDispatchTicketsOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupFinalizeCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupOriginationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRejectionOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRemoveCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupReturnBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupSubmitBatchOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("UpdateConsensusKeyOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("VdfRevelationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Creator") - .WithMany() - .HasForeignKey("CreatorId"); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") - .WithMany() - .HasForeignKey("WeirdDelegateId"); - - b.Navigation("Creator"); - - b.Navigation("Manager"); - - b.Navigation("WeirdDelegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Navigation("Activations"); - - b.Navigation("Ballots"); - - b.Navigation("CreatedAccounts"); - - b.Navigation("Delegations"); - - b.Navigation("DoubleBakings"); - - b.Navigation("DoubleEndorsings"); - - b.Navigation("DoublePreendorsings"); - - b.Navigation("DrainDelegateOps"); - - b.Navigation("Endorsements"); - - b.Navigation("IncreasePaidStorageOps"); - - b.Navigation("Migrations"); - - b.Navigation("Originations"); - - b.Navigation("Preendorsements"); - - b.Navigation("Proposals"); - - b.Navigation("RegisterConstants"); - - b.Navigation("Reveals"); - - b.Navigation("RevelationPenalties"); - - b.Navigation("Revelations"); - - b.Navigation("SetDepositsLimits"); - - b.Navigation("SmartRollupAddMessagesOps"); - - b.Navigation("SmartRollupCementOps"); - - b.Navigation("SmartRollupExecuteOps"); - - b.Navigation("SmartRollupOriginateOps"); - - b.Navigation("SmartRollupPublishOps"); - - b.Navigation("SmartRollupRecoverBondOps"); - - b.Navigation("SmartRollupRefuteOps"); - - b.Navigation("Transactions"); - - b.Navigation("TransferTicketOps"); - - b.Navigation("TxRollupCommitOps"); - - b.Navigation("TxRollupDispatchTicketsOps"); - - b.Navigation("TxRollupFinalizeCommitmentOps"); - - b.Navigation("TxRollupOriginationOps"); - - b.Navigation("TxRollupRejectionOps"); - - b.Navigation("TxRollupRemoveCommitmentOps"); - - b.Navigation("TxRollupReturnBondOps"); - - b.Navigation("TxRollupSubmitBatchOps"); - - b.Navigation("UpdateConsensusKeyOps"); - - b.Navigation("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Navigation("RevealedBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.Navigation("DelegatedAccounts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Tzkt.Data/Migrations/20230717085608_ticket.cs b/Tzkt.Data/Migrations/20230717085608_ticket.cs deleted file mode 100644 index 789a721ac..000000000 --- a/Tzkt.Data/Migrations/20230717085608_ticket.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System.Numerics; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class ticket : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "TicketsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketsCount", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.CreateTable( - name: "Tickets", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - ContractId = table.Column(type: "integer", nullable: false), - TicketId = table.Column(type: "numeric", nullable: false), - FirstMinterId = table.Column(type: "integer", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - TransfersCount = table.Column(type: "integer", nullable: false), - BalancesCount = table.Column(type: "integer", nullable: false), - HoldersCount = table.Column(type: "integer", nullable: false), - TotalMinted = table.Column(type: "numeric", nullable: false), - TotalBurned = table.Column(type: "numeric", nullable: false), - TotalSupply = table.Column(type: "numeric", nullable: false), - OwnerId = table.Column(type: "integer", nullable: true), - IndexedAt = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Tickets", x => x.Id); - }); - - migrationBuilder.UpdateData( - table: "AppState", - keyColumn: "Id", - keyValue: -1, - column: "TicketsCount", - value: 0); - - migrationBuilder.AddForeignKey( - name: "FK_TransferTicketOps_Accounts_TicketerId", - table: "TransferTicketOps", - column: "TicketerId", - principalTable: "Accounts", - principalColumn: "Id"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_TransferTicketOps_Accounts_TicketerId", - table: "TransferTicketOps"); - - migrationBuilder.DropTable( - name: "Tickets"); - - migrationBuilder.DropColumn( - name: "TicketsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "TicketsCount", - table: "Accounts"); - } - } -} diff --git a/Tzkt.Data/Migrations/20230718133721_tickets.Designer.cs b/Tzkt.Data/Migrations/20230718133721_tickets.Designer.cs deleted file mode 100644 index 7097afaa4..000000000 --- a/Tzkt.Data/Migrations/20230718133721_tickets.Designer.cs +++ /dev/null @@ -1,6124 +0,0 @@ -// -using System; -using System.Numerics; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Tzkt.Data; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - [DbContext(typeof(TzktContext))] - [Migration("20230718133721_tickets")] - partial class tickets - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveRefutationGamesCount") - .HasColumnType("integer"); - - b.Property("ActiveTokensCount") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character varying(37)"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("ContractsCount") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegationLevel") - .HasColumnType("integer"); - - b.Property("DelegationsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageCount") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MigrationsCount") - .HasColumnType("integer"); - - b.Property("OriginationsCount") - .HasColumnType("integer"); - - b.Property("RefutationGamesCount") - .HasColumnType("integer"); - - b.Property("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesCount") - .HasColumnType("integer"); - - b.Property("SmartRollupBonds") - .HasColumnType("bigint"); - - b.Property("SmartRollupCementCount") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TransactionsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchCount") - .HasColumnType("integer"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.Property("UpdateConsensusKeyCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("DelegateId"); - - b.HasIndex("Extras"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); - - b.HasIndex("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - b.ToTable("Accounts"); - - b.HasDiscriminator("Type").HasValue((byte)3); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("ActivationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.AppState", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountCounter") - .HasColumnType("integer"); - - b.Property("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .HasColumnType("integer"); - - b.Property("BallotOpsCount") - .HasColumnType("integer"); - - b.Property("BigMapCounter") - .HasColumnType("integer"); - - b.Property("BigMapKeyCounter") - .HasColumnType("integer"); - - b.Property("BigMapUpdateCounter") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Chain") - .HasColumnType("text"); - - b.Property("ChainId") - .HasColumnType("text"); - - b.Property("CommitmentsCount") - .HasColumnType("integer"); - - b.Property("ConstantsCount") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("CyclesCount") - .HasColumnType("integer"); - - b.Property("DelegationOpsCount") - .HasColumnType("integer"); - - b.Property("DomainsLevel") - .HasColumnType("integer"); - - b.Property("DomainsNameRegistry") - .HasColumnType("text"); - - b.Property("DoubleBakingOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsementOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardOpsCount") - .HasColumnType("integer"); - - b.Property("EventCounter") - .HasColumnType("integer"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxMessageCounter") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageOpsCount") - .HasColumnType("integer"); - - b.Property("KnownHead") - .HasColumnType("integer"); - - b.Property("LastSync") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerCounter") - .HasColumnType("integer"); - - b.Property("MigrationOpsCount") - .HasColumnType("integer"); - - b.Property("NextProtocol") - .HasColumnType("text"); - - b.Property("NonceRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("OperationCounter") - .HasColumnType("bigint"); - - b.Property("OriginationOpsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("ProtocolsCount") - .HasColumnType("integer"); - - b.Property("QuoteBtc") - .HasColumnType("double precision"); - - b.Property("QuoteCny") - .HasColumnType("double precision"); - - b.Property("QuoteEth") - .HasColumnType("double precision"); - - b.Property("QuoteEur") - .HasColumnType("double precision"); - - b.Property("QuoteGbp") - .HasColumnType("double precision"); - - b.Property("QuoteJpy") - .HasColumnType("double precision"); - - b.Property("QuoteKrw") - .HasColumnType("double precision"); - - b.Property("QuoteLevel") - .HasColumnType("integer"); - - b.Property("QuoteUsd") - .HasColumnType("double precision"); - - b.Property("RefutationGameCounter") - .HasColumnType("integer"); - - b.Property("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCementOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentCounter") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TransactionOpsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchOpsCount") - .HasColumnType("integer"); - - b.Property("UpdateConsensusKeyOpsCount") - .HasColumnType("integer"); - - b.Property("VdfRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("VotingEpoch") - .HasColumnType("integer"); - - b.Property("VotingPeriod") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("AppState"); - - b.HasData( - new - { - Id = -1, - AccountCounter = 0, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DomainsLevel = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - DrainDelegateOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - InboxMessageCounter = 0, - IncreasePaidStorageOpsCount = 0, - KnownHead = 0, - LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Level = -1, - ManagerCounter = 0, - MigrationOpsCount = 0, - NextProtocol = "", - NonceRevelationOpsCount = 0, - OperationCounter = 0L, - OriginationOpsCount = 0, - PreendorsementOpsCount = 0, - ProposalOpsCount = 0, - ProposalsCount = 0, - Protocol = "", - ProtocolsCount = 0, - QuoteBtc = 0.0, - QuoteCny = 0.0, - QuoteEth = 0.0, - QuoteEur = 0.0, - QuoteGbp = 0.0, - QuoteJpy = 0.0, - QuoteKrw = 0.0, - QuoteLevel = -1, - QuoteUsd = 0.0, - RefutationGameCounter = 0, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - SmartRollupAddMessagesOpsCount = 0, - SmartRollupCementOpsCount = 0, - SmartRollupCommitmentCounter = 0, - SmartRollupExecuteOpsCount = 0, - SmartRollupOriginateOpsCount = 0, - SmartRollupPublishOpsCount = 0, - SmartRollupRecoverBondOpsCount = 0, - SmartRollupRefuteOpsCount = 0, - StorageCounter = 0, - TicketsCount = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), - TokenBalancesCount = 0, - TokenTransfersCount = 0, - TokensCount = 0, - TransactionOpsCount = 0, - TransferTicketOpsCount = 0, - TxRollupCommitOpsCount = 0, - TxRollupDispatchTicketsOpsCount = 0, - TxRollupFinalizeCommitmentOpsCount = 0, - TxRollupOriginationOpsCount = 0, - TxRollupRejectionOpsCount = 0, - TxRollupRemoveCommitmentOpsCount = 0, - TxRollupReturnBondOpsCount = 0, - TxRollupSubmitBatchOpsCount = 0, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - b.Property("FutureBlockRewards") - .HasColumnType("bigint"); - - b.Property("FutureBlocks") - .HasColumnType("integer"); - - b.Property("FutureEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("FutureEndorsements") - .HasColumnType("integer"); - - b.Property("MissedBlockFees") - .HasColumnType("bigint"); - - b.Property("MissedBlockRewards") - .HasColumnType("bigint"); - - b.Property("MissedBlocks") - .HasColumnType("integer"); - - b.Property("MissedEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("MissedEndorsements") - .HasColumnType("integer"); - - b.Property("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - b.ToTable("BakerCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Round") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("Cycle", "BakerId"); - - b.ToTable("BakingRights"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Vote") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("BallotOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("ActiveKeys") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("KeyType") - .HasColumnType("bytea"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Ptr") - .HasColumnType("integer"); - - b.Property("StoragePath") - .HasColumnType("text"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TotalKeys") - .HasColumnType("integer"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.Property("ValueType") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Ptr") - .IsUnique(); - - b.ToTable("BigMaps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("JsonKey") - .HasColumnType("jsonb"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("KeyHash") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("RawKey") - .HasColumnType("bytea"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonKey"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); - - b.HasIndex("JsonValue"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); - - b.HasIndex("LastLevel"); - - b.HasIndex("BigMapPtr", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - b.ToTable("BigMapKeys"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Action") - .HasColumnType("integer"); - - b.Property("BigMapKeyId") - .HasColumnType("integer"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Fees") - .HasColumnType("bigint"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBToggle") - .HasColumnType("boolean"); - - b.Property("LBToggleEma") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Operations") - .HasColumnType("bigint"); - - b.Property("PayloadRound") - .HasColumnType("integer"); - - b.Property("ProducerId") - .HasColumnType("integer"); - - b.Property("ProposerId") - .HasColumnType("integer"); - - b.Property("ProtoCode") - .HasColumnType("integer"); - - b.Property("ResetBakerDeactivation") - .HasColumnType("integer"); - - b.Property("ResetProposerDeactivation") - .HasColumnType("integer"); - - b.Property("RevelationId") - .HasColumnType("bigint"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Validations") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Hash") - .IsUnique(); - - b.HasIndex("Level") - .IsUnique(); - - b.HasIndex("ProducerId"); - - b.HasIndex("ProposerId"); - - b.HasIndex("ProtoCode"); - - b.HasIndex("RevelationId") - .IsUnique(); - - b.HasIndex("SoftwareId"); - - b.ToTable("Blocks"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character(37)") - .IsFixedLength(); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("Commitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("JsonPayload") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("RawPayload") - .HasColumnType("bytea"); - - b.Property("Tag") - .HasColumnType("text"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("Type") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonPayload"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("Tag"); - - b.HasIndex("TransactionId"); - - b.HasIndex("ContractCodeHash", "Tag"); - - b.HasIndex("ContractId", "Tag"); - - b.ToTable("Events"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PrevDelegateId") - .HasColumnType("integer"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("PrevDelegateId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.ToTable("DelegationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasColumnType("text"); - - b.Property("Data") - .HasColumnType("jsonb"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("Reverse") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.HasIndex("Address"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Level"); - - b.HasIndex("Name"); - - b.HasIndex("Owner"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleBakingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleEndorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoublePreendorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Fee") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("TargetId"); - - b.ToTable("DrainDelegateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("EndorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Expected") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Received") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("EndorsingRewardOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OperationId") - .HasColumnType("bigint"); - - b.Property("Payload") - .HasColumnType("bytea"); - - b.Property("PredecessorLevel") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("Type") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OperationId"); - - b.HasIndex("Type", "Id"); - - b.ToTable("InboxMessages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("IncreasePaidStorageOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("BalanceChange") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("Level"); - - b.HasIndex("ScriptId"); - - b.HasIndex("StorageId"); - - b.ToTable("MigrationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RevealedCycle") - .HasColumnType("integer"); - - b.Property("RevealedLevel") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RevealedCycle"); - - b.HasIndex("SenderId"); - - b.ToTable("NonceRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash") - .HasFilter("\"ContractCodeHash\" IS NOT NULL"); - - b.HasIndex("ContractId"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("ManagerId"); - - b.HasIndex("OpHash"); - - b.HasIndex("ScriptId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.ToTable("OriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("PreendorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - b.ToTable("Proposals"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Duplicated") - .HasColumnType("boolean"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("ProposalOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotQuorumMax") - .HasColumnType("integer"); - - b.Property("BallotQuorumMin") - .HasColumnType("integer"); - - b.Property("BlockDeposit") - .HasColumnType("bigint"); - - b.Property("BlockReward0") - .HasColumnType("bigint"); - - b.Property("BlockReward1") - .HasColumnType("bigint"); - - b.Property("BlocksPerCommitment") - .HasColumnType("integer"); - - b.Property("BlocksPerCycle") - .HasColumnType("integer"); - - b.Property("BlocksPerSnapshot") - .HasColumnType("integer"); - - b.Property("BlocksPerVoting") - .HasColumnType("integer"); - - b.Property("ByteCost") - .HasColumnType("integer"); - - b.Property("Code") - .HasColumnType("integer"); - - b.Property("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - - b.Property("HardBlockGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationStorageLimit") - .HasColumnType("integer"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupChallengeWindow") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentPeriod") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginationSize") - .HasColumnType("integer"); - - b.Property("SmartRollupStakeAmount") - .HasColumnType("bigint"); - - b.Property("SmartRollupTimeoutPeriod") - .HasColumnType("integer"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Protocols"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Btc") - .HasColumnType("double precision"); - - b.Property("Cny") - .HasColumnType("double precision"); - - b.Property("Eth") - .HasColumnType("double precision"); - - b.Property("Eur") - .HasColumnType("double precision"); - - b.Property("Gbp") - .HasColumnType("double precision"); - - b.Property("Jpy") - .HasColumnType("double precision"); - - b.Property("Krw") - .HasColumnType("double precision"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Usd") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Quotes"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("InitiatorCommitmentId") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InitiatorLoss") - .HasColumnType("bigint"); - - b.Property("InitiatorReward") - .HasColumnType("bigint"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("LastMoveId") - .HasColumnType("bigint"); - - b.Property("OpponentCommitmentId") - .HasColumnType("integer"); - - b.Property("OpponentId") - .HasColumnType("integer"); - - b.Property("OpponentLoss") - .HasColumnType("bigint"); - - b.Property("OpponentReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("InitiatorCommitmentId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("LastLevel"); - - b.HasIndex("OpponentCommitmentId"); - - b.HasIndex("OpponentId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("RefutationGames"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("Refs") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Value") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique() - .HasFilter("\"Address\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RegisterConstantOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RevealOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("MissedLevel") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("RevelationPenaltyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Script", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CodeSchema") - .HasColumnType("bytea"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ParameterSchema") - .HasColumnType("bytea"); - - b.Property("StorageSchema") - .HasColumnType("bytea"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("Views") - .HasColumnType("bytea[]"); - - b.HasKey("Id"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Limit") - .HasColumnType("text"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SetDepositsLimitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MessagesCount") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupAddMessagesOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupCementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("PredecessorId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Stakers") - .HasColumnType("integer"); - - b.Property("State") - .HasColumnType("text"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Successors") - .HasColumnType("integer"); - - b.Property("Ticks") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Hash"); - - b.HasIndex("InboxLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("PredecessorId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("Hash", "SmartRollupId"); - - b.ToTable("SmartRollupCommitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupExecuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("Kernel") - .HasColumnType("bytea"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("OriginationProof") - .HasColumnType("bytea"); - - b.Property("ParameterType") - .HasColumnType("bytea"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupOriginateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("BondStatus") - .HasColumnType("integer"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Flags") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("SmartRollupId", "BondStatus", "SenderId") - .HasFilter("\"BondStatus\" IS NOT NULL"); - - b.ToTable("SmartRollupPublishOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("StakerId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("StakerId"); - - b.ToTable("SmartRollupRecoverBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DissectionEnd") - .HasColumnType("bigint"); - - b.Property("DissectionStart") - .HasColumnType("bigint"); - - b.Property("DissectionSteps") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GameId") - .HasColumnType("integer"); - - b.Property("GameStatus") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Move") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("GameId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupRefuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - b.ToTable("SnapshotBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("TotalActivated") - .HasColumnType("bigint"); - - b.Property("TotalBanished") - .HasColumnType("bigint"); - - b.Property("TotalBootstrapped") - .HasColumnType("bigint"); - - b.Property("TotalBurned") - .HasColumnType("bigint"); - - b.Property("TotalCommitments") - .HasColumnType("bigint"); - - b.Property("TotalCreated") - .HasColumnType("bigint"); - - b.Property("TotalFrozen") - .HasColumnType("bigint"); - - b.Property("TotalRollupBonds") - .HasColumnType("bigint"); - - b.Property("TotalSmartRollupBonds") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle") - .IsUnique() - .HasFilter("\"Cycle\" IS NOT NULL"); - - b.HasIndex("Date") - .IsUnique() - .HasFilter("\"Date\" IS NOT NULL"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Storage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContentHash") - .HasColumnType("integer"); - - b.Property("ContentTypeHash") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("TicketId") - .HasColumnType("numeric"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TotalBurned") - .HasColumnType("numeric"); - - b.Property("TotalMinted") - .HasColumnType("numeric"); - - b.Property("TotalSupply") - .HasColumnType("numeric"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Token", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("ContractId", "TokenId") - .IsUnique(); - - b.ToTable("Tokens"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); - - b.HasIndex("TokenId"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("TokenTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InternalDelegations") - .HasColumnType("smallint"); - - b.Property("InternalOperations") - .HasColumnType("smallint"); - - b.Property("InternalOriginations") - .HasColumnType("smallint"); - - b.Property("InternalTransactions") - .HasColumnType("smallint"); - - b.Property("JsonParameters") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawParameters") - .HasColumnType("bytea"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("TargetCodeHash") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("JsonParameters"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.HasIndex("TargetCodeHash") - .HasFilter("\"TargetCodeHash\" IS NOT NULL"); - - b.HasIndex("TargetId"); - - b.ToTable("TransactionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("JsonContent") - .HasColumnType("text"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawContent") - .HasColumnType("bytea"); - - b.Property("RawType") - .HasColumnType("bytea"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("TargetId"); - - b.HasIndex("TicketerId"); - - b.ToTable("TransferTicketOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupCommitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupDispatchTicketsOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupFinalizeCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupOriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitterId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitterId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRejectionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRemoveCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupReturnBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupSubmitBatchOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActivationCycle") - .HasColumnType("integer"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("PublicKeyHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("UpdateConsensusKeyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Proof") - .HasColumnType("bytea"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotsQuorum") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("integer"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("NayBallots") - .HasColumnType("integer"); - - b.Property("NayVotingPower") - .HasColumnType("bigint"); - - b.Property("ParticipationEma") - .HasColumnType("integer"); - - b.Property("PassBallots") - .HasColumnType("integer"); - - b.Property("PassVotingPower") - .HasColumnType("bigint"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("SingleWinner") - .HasColumnType("boolean"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Supermajority") - .HasColumnType("integer"); - - b.Property("TopUpvotes") - .HasColumnType("integer"); - - b.Property("TopVotingPower") - .HasColumnType("bigint"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalVotingPower") - .HasColumnType("bigint"); - - b.Property("UpvotesQuorum") - .HasColumnType("integer"); - - b.Property("YayBallots") - .HasColumnType("integer"); - - b.Property("YayVotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("VotingPeriods"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Period"); - - b.HasIndex("Period", "BakerId") - .IsUnique(); - - b.ToTable("VotingSnapshots"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("smallint"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Spendable") - .HasColumnType("boolean"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("WeirdDelegateId") - .HasColumnType("integer"); - - b.HasIndex("CodeHash"); - - b.HasIndex("CreatorId"); - - b.HasIndex("ManagerId"); - - b.HasIndex("TypeHash"); - - b.HasIndex("WeirdDelegateId"); - - b.HasIndex("Type", "Kind") - .HasFilter("\"Type\" = 2"); - - b.HasDiscriminator().HasValue((byte)2); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)4); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("CementedCommitments") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("ExecutedCommitments") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("LastCommitment") - .HasColumnType("text"); - - b.Property("OrphanCommitments") - .HasColumnType("integer"); - - b.Property("PendingCommitments") - .HasColumnType("integer"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("RefutedCommitments") - .HasColumnType("integer"); - - b.Property("TotalStakers") - .HasColumnType("integer"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)5); - }); - - modelBuilder.Entity("Tzkt.Data.Models.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - b.HasDiscriminator().HasValue((byte)0); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasBaseType("Tzkt.Data.Models.User"); - - b.Property("ActivationLevel") - .HasColumnType("integer"); - - b.Property("BallotsCount") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("DeactivationLevel") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingCount") - .HasColumnType("integer"); - - b.Property("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .HasFilter("\"Type\" = 1"); - - b.HasDiscriminator().HasValue((byte)1); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany("DelegatedAccounts") - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") - .WithMany("CreatedAccounts") - .HasForeignKey("FirstLevel") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Delegate"); - - b.Navigation("FirstBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.HasOne("Tzkt.Data.Models.User", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Activations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Ballots") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") - .WithMany() - .HasForeignKey("ProposerId"); - - b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") - .WithMany() - .HasForeignKey("ProtoCode") - .HasPrincipalKey("Code") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") - .WithOne("RevealedBlock") - .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); - - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Proposer"); - - b.Navigation("Protocol"); - - b.Navigation("Revelation"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Delegations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") - .WithMany() - .HasForeignKey("PrevDelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("PrevDelegate"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleBakings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleEndorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoublePreendorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DrainDelegateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Endorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("IncreasePaidStorageOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Migrations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Account"); - - b.Navigation("Block"); - - b.Navigation("Script"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Revelations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Contract", "Contract") - .WithMany() - .HasForeignKey("ContractId"); - - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Originations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Block"); - - b.Navigation("Contract"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("Manager"); - - b.Navigation("Script"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Preendorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Proposals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RegisterConstants") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Reveals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RevelationPenalties") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SetDepositsLimits") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupAddMessagesOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupCementOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupExecuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupOriginateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupPublishOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRecoverBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRefuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Transactions") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.HasOne("Tzkt.Data.Models.Account", "Target") - .WithMany() - .HasForeignKey("TargetId"); - - b.Navigation("Block"); - - b.Navigation("Initiator"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - - b.Navigation("Target"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TransferTicketOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - - b.Navigation("Ticketer"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupCommitOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupDispatchTicketsOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupFinalizeCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupOriginationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRejectionOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRemoveCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupReturnBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupSubmitBatchOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("UpdateConsensusKeyOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("VdfRevelationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Creator") - .WithMany() - .HasForeignKey("CreatorId"); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") - .WithMany() - .HasForeignKey("WeirdDelegateId"); - - b.Navigation("Creator"); - - b.Navigation("Manager"); - - b.Navigation("WeirdDelegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Navigation("Activations"); - - b.Navigation("Ballots"); - - b.Navigation("CreatedAccounts"); - - b.Navigation("Delegations"); - - b.Navigation("DoubleBakings"); - - b.Navigation("DoubleEndorsings"); - - b.Navigation("DoublePreendorsings"); - - b.Navigation("DrainDelegateOps"); - - b.Navigation("Endorsements"); - - b.Navigation("IncreasePaidStorageOps"); - - b.Navigation("Migrations"); - - b.Navigation("Originations"); - - b.Navigation("Preendorsements"); - - b.Navigation("Proposals"); - - b.Navigation("RegisterConstants"); - - b.Navigation("Reveals"); - - b.Navigation("RevelationPenalties"); - - b.Navigation("Revelations"); - - b.Navigation("SetDepositsLimits"); - - b.Navigation("SmartRollupAddMessagesOps"); - - b.Navigation("SmartRollupCementOps"); - - b.Navigation("SmartRollupExecuteOps"); - - b.Navigation("SmartRollupOriginateOps"); - - b.Navigation("SmartRollupPublishOps"); - - b.Navigation("SmartRollupRecoverBondOps"); - - b.Navigation("SmartRollupRefuteOps"); - - b.Navigation("Transactions"); - - b.Navigation("TransferTicketOps"); - - b.Navigation("TxRollupCommitOps"); - - b.Navigation("TxRollupDispatchTicketsOps"); - - b.Navigation("TxRollupFinalizeCommitmentOps"); - - b.Navigation("TxRollupOriginationOps"); - - b.Navigation("TxRollupRejectionOps"); - - b.Navigation("TxRollupRemoveCommitmentOps"); - - b.Navigation("TxRollupReturnBondOps"); - - b.Navigation("TxRollupSubmitBatchOps"); - - b.Navigation("UpdateConsensusKeyOps"); - - b.Navigation("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Navigation("RevealedBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.Navigation("DelegatedAccounts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Tzkt.Data/Migrations/20230718133721_tickets.cs b/Tzkt.Data/Migrations/20230718133721_tickets.cs deleted file mode 100644 index c299e989c..000000000 --- a/Tzkt.Data/Migrations/20230718133721_tickets.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class tickets : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.RenameColumn( - name: "ContractId", - table: "Tickets", - newName: "TicketerId"); - - migrationBuilder.AddColumn( - name: "ContentHash", - table: "Tickets", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "ContentTypeHash", - table: "Tickets", - type: "integer", - nullable: false, - defaultValue: 0); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "ContentHash", - table: "Tickets"); - - migrationBuilder.DropColumn( - name: "ContentTypeHash", - table: "Tickets"); - - migrationBuilder.RenameColumn( - name: "TicketerId", - table: "Tickets", - newName: "ContractId"); - } - } -} diff --git a/Tzkt.Data/Migrations/20230730143042_test.Designer.cs b/Tzkt.Data/Migrations/20230730143042_test.Designer.cs deleted file mode 100644 index 0f39cbff2..000000000 --- a/Tzkt.Data/Migrations/20230730143042_test.Designer.cs +++ /dev/null @@ -1,6263 +0,0 @@ -// -using System; -using System.Numerics; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Tzkt.Data; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - [DbContext(typeof(TzktContext))] - [Migration("20230730143042_test")] - partial class test - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveRefutationGamesCount") - .HasColumnType("integer"); - - b.Property("ActiveTicketsCount") - .HasColumnType("integer"); - - b.Property("ActiveTokensCount") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character varying(37)"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("ContractsCount") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegationLevel") - .HasColumnType("integer"); - - b.Property("DelegationsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageCount") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MigrationsCount") - .HasColumnType("integer"); - - b.Property("OriginationsCount") - .HasColumnType("integer"); - - b.Property("RefutationGamesCount") - .HasColumnType("integer"); - - b.Property("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesCount") - .HasColumnType("integer"); - - b.Property("SmartRollupBonds") - .HasColumnType("bigint"); - - b.Property("SmartRollupCementCount") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TransactionsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchCount") - .HasColumnType("integer"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.Property("UpdateConsensusKeyCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("DelegateId"); - - b.HasIndex("Extras"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); - - b.HasIndex("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - b.ToTable("Accounts"); - - b.HasDiscriminator("Type").HasValue((byte)3); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("ActivationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.AppState", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountCounter") - .HasColumnType("integer"); - - b.Property("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .HasColumnType("integer"); - - b.Property("BallotOpsCount") - .HasColumnType("integer"); - - b.Property("BigMapCounter") - .HasColumnType("integer"); - - b.Property("BigMapKeyCounter") - .HasColumnType("integer"); - - b.Property("BigMapUpdateCounter") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Chain") - .HasColumnType("text"); - - b.Property("ChainId") - .HasColumnType("text"); - - b.Property("CommitmentsCount") - .HasColumnType("integer"); - - b.Property("ConstantsCount") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("CyclesCount") - .HasColumnType("integer"); - - b.Property("DelegationOpsCount") - .HasColumnType("integer"); - - b.Property("DomainsLevel") - .HasColumnType("integer"); - - b.Property("DomainsNameRegistry") - .HasColumnType("text"); - - b.Property("DoubleBakingOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsementOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardOpsCount") - .HasColumnType("integer"); - - b.Property("EventCounter") - .HasColumnType("integer"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxMessageCounter") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageOpsCount") - .HasColumnType("integer"); - - b.Property("KnownHead") - .HasColumnType("integer"); - - b.Property("LastSync") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerCounter") - .HasColumnType("integer"); - - b.Property("MigrationOpsCount") - .HasColumnType("integer"); - - b.Property("NextProtocol") - .HasColumnType("text"); - - b.Property("NonceRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("OperationCounter") - .HasColumnType("bigint"); - - b.Property("OriginationOpsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("ProtocolsCount") - .HasColumnType("integer"); - - b.Property("QuoteBtc") - .HasColumnType("double precision"); - - b.Property("QuoteCny") - .HasColumnType("double precision"); - - b.Property("QuoteEth") - .HasColumnType("double precision"); - - b.Property("QuoteEur") - .HasColumnType("double precision"); - - b.Property("QuoteGbp") - .HasColumnType("double precision"); - - b.Property("QuoteJpy") - .HasColumnType("double precision"); - - b.Property("QuoteKrw") - .HasColumnType("double precision"); - - b.Property("QuoteLevel") - .HasColumnType("integer"); - - b.Property("QuoteUsd") - .HasColumnType("double precision"); - - b.Property("RefutationGameCounter") - .HasColumnType("integer"); - - b.Property("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCementOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentCounter") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .HasColumnType("integer"); - - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TransactionOpsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchOpsCount") - .HasColumnType("integer"); - - b.Property("UpdateConsensusKeyOpsCount") - .HasColumnType("integer"); - - b.Property("VdfRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("VotingEpoch") - .HasColumnType("integer"); - - b.Property("VotingPeriod") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("AppState"); - - b.HasData( - new - { - Id = -1, - AccountCounter = 0, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DomainsLevel = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - DrainDelegateOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - InboxMessageCounter = 0, - IncreasePaidStorageOpsCount = 0, - KnownHead = 0, - LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Level = -1, - ManagerCounter = 0, - MigrationOpsCount = 0, - NextProtocol = "", - NonceRevelationOpsCount = 0, - OperationCounter = 0L, - OriginationOpsCount = 0, - PreendorsementOpsCount = 0, - ProposalOpsCount = 0, - ProposalsCount = 0, - Protocol = "", - ProtocolsCount = 0, - QuoteBtc = 0.0, - QuoteCny = 0.0, - QuoteEth = 0.0, - QuoteEur = 0.0, - QuoteGbp = 0.0, - QuoteJpy = 0.0, - QuoteKrw = 0.0, - QuoteLevel = -1, - QuoteUsd = 0.0, - RefutationGameCounter = 0, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - SmartRollupAddMessagesOpsCount = 0, - SmartRollupCementOpsCount = 0, - SmartRollupCommitmentCounter = 0, - SmartRollupExecuteOpsCount = 0, - SmartRollupOriginateOpsCount = 0, - SmartRollupPublishOpsCount = 0, - SmartRollupRecoverBondOpsCount = 0, - SmartRollupRefuteOpsCount = 0, - StorageCounter = 0, - TicketBalancesCount = 0, - TicketTransfersCount = 0, - TicketsCount = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), - TokenBalancesCount = 0, - TokenTransfersCount = 0, - TokensCount = 0, - TransactionOpsCount = 0, - TransferTicketOpsCount = 0, - TxRollupCommitOpsCount = 0, - TxRollupDispatchTicketsOpsCount = 0, - TxRollupFinalizeCommitmentOpsCount = 0, - TxRollupOriginationOpsCount = 0, - TxRollupRejectionOpsCount = 0, - TxRollupRemoveCommitmentOpsCount = 0, - TxRollupReturnBondOpsCount = 0, - TxRollupSubmitBatchOpsCount = 0, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - b.Property("FutureBlockRewards") - .HasColumnType("bigint"); - - b.Property("FutureBlocks") - .HasColumnType("integer"); - - b.Property("FutureEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("FutureEndorsements") - .HasColumnType("integer"); - - b.Property("MissedBlockFees") - .HasColumnType("bigint"); - - b.Property("MissedBlockRewards") - .HasColumnType("bigint"); - - b.Property("MissedBlocks") - .HasColumnType("integer"); - - b.Property("MissedEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("MissedEndorsements") - .HasColumnType("integer"); - - b.Property("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - b.ToTable("BakerCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Round") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("Cycle", "BakerId"); - - b.ToTable("BakingRights"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Vote") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("BallotOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("ActiveKeys") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("KeyType") - .HasColumnType("bytea"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Ptr") - .HasColumnType("integer"); - - b.Property("StoragePath") - .HasColumnType("text"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TotalKeys") - .HasColumnType("integer"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.Property("ValueType") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Ptr") - .IsUnique(); - - b.ToTable("BigMaps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("JsonKey") - .HasColumnType("jsonb"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("KeyHash") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("RawKey") - .HasColumnType("bytea"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonKey"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); - - b.HasIndex("JsonValue"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); - - b.HasIndex("LastLevel"); - - b.HasIndex("BigMapPtr", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - b.ToTable("BigMapKeys"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Action") - .HasColumnType("integer"); - - b.Property("BigMapKeyId") - .HasColumnType("integer"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Fees") - .HasColumnType("bigint"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBToggle") - .HasColumnType("boolean"); - - b.Property("LBToggleEma") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Operations") - .HasColumnType("bigint"); - - b.Property("PayloadRound") - .HasColumnType("integer"); - - b.Property("ProducerId") - .HasColumnType("integer"); - - b.Property("ProposerId") - .HasColumnType("integer"); - - b.Property("ProtoCode") - .HasColumnType("integer"); - - b.Property("ResetBakerDeactivation") - .HasColumnType("integer"); - - b.Property("ResetProposerDeactivation") - .HasColumnType("integer"); - - b.Property("RevelationId") - .HasColumnType("bigint"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Validations") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Hash") - .IsUnique(); - - b.HasIndex("Level") - .IsUnique(); - - b.HasIndex("ProducerId"); - - b.HasIndex("ProposerId"); - - b.HasIndex("ProtoCode"); - - b.HasIndex("RevelationId") - .IsUnique(); - - b.HasIndex("SoftwareId"); - - b.ToTable("Blocks"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character(37)") - .IsFixedLength(); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("Commitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("JsonPayload") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("RawPayload") - .HasColumnType("bytea"); - - b.Property("Tag") - .HasColumnType("text"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("Type") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonPayload"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("Tag"); - - b.HasIndex("TransactionId"); - - b.HasIndex("ContractCodeHash", "Tag"); - - b.HasIndex("ContractId", "Tag"); - - b.ToTable("Events"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PrevDelegateId") - .HasColumnType("integer"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("PrevDelegateId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.ToTable("DelegationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasColumnType("text"); - - b.Property("Data") - .HasColumnType("jsonb"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("Reverse") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.HasIndex("Address"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Level"); - - b.HasIndex("Name"); - - b.HasIndex("Owner"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleBakingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleEndorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoublePreendorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Fee") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("TargetId"); - - b.ToTable("DrainDelegateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("EndorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Expected") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Received") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("EndorsingRewardOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OperationId") - .HasColumnType("bigint"); - - b.Property("Payload") - .HasColumnType("bytea"); - - b.Property("PredecessorLevel") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("Type") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OperationId"); - - b.HasIndex("Type", "Id"); - - b.ToTable("InboxMessages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("IncreasePaidStorageOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("BalanceChange") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("Level"); - - b.HasIndex("ScriptId"); - - b.HasIndex("StorageId"); - - b.ToTable("MigrationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RevealedCycle") - .HasColumnType("integer"); - - b.Property("RevealedLevel") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RevealedCycle"); - - b.HasIndex("SenderId"); - - b.ToTable("NonceRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("TicketTransfers") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash") - .HasFilter("\"ContractCodeHash\" IS NOT NULL"); - - b.HasIndex("ContractId"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("ManagerId"); - - b.HasIndex("OpHash"); - - b.HasIndex("ScriptId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.ToTable("OriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("PreendorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - b.ToTable("Proposals"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Duplicated") - .HasColumnType("boolean"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("ProposalOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotQuorumMax") - .HasColumnType("integer"); - - b.Property("BallotQuorumMin") - .HasColumnType("integer"); - - b.Property("BlockDeposit") - .HasColumnType("bigint"); - - b.Property("BlockReward0") - .HasColumnType("bigint"); - - b.Property("BlockReward1") - .HasColumnType("bigint"); - - b.Property("BlocksPerCommitment") - .HasColumnType("integer"); - - b.Property("BlocksPerCycle") - .HasColumnType("integer"); - - b.Property("BlocksPerSnapshot") - .HasColumnType("integer"); - - b.Property("BlocksPerVoting") - .HasColumnType("integer"); - - b.Property("ByteCost") - .HasColumnType("integer"); - - b.Property("Code") - .HasColumnType("integer"); - - b.Property("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - - b.Property("HardBlockGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationStorageLimit") - .HasColumnType("integer"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupChallengeWindow") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentPeriod") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginationSize") - .HasColumnType("integer"); - - b.Property("SmartRollupStakeAmount") - .HasColumnType("bigint"); - - b.Property("SmartRollupTimeoutPeriod") - .HasColumnType("integer"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Protocols"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Btc") - .HasColumnType("double precision"); - - b.Property("Cny") - .HasColumnType("double precision"); - - b.Property("Eth") - .HasColumnType("double precision"); - - b.Property("Eur") - .HasColumnType("double precision"); - - b.Property("Gbp") - .HasColumnType("double precision"); - - b.Property("Jpy") - .HasColumnType("double precision"); - - b.Property("Krw") - .HasColumnType("double precision"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Usd") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Quotes"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("InitiatorCommitmentId") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InitiatorLoss") - .HasColumnType("bigint"); - - b.Property("InitiatorReward") - .HasColumnType("bigint"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("LastMoveId") - .HasColumnType("bigint"); - - b.Property("OpponentCommitmentId") - .HasColumnType("integer"); - - b.Property("OpponentId") - .HasColumnType("integer"); - - b.Property("OpponentLoss") - .HasColumnType("bigint"); - - b.Property("OpponentReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("InitiatorCommitmentId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("LastLevel"); - - b.HasIndex("OpponentCommitmentId"); - - b.HasIndex("OpponentId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("RefutationGames"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("Refs") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Value") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique() - .HasFilter("\"Address\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RegisterConstantOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RevealOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("MissedLevel") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("RevelationPenaltyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Script", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CodeSchema") - .HasColumnType("bytea"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ParameterSchema") - .HasColumnType("bytea"); - - b.Property("StorageSchema") - .HasColumnType("bytea"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("Views") - .HasColumnType("bytea[]"); - - b.HasKey("Id"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Limit") - .HasColumnType("text"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SetDepositsLimitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MessagesCount") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupAddMessagesOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupCementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("PredecessorId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Stakers") - .HasColumnType("integer"); - - b.Property("State") - .HasColumnType("text"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Successors") - .HasColumnType("integer"); - - b.Property("Ticks") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Hash"); - - b.HasIndex("InboxLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("PredecessorId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("Hash", "SmartRollupId"); - - b.ToTable("SmartRollupCommitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupExecuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("Kernel") - .HasColumnType("bytea"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("OriginationProof") - .HasColumnType("bytea"); - - b.Property("ParameterType") - .HasColumnType("bytea"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupOriginateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("BondStatus") - .HasColumnType("integer"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Flags") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("SmartRollupId", "BondStatus", "SenderId") - .HasFilter("\"BondStatus\" IS NOT NULL"); - - b.ToTable("SmartRollupPublishOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("StakerId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("StakerId"); - - b.ToTable("SmartRollupRecoverBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DissectionEnd") - .HasColumnType("bigint"); - - b.Property("DissectionStart") - .HasColumnType("bigint"); - - b.Property("DissectionSteps") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GameId") - .HasColumnType("integer"); - - b.Property("GameStatus") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Move") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("GameId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupRefuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - b.ToTable("SnapshotBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("TotalActivated") - .HasColumnType("bigint"); - - b.Property("TotalBanished") - .HasColumnType("bigint"); - - b.Property("TotalBootstrapped") - .HasColumnType("bigint"); - - b.Property("TotalBurned") - .HasColumnType("bigint"); - - b.Property("TotalCommitments") - .HasColumnType("bigint"); - - b.Property("TotalCreated") - .HasColumnType("bigint"); - - b.Property("TotalFrozen") - .HasColumnType("bigint"); - - b.Property("TotalRollupBonds") - .HasColumnType("bigint"); - - b.Property("TotalSmartRollupBonds") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle") - .IsUnique() - .HasFilter("\"Cycle\" IS NOT NULL"); - - b.HasIndex("Date") - .IsUnique() - .HasFilter("\"Date\" IS NOT NULL"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Storage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("Content") - .HasColumnType("bytea"); - - b.Property("ContentHash") - .HasColumnType("integer"); - - b.Property("ContentType") - .HasColumnType("bytea"); - - b.Property("ContentTypeHash") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TotalBurned") - .HasColumnType("numeric"); - - b.Property("TotalMinted") - .HasColumnType("numeric"); - - b.Property("TotalSupply") - .HasColumnType("numeric"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("numeric"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("TicketId"); - - b.HasIndex("TicketerId"); - - b.ToTable("TicketBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("numeric"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TicketTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Token", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("ContractId", "TokenId") - .IsUnique(); - - b.ToTable("Tokens"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); - - b.HasIndex("TokenId"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("TokenTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InternalDelegations") - .HasColumnType("smallint"); - - b.Property("InternalOperations") - .HasColumnType("smallint"); - - b.Property("InternalOriginations") - .HasColumnType("smallint"); - - b.Property("InternalTransactions") - .HasColumnType("smallint"); - - b.Property("JsonParameters") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawParameters") - .HasColumnType("bytea"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("TargetCodeHash") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("TicketTransfers") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("JsonParameters"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.HasIndex("TargetCodeHash") - .HasFilter("\"TargetCodeHash\" IS NOT NULL"); - - b.HasIndex("TargetId"); - - b.ToTable("TransactionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("JsonContent") - .HasColumnType("text"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawContent") - .HasColumnType("bytea"); - - b.Property("RawType") - .HasColumnType("bytea"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("TargetId"); - - b.HasIndex("TicketerId"); - - b.ToTable("TransferTicketOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupCommitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupDispatchTicketsOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupFinalizeCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupOriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitterId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitterId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRejectionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRemoveCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupReturnBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupSubmitBatchOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActivationCycle") - .HasColumnType("integer"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("PublicKeyHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("UpdateConsensusKeyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Proof") - .HasColumnType("bytea"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotsQuorum") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("integer"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("NayBallots") - .HasColumnType("integer"); - - b.Property("NayVotingPower") - .HasColumnType("bigint"); - - b.Property("ParticipationEma") - .HasColumnType("integer"); - - b.Property("PassBallots") - .HasColumnType("integer"); - - b.Property("PassVotingPower") - .HasColumnType("bigint"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("SingleWinner") - .HasColumnType("boolean"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Supermajority") - .HasColumnType("integer"); - - b.Property("TopUpvotes") - .HasColumnType("integer"); - - b.Property("TopVotingPower") - .HasColumnType("bigint"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalVotingPower") - .HasColumnType("bigint"); - - b.Property("UpvotesQuorum") - .HasColumnType("integer"); - - b.Property("YayBallots") - .HasColumnType("integer"); - - b.Property("YayVotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("VotingPeriods"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Period"); - - b.HasIndex("Period", "BakerId") - .IsUnique(); - - b.ToTable("VotingSnapshots"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("smallint"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Spendable") - .HasColumnType("boolean"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("WeirdDelegateId") - .HasColumnType("integer"); - - b.HasIndex("CodeHash"); - - b.HasIndex("CreatorId"); - - b.HasIndex("ManagerId"); - - b.HasIndex("TypeHash"); - - b.HasIndex("WeirdDelegateId"); - - b.HasIndex("Type", "Kind") - .HasFilter("\"Type\" = 2"); - - b.HasDiscriminator().HasValue((byte)2); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)4); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("CementedCommitments") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("ExecutedCommitments") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("LastCommitment") - .HasColumnType("text"); - - b.Property("OrphanCommitments") - .HasColumnType("integer"); - - b.Property("PendingCommitments") - .HasColumnType("integer"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("RefutedCommitments") - .HasColumnType("integer"); - - b.Property("TotalStakers") - .HasColumnType("integer"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)5); - }); - - modelBuilder.Entity("Tzkt.Data.Models.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - b.HasDiscriminator().HasValue((byte)0); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasBaseType("Tzkt.Data.Models.User"); - - b.Property("ActivationLevel") - .HasColumnType("integer"); - - b.Property("BallotsCount") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("DeactivationLevel") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingCount") - .HasColumnType("integer"); - - b.Property("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .HasFilter("\"Type\" = 1"); - - b.HasDiscriminator().HasValue((byte)1); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany("DelegatedAccounts") - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") - .WithMany("CreatedAccounts") - .HasForeignKey("FirstLevel") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Delegate"); - - b.Navigation("FirstBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.HasOne("Tzkt.Data.Models.User", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Activations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Ballots") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") - .WithMany() - .HasForeignKey("ProposerId"); - - b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") - .WithMany() - .HasForeignKey("ProtoCode") - .HasPrincipalKey("Code") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") - .WithOne("RevealedBlock") - .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); - - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Proposer"); - - b.Navigation("Protocol"); - - b.Navigation("Revelation"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Delegations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") - .WithMany() - .HasForeignKey("PrevDelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("PrevDelegate"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleBakings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleEndorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoublePreendorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DrainDelegateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Endorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("IncreasePaidStorageOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Migrations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Account"); - - b.Navigation("Block"); - - b.Navigation("Script"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Revelations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Contract", "Contract") - .WithMany() - .HasForeignKey("ContractId"); - - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Originations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Block"); - - b.Navigation("Contract"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("Manager"); - - b.Navigation("Script"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Preendorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Proposals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RegisterConstants") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Reveals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RevelationPenalties") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SetDepositsLimits") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupAddMessagesOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupCementOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupExecuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupOriginateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupPublishOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRecoverBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRefuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Ticket", "Ticket") - .WithMany() - .HasForeignKey("TicketId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Ticket"); - - b.Navigation("Ticketer"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Transactions") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.HasOne("Tzkt.Data.Models.Account", "Target") - .WithMany() - .HasForeignKey("TargetId"); - - b.Navigation("Block"); - - b.Navigation("Initiator"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - - b.Navigation("Target"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TransferTicketOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - - b.Navigation("Ticketer"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupCommitOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupDispatchTicketsOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupFinalizeCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupOriginationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRejectionOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRemoveCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupReturnBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupSubmitBatchOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("UpdateConsensusKeyOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("VdfRevelationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Creator") - .WithMany() - .HasForeignKey("CreatorId"); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") - .WithMany() - .HasForeignKey("WeirdDelegateId"); - - b.Navigation("Creator"); - - b.Navigation("Manager"); - - b.Navigation("WeirdDelegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Navigation("Activations"); - - b.Navigation("Ballots"); - - b.Navigation("CreatedAccounts"); - - b.Navigation("Delegations"); - - b.Navigation("DoubleBakings"); - - b.Navigation("DoubleEndorsings"); - - b.Navigation("DoublePreendorsings"); - - b.Navigation("DrainDelegateOps"); - - b.Navigation("Endorsements"); - - b.Navigation("IncreasePaidStorageOps"); - - b.Navigation("Migrations"); - - b.Navigation("Originations"); - - b.Navigation("Preendorsements"); - - b.Navigation("Proposals"); - - b.Navigation("RegisterConstants"); - - b.Navigation("Reveals"); - - b.Navigation("RevelationPenalties"); - - b.Navigation("Revelations"); - - b.Navigation("SetDepositsLimits"); - - b.Navigation("SmartRollupAddMessagesOps"); - - b.Navigation("SmartRollupCementOps"); - - b.Navigation("SmartRollupExecuteOps"); - - b.Navigation("SmartRollupOriginateOps"); - - b.Navigation("SmartRollupPublishOps"); - - b.Navigation("SmartRollupRecoverBondOps"); - - b.Navigation("SmartRollupRefuteOps"); - - b.Navigation("Transactions"); - - b.Navigation("TransferTicketOps"); - - b.Navigation("TxRollupCommitOps"); - - b.Navigation("TxRollupDispatchTicketsOps"); - - b.Navigation("TxRollupFinalizeCommitmentOps"); - - b.Navigation("TxRollupOriginationOps"); - - b.Navigation("TxRollupRejectionOps"); - - b.Navigation("TxRollupRemoveCommitmentOps"); - - b.Navigation("TxRollupReturnBondOps"); - - b.Navigation("TxRollupSubmitBatchOps"); - - b.Navigation("UpdateConsensusKeyOps"); - - b.Navigation("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Navigation("RevealedBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.Navigation("DelegatedAccounts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Tzkt.Data/Migrations/20230730143042_test.cs b/Tzkt.Data/Migrations/20230730143042_test.cs deleted file mode 100644 index a43b57c66..000000000 --- a/Tzkt.Data/Migrations/20230730143042_test.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Globalization; -using System.Numerics; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class test : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "TicketId", - table: "Tickets"); - - migrationBuilder.AddColumn( - name: "Content", - table: "Tickets", - type: "bytea", - nullable: true); - - migrationBuilder.AddColumn( - name: "ContentType", - table: "Tickets", - type: "bytea", - nullable: true); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_AccountId", - table: "TicketBalances", - column: "AccountId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_TicketerId", - table: "TicketBalances", - column: "TicketerId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_TicketId", - table: "TicketBalances", - column: "TicketId"); - - migrationBuilder.AddForeignKey( - name: "FK_TicketBalances_Accounts_AccountId", - table: "TicketBalances", - column: "AccountId", - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_TicketBalances_Accounts_TicketerId", - table: "TicketBalances", - column: "TicketerId", - principalTable: "Accounts", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_TicketBalances_Tickets_TicketId", - table: "TicketBalances", - column: "TicketId", - principalTable: "Tickets", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_TicketBalances_Accounts_AccountId", - table: "TicketBalances"); - - migrationBuilder.DropForeignKey( - name: "FK_TicketBalances_Accounts_TicketerId", - table: "TicketBalances"); - - migrationBuilder.DropForeignKey( - name: "FK_TicketBalances_Tickets_TicketId", - table: "TicketBalances"); - - migrationBuilder.DropIndex( - name: "IX_TicketBalances_AccountId", - table: "TicketBalances"); - - migrationBuilder.DropIndex( - name: "IX_TicketBalances_TicketerId", - table: "TicketBalances"); - - migrationBuilder.DropIndex( - name: "IX_TicketBalances_TicketId", - table: "TicketBalances"); - - migrationBuilder.DropColumn( - name: "Content", - table: "Tickets"); - - migrationBuilder.DropColumn( - name: "ContentType", - table: "Tickets"); - - migrationBuilder.AddColumn( - name: "TicketId", - table: "Tickets", - type: "numeric", - nullable: false, - defaultValue: BigInteger.Parse("0", NumberFormatInfo.InvariantInfo)); - } - } -} diff --git a/Tzkt.Data/Migrations/20230801105851_toDelete.Designer.cs b/Tzkt.Data/Migrations/20230801105851_toDelete.Designer.cs deleted file mode 100644 index 228b8a5ff..000000000 --- a/Tzkt.Data/Migrations/20230801105851_toDelete.Designer.cs +++ /dev/null @@ -1,6266 +0,0 @@ -// -using System; -using System.Numerics; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Tzkt.Data; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - [DbContext(typeof(TzktContext))] - [Migration("20230801105851_toDelete")] - partial class toDelete - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveRefutationGamesCount") - .HasColumnType("integer"); - - b.Property("ActiveTicketsCount") - .HasColumnType("integer"); - - b.Property("ActiveTokensCount") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character varying(37)"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("ContractsCount") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegationLevel") - .HasColumnType("integer"); - - b.Property("DelegationsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageCount") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MigrationsCount") - .HasColumnType("integer"); - - b.Property("OriginationsCount") - .HasColumnType("integer"); - - b.Property("RefutationGamesCount") - .HasColumnType("integer"); - - b.Property("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesCount") - .HasColumnType("integer"); - - b.Property("SmartRollupBonds") - .HasColumnType("bigint"); - - b.Property("SmartRollupCementCount") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TransactionsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchCount") - .HasColumnType("integer"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.Property("UpdateConsensusKeyCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("DelegateId"); - - b.HasIndex("Extras"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); - - b.HasIndex("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - b.ToTable("Accounts"); - - b.HasDiscriminator("Type").HasValue((byte)3); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("ActivationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.AppState", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountCounter") - .HasColumnType("integer"); - - b.Property("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .HasColumnType("integer"); - - b.Property("BallotOpsCount") - .HasColumnType("integer"); - - b.Property("BigMapCounter") - .HasColumnType("integer"); - - b.Property("BigMapKeyCounter") - .HasColumnType("integer"); - - b.Property("BigMapUpdateCounter") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Chain") - .HasColumnType("text"); - - b.Property("ChainId") - .HasColumnType("text"); - - b.Property("CommitmentsCount") - .HasColumnType("integer"); - - b.Property("ConstantsCount") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("CyclesCount") - .HasColumnType("integer"); - - b.Property("DelegationOpsCount") - .HasColumnType("integer"); - - b.Property("DomainsLevel") - .HasColumnType("integer"); - - b.Property("DomainsNameRegistry") - .HasColumnType("text"); - - b.Property("DoubleBakingOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsementOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardOpsCount") - .HasColumnType("integer"); - - b.Property("EventCounter") - .HasColumnType("integer"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxMessageCounter") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageOpsCount") - .HasColumnType("integer"); - - b.Property("KnownHead") - .HasColumnType("integer"); - - b.Property("LastSync") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerCounter") - .HasColumnType("integer"); - - b.Property("MigrationOpsCount") - .HasColumnType("integer"); - - b.Property("NextProtocol") - .HasColumnType("text"); - - b.Property("NonceRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("OperationCounter") - .HasColumnType("bigint"); - - b.Property("OriginationOpsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("ProtocolsCount") - .HasColumnType("integer"); - - b.Property("QuoteBtc") - .HasColumnType("double precision"); - - b.Property("QuoteCny") - .HasColumnType("double precision"); - - b.Property("QuoteEth") - .HasColumnType("double precision"); - - b.Property("QuoteEur") - .HasColumnType("double precision"); - - b.Property("QuoteGbp") - .HasColumnType("double precision"); - - b.Property("QuoteJpy") - .HasColumnType("double precision"); - - b.Property("QuoteKrw") - .HasColumnType("double precision"); - - b.Property("QuoteLevel") - .HasColumnType("integer"); - - b.Property("QuoteUsd") - .HasColumnType("double precision"); - - b.Property("RefutationGameCounter") - .HasColumnType("integer"); - - b.Property("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCementOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentCounter") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .HasColumnType("integer"); - - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TransactionOpsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchOpsCount") - .HasColumnType("integer"); - - b.Property("UpdateConsensusKeyOpsCount") - .HasColumnType("integer"); - - b.Property("VdfRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("VotingEpoch") - .HasColumnType("integer"); - - b.Property("VotingPeriod") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("AppState"); - - b.HasData( - new - { - Id = -1, - AccountCounter = 0, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DomainsLevel = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - DrainDelegateOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - InboxMessageCounter = 0, - IncreasePaidStorageOpsCount = 0, - KnownHead = 0, - LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Level = -1, - ManagerCounter = 0, - MigrationOpsCount = 0, - NextProtocol = "", - NonceRevelationOpsCount = 0, - OperationCounter = 0L, - OriginationOpsCount = 0, - PreendorsementOpsCount = 0, - ProposalOpsCount = 0, - ProposalsCount = 0, - Protocol = "", - ProtocolsCount = 0, - QuoteBtc = 0.0, - QuoteCny = 0.0, - QuoteEth = 0.0, - QuoteEur = 0.0, - QuoteGbp = 0.0, - QuoteJpy = 0.0, - QuoteKrw = 0.0, - QuoteLevel = -1, - QuoteUsd = 0.0, - RefutationGameCounter = 0, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - SmartRollupAddMessagesOpsCount = 0, - SmartRollupCementOpsCount = 0, - SmartRollupCommitmentCounter = 0, - SmartRollupExecuteOpsCount = 0, - SmartRollupOriginateOpsCount = 0, - SmartRollupPublishOpsCount = 0, - SmartRollupRecoverBondOpsCount = 0, - SmartRollupRefuteOpsCount = 0, - StorageCounter = 0, - TicketBalancesCount = 0, - TicketTransfersCount = 0, - TicketsCount = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), - TokenBalancesCount = 0, - TokenTransfersCount = 0, - TokensCount = 0, - TransactionOpsCount = 0, - TransferTicketOpsCount = 0, - TxRollupCommitOpsCount = 0, - TxRollupDispatchTicketsOpsCount = 0, - TxRollupFinalizeCommitmentOpsCount = 0, - TxRollupOriginationOpsCount = 0, - TxRollupRejectionOpsCount = 0, - TxRollupRemoveCommitmentOpsCount = 0, - TxRollupReturnBondOpsCount = 0, - TxRollupSubmitBatchOpsCount = 0, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - b.Property("FutureBlockRewards") - .HasColumnType("bigint"); - - b.Property("FutureBlocks") - .HasColumnType("integer"); - - b.Property("FutureEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("FutureEndorsements") - .HasColumnType("integer"); - - b.Property("MissedBlockFees") - .HasColumnType("bigint"); - - b.Property("MissedBlockRewards") - .HasColumnType("bigint"); - - b.Property("MissedBlocks") - .HasColumnType("integer"); - - b.Property("MissedEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("MissedEndorsements") - .HasColumnType("integer"); - - b.Property("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - b.ToTable("BakerCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Round") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("Cycle", "BakerId"); - - b.ToTable("BakingRights"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Vote") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("BallotOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("ActiveKeys") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("KeyType") - .HasColumnType("bytea"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Ptr") - .HasColumnType("integer"); - - b.Property("StoragePath") - .HasColumnType("text"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TotalKeys") - .HasColumnType("integer"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.Property("ValueType") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Ptr") - .IsUnique(); - - b.ToTable("BigMaps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("JsonKey") - .HasColumnType("jsonb"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("KeyHash") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("RawKey") - .HasColumnType("bytea"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonKey"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); - - b.HasIndex("JsonValue"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); - - b.HasIndex("LastLevel"); - - b.HasIndex("BigMapPtr", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - b.ToTable("BigMapKeys"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Action") - .HasColumnType("integer"); - - b.Property("BigMapKeyId") - .HasColumnType("integer"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Fees") - .HasColumnType("bigint"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBToggle") - .HasColumnType("boolean"); - - b.Property("LBToggleEma") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Operations") - .HasColumnType("bigint"); - - b.Property("PayloadRound") - .HasColumnType("integer"); - - b.Property("ProducerId") - .HasColumnType("integer"); - - b.Property("ProposerId") - .HasColumnType("integer"); - - b.Property("ProtoCode") - .HasColumnType("integer"); - - b.Property("ResetBakerDeactivation") - .HasColumnType("integer"); - - b.Property("ResetProposerDeactivation") - .HasColumnType("integer"); - - b.Property("RevelationId") - .HasColumnType("bigint"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Validations") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Hash") - .IsUnique(); - - b.HasIndex("Level") - .IsUnique(); - - b.HasIndex("ProducerId"); - - b.HasIndex("ProposerId"); - - b.HasIndex("ProtoCode"); - - b.HasIndex("RevelationId") - .IsUnique(); - - b.HasIndex("SoftwareId"); - - b.ToTable("Blocks"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character(37)") - .IsFixedLength(); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("Commitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("JsonPayload") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("RawPayload") - .HasColumnType("bytea"); - - b.Property("Tag") - .HasColumnType("text"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("Type") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonPayload"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("Tag"); - - b.HasIndex("TransactionId"); - - b.HasIndex("ContractCodeHash", "Tag"); - - b.HasIndex("ContractId", "Tag"); - - b.ToTable("Events"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PrevDelegateId") - .HasColumnType("integer"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("PrevDelegateId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.ToTable("DelegationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasColumnType("text"); - - b.Property("Data") - .HasColumnType("jsonb"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("Reverse") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.HasIndex("Address"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Level"); - - b.HasIndex("Name"); - - b.HasIndex("Owner"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleBakingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleEndorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoublePreendorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Fee") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("TargetId"); - - b.ToTable("DrainDelegateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("EndorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Expected") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Received") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("EndorsingRewardOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OperationId") - .HasColumnType("bigint"); - - b.Property("Payload") - .HasColumnType("bytea"); - - b.Property("PredecessorLevel") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("Type") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OperationId"); - - b.HasIndex("Type", "Id"); - - b.ToTable("InboxMessages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("IncreasePaidStorageOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("BalanceChange") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("Level"); - - b.HasIndex("ScriptId"); - - b.HasIndex("StorageId"); - - b.ToTable("MigrationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RevealedCycle") - .HasColumnType("integer"); - - b.Property("RevealedLevel") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RevealedCycle"); - - b.HasIndex("SenderId"); - - b.ToTable("NonceRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash") - .HasFilter("\"ContractCodeHash\" IS NOT NULL"); - - b.HasIndex("ContractId"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("ManagerId"); - - b.HasIndex("OpHash"); - - b.HasIndex("ScriptId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.ToTable("OriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("PreendorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - b.ToTable("Proposals"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Duplicated") - .HasColumnType("boolean"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("ProposalOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotQuorumMax") - .HasColumnType("integer"); - - b.Property("BallotQuorumMin") - .HasColumnType("integer"); - - b.Property("BlockDeposit") - .HasColumnType("bigint"); - - b.Property("BlockReward0") - .HasColumnType("bigint"); - - b.Property("BlockReward1") - .HasColumnType("bigint"); - - b.Property("BlocksPerCommitment") - .HasColumnType("integer"); - - b.Property("BlocksPerCycle") - .HasColumnType("integer"); - - b.Property("BlocksPerSnapshot") - .HasColumnType("integer"); - - b.Property("BlocksPerVoting") - .HasColumnType("integer"); - - b.Property("ByteCost") - .HasColumnType("integer"); - - b.Property("Code") - .HasColumnType("integer"); - - b.Property("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - - b.Property("HardBlockGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationStorageLimit") - .HasColumnType("integer"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupChallengeWindow") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentPeriod") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginationSize") - .HasColumnType("integer"); - - b.Property("SmartRollupStakeAmount") - .HasColumnType("bigint"); - - b.Property("SmartRollupTimeoutPeriod") - .HasColumnType("integer"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Protocols"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Btc") - .HasColumnType("double precision"); - - b.Property("Cny") - .HasColumnType("double precision"); - - b.Property("Eth") - .HasColumnType("double precision"); - - b.Property("Eur") - .HasColumnType("double precision"); - - b.Property("Gbp") - .HasColumnType("double precision"); - - b.Property("Jpy") - .HasColumnType("double precision"); - - b.Property("Krw") - .HasColumnType("double precision"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Usd") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Quotes"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("InitiatorCommitmentId") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InitiatorLoss") - .HasColumnType("bigint"); - - b.Property("InitiatorReward") - .HasColumnType("bigint"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("LastMoveId") - .HasColumnType("bigint"); - - b.Property("OpponentCommitmentId") - .HasColumnType("integer"); - - b.Property("OpponentId") - .HasColumnType("integer"); - - b.Property("OpponentLoss") - .HasColumnType("bigint"); - - b.Property("OpponentReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("InitiatorCommitmentId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("LastLevel"); - - b.HasIndex("OpponentCommitmentId"); - - b.HasIndex("OpponentId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("RefutationGames"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("Refs") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Value") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique() - .HasFilter("\"Address\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RegisterConstantOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RevealOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("MissedLevel") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("RevelationPenaltyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Script", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CodeSchema") - .HasColumnType("bytea"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ParameterSchema") - .HasColumnType("bytea"); - - b.Property("StorageSchema") - .HasColumnType("bytea"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("Views") - .HasColumnType("bytea[]"); - - b.HasKey("Id"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Limit") - .HasColumnType("text"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SetDepositsLimitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MessagesCount") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupAddMessagesOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupCementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("PredecessorId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Stakers") - .HasColumnType("integer"); - - b.Property("State") - .HasColumnType("text"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Successors") - .HasColumnType("integer"); - - b.Property("Ticks") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Hash"); - - b.HasIndex("InboxLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("PredecessorId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("Hash", "SmartRollupId"); - - b.ToTable("SmartRollupCommitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupExecuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("Kernel") - .HasColumnType("bytea"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("OriginationProof") - .HasColumnType("bytea"); - - b.Property("ParameterType") - .HasColumnType("bytea"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupOriginateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("BondStatus") - .HasColumnType("integer"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Flags") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("SmartRollupId", "BondStatus", "SenderId") - .HasFilter("\"BondStatus\" IS NOT NULL"); - - b.ToTable("SmartRollupPublishOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("StakerId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("StakerId"); - - b.ToTable("SmartRollupRecoverBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DissectionEnd") - .HasColumnType("bigint"); - - b.Property("DissectionStart") - .HasColumnType("bigint"); - - b.Property("DissectionSteps") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GameId") - .HasColumnType("integer"); - - b.Property("GameStatus") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Move") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("GameId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupRefuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - b.ToTable("SnapshotBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("TotalActivated") - .HasColumnType("bigint"); - - b.Property("TotalBanished") - .HasColumnType("bigint"); - - b.Property("TotalBootstrapped") - .HasColumnType("bigint"); - - b.Property("TotalBurned") - .HasColumnType("bigint"); - - b.Property("TotalCommitments") - .HasColumnType("bigint"); - - b.Property("TotalCreated") - .HasColumnType("bigint"); - - b.Property("TotalFrozen") - .HasColumnType("bigint"); - - b.Property("TotalRollupBonds") - .HasColumnType("bigint"); - - b.Property("TotalSmartRollupBonds") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle") - .IsUnique() - .HasFilter("\"Cycle\" IS NOT NULL"); - - b.HasIndex("Date") - .IsUnique() - .HasFilter("\"Date\" IS NOT NULL"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Storage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("Content") - .HasColumnType("bytea"); - - b.Property("ContentHash") - .HasColumnType("integer"); - - b.Property("ContentType") - .HasColumnType("bytea"); - - b.Property("ContentTypeHash") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TotalBurned") - .HasColumnType("numeric"); - - b.Property("TotalMinted") - .HasColumnType("numeric"); - - b.Property("TotalSupply") - .HasColumnType("numeric"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("numeric"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("TicketId"); - - b.HasIndex("TicketerId"); - - b.ToTable("TicketBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("numeric"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("TransferTicketId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TicketTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Token", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("ContractId", "TokenId") - .IsUnique(); - - b.ToTable("Tokens"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); - - b.HasIndex("TokenId"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("TokenTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InternalDelegations") - .HasColumnType("smallint"); - - b.Property("InternalOperations") - .HasColumnType("smallint"); - - b.Property("InternalOriginations") - .HasColumnType("smallint"); - - b.Property("InternalTransactions") - .HasColumnType("smallint"); - - b.Property("JsonParameters") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawParameters") - .HasColumnType("bytea"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("TargetCodeHash") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("TicketTransfers") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("JsonParameters"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.HasIndex("TargetCodeHash") - .HasFilter("\"TargetCodeHash\" IS NOT NULL"); - - b.HasIndex("TargetId"); - - b.ToTable("TransactionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("JsonContent") - .HasColumnType("text"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawContent") - .HasColumnType("bytea"); - - b.Property("RawType") - .HasColumnType("bytea"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("TicketTransfers") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("TargetId"); - - b.HasIndex("TicketerId"); - - b.ToTable("TransferTicketOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupCommitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupDispatchTicketsOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupFinalizeCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupOriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitterId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitterId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRejectionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRemoveCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupReturnBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupSubmitBatchOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActivationCycle") - .HasColumnType("integer"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("PublicKeyHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("UpdateConsensusKeyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Proof") - .HasColumnType("bytea"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotsQuorum") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("integer"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("NayBallots") - .HasColumnType("integer"); - - b.Property("NayVotingPower") - .HasColumnType("bigint"); - - b.Property("ParticipationEma") - .HasColumnType("integer"); - - b.Property("PassBallots") - .HasColumnType("integer"); - - b.Property("PassVotingPower") - .HasColumnType("bigint"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("SingleWinner") - .HasColumnType("boolean"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Supermajority") - .HasColumnType("integer"); - - b.Property("TopUpvotes") - .HasColumnType("integer"); - - b.Property("TopVotingPower") - .HasColumnType("bigint"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalVotingPower") - .HasColumnType("bigint"); - - b.Property("UpvotesQuorum") - .HasColumnType("integer"); - - b.Property("YayBallots") - .HasColumnType("integer"); - - b.Property("YayVotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("VotingPeriods"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Period"); - - b.HasIndex("Period", "BakerId") - .IsUnique(); - - b.ToTable("VotingSnapshots"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("smallint"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Spendable") - .HasColumnType("boolean"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("WeirdDelegateId") - .HasColumnType("integer"); - - b.HasIndex("CodeHash"); - - b.HasIndex("CreatorId"); - - b.HasIndex("ManagerId"); - - b.HasIndex("TypeHash"); - - b.HasIndex("WeirdDelegateId"); - - b.HasIndex("Type", "Kind") - .HasFilter("\"Type\" = 2"); - - b.HasDiscriminator().HasValue((byte)2); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)4); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("CementedCommitments") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("ExecutedCommitments") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("LastCommitment") - .HasColumnType("text"); - - b.Property("OrphanCommitments") - .HasColumnType("integer"); - - b.Property("PendingCommitments") - .HasColumnType("integer"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("RefutedCommitments") - .HasColumnType("integer"); - - b.Property("TotalStakers") - .HasColumnType("integer"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)5); - }); - - modelBuilder.Entity("Tzkt.Data.Models.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - b.HasDiscriminator().HasValue((byte)0); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasBaseType("Tzkt.Data.Models.User"); - - b.Property("ActivationLevel") - .HasColumnType("integer"); - - b.Property("BallotsCount") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("DeactivationLevel") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingCount") - .HasColumnType("integer"); - - b.Property("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .HasFilter("\"Type\" = 1"); - - b.HasDiscriminator().HasValue((byte)1); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany("DelegatedAccounts") - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") - .WithMany("CreatedAccounts") - .HasForeignKey("FirstLevel") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Delegate"); - - b.Navigation("FirstBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.HasOne("Tzkt.Data.Models.User", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Activations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Ballots") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") - .WithMany() - .HasForeignKey("ProposerId"); - - b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") - .WithMany() - .HasForeignKey("ProtoCode") - .HasPrincipalKey("Code") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") - .WithOne("RevealedBlock") - .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); - - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Proposer"); - - b.Navigation("Protocol"); - - b.Navigation("Revelation"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Delegations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") - .WithMany() - .HasForeignKey("PrevDelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("PrevDelegate"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleBakings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleEndorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoublePreendorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DrainDelegateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Endorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("IncreasePaidStorageOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Migrations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Account"); - - b.Navigation("Block"); - - b.Navigation("Script"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Revelations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Contract", "Contract") - .WithMany() - .HasForeignKey("ContractId"); - - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Originations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Block"); - - b.Navigation("Contract"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("Manager"); - - b.Navigation("Script"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Preendorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Proposals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RegisterConstants") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Reveals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RevelationPenalties") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SetDepositsLimits") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupAddMessagesOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupCementOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupExecuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupOriginateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupPublishOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRecoverBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRefuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Ticket", "Ticket") - .WithMany() - .HasForeignKey("TicketId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Ticket"); - - b.Navigation("Ticketer"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Transactions") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.HasOne("Tzkt.Data.Models.Account", "Target") - .WithMany() - .HasForeignKey("TargetId"); - - b.Navigation("Block"); - - b.Navigation("Initiator"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - - b.Navigation("Target"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TransferTicketOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - - b.Navigation("Ticketer"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupCommitOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupDispatchTicketsOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupFinalizeCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupOriginationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRejectionOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRemoveCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupReturnBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupSubmitBatchOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("UpdateConsensusKeyOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("VdfRevelationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Creator") - .WithMany() - .HasForeignKey("CreatorId"); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") - .WithMany() - .HasForeignKey("WeirdDelegateId"); - - b.Navigation("Creator"); - - b.Navigation("Manager"); - - b.Navigation("WeirdDelegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Navigation("Activations"); - - b.Navigation("Ballots"); - - b.Navigation("CreatedAccounts"); - - b.Navigation("Delegations"); - - b.Navigation("DoubleBakings"); - - b.Navigation("DoubleEndorsings"); - - b.Navigation("DoublePreendorsings"); - - b.Navigation("DrainDelegateOps"); - - b.Navigation("Endorsements"); - - b.Navigation("IncreasePaidStorageOps"); - - b.Navigation("Migrations"); - - b.Navigation("Originations"); - - b.Navigation("Preendorsements"); - - b.Navigation("Proposals"); - - b.Navigation("RegisterConstants"); - - b.Navigation("Reveals"); - - b.Navigation("RevelationPenalties"); - - b.Navigation("Revelations"); - - b.Navigation("SetDepositsLimits"); - - b.Navigation("SmartRollupAddMessagesOps"); - - b.Navigation("SmartRollupCementOps"); - - b.Navigation("SmartRollupExecuteOps"); - - b.Navigation("SmartRollupOriginateOps"); - - b.Navigation("SmartRollupPublishOps"); - - b.Navigation("SmartRollupRecoverBondOps"); - - b.Navigation("SmartRollupRefuteOps"); - - b.Navigation("Transactions"); - - b.Navigation("TransferTicketOps"); - - b.Navigation("TxRollupCommitOps"); - - b.Navigation("TxRollupDispatchTicketsOps"); - - b.Navigation("TxRollupFinalizeCommitmentOps"); - - b.Navigation("TxRollupOriginationOps"); - - b.Navigation("TxRollupRejectionOps"); - - b.Navigation("TxRollupRemoveCommitmentOps"); - - b.Navigation("TxRollupReturnBondOps"); - - b.Navigation("TxRollupSubmitBatchOps"); - - b.Navigation("UpdateConsensusKeyOps"); - - b.Navigation("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Navigation("RevealedBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.Navigation("DelegatedAccounts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Tzkt.Data/Migrations/20230801105851_toDelete.cs b/Tzkt.Data/Migrations/20230801105851_toDelete.cs deleted file mode 100644 index e4242f791..000000000 --- a/Tzkt.Data/Migrations/20230801105851_toDelete.cs +++ /dev/null @@ -1,58 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class toDelete : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "OriginationOps"); - - migrationBuilder.RenameColumn( - name: "OriginationId", - table: "TicketTransfers", - newName: "TransferTicketId"); - - migrationBuilder.AddColumn( - name: "SubIds", - table: "TransferTicketOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "TransferTicketOps", - type: "integer", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "SubIds", - table: "TransferTicketOps"); - - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "TransferTicketOps"); - - migrationBuilder.RenameColumn( - name: "TransferTicketId", - table: "TicketTransfers", - newName: "OriginationId"); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "OriginationOps", - type: "integer", - nullable: true); - } - } -} diff --git a/Tzkt.Data/Migrations/20230718171450_ticketUpdates.Designer.cs b/Tzkt.Data/Migrations/20230807105327_tickets.Designer.cs similarity index 99% rename from Tzkt.Data/Migrations/20230718171450_ticketUpdates.Designer.cs rename to Tzkt.Data/Migrations/20230807105327_tickets.Designer.cs index 92108a280..2b4639c65 100644 --- a/Tzkt.Data/Migrations/20230718171450_ticketUpdates.Designer.cs +++ b/Tzkt.Data/Migrations/20230807105327_tickets.Designer.cs @@ -14,8 +14,8 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230718171450_ticketUpdates")] - partial class ticketUpdates + [Migration("20230807105327_tickets")] + partial class tickets { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -2042,9 +2042,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SubIds") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3589,9 +3586,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("BalancesCount") .HasColumnType("integer"); + b.Property("Content") + .HasColumnType("bytea"); + b.Property("ContentHash") .HasColumnType("integer"); + b.Property("ContentType") + .HasColumnType("bytea"); + b.Property("ContentTypeHash") .HasColumnType("integer"); @@ -3613,9 +3616,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("OwnerId") .HasColumnType("integer"); - b.Property("TicketId") - .HasColumnType("numeric"); - b.Property("TicketerId") .HasColumnType("integer"); @@ -3696,9 +3696,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MigrationId") .HasColumnType("bigint"); - b.Property("OriginationId") - .HasColumnType("bigint"); - b.Property("TicketId") .HasColumnType("bigint"); @@ -3711,6 +3708,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TransactionId") .HasColumnType("bigint"); + b.Property("TransferTicketId") + .HasColumnType("bigint"); + b.HasKey("Id"); b.ToTable("TicketTransfers"); @@ -4136,9 +4136,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("TicketerId") .HasColumnType("integer"); @@ -5892,15 +5898,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId"); - b.Navigation("Block"); b.Navigation("Sender"); - - b.Navigation("Ticketer"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => diff --git a/Tzkt.Data/Migrations/20230718171450_ticketUpdates.cs b/Tzkt.Data/Migrations/20230807105327_tickets.cs similarity index 63% rename from Tzkt.Data/Migrations/20230718171450_ticketUpdates.cs rename to Tzkt.Data/Migrations/20230807105327_tickets.cs index 0dfe8c606..6a3fa706d 100644 --- a/Tzkt.Data/Migrations/20230718171450_ticketUpdates.cs +++ b/Tzkt.Data/Migrations/20230807105327_tickets.cs @@ -7,20 +7,26 @@ namespace Tzkt.Data.Migrations { /// - public partial class ticketUpdates : Migration + public partial class tickets : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.AddColumn( + name: "SubIds", + table: "TransferTicketOps", + type: "integer", + nullable: true); + migrationBuilder.AddColumn( name: "TicketTransfers", - table: "TransactionOps", + table: "TransferTicketOps", type: "integer", nullable: true); migrationBuilder.AddColumn( name: "TicketTransfers", - table: "OriginationOps", + table: "TransactionOps", type: "integer", nullable: true); @@ -38,6 +44,13 @@ protected override void Up(MigrationBuilder migrationBuilder) nullable: false, defaultValue: 0); + migrationBuilder.AddColumn( + name: "TicketsCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + migrationBuilder.AddColumn( name: "ActiveTicketsCount", table: "Accounts", @@ -59,6 +72,12 @@ protected override void Up(MigrationBuilder migrationBuilder) nullable: false, defaultValue: 0); + migrationBuilder.AddColumn( + name: "TicketsCount", + table: "Accounts", + type: "integer", + nullable: true); + migrationBuilder.CreateTable( name: "TicketBalances", columns: table => new @@ -79,6 +98,34 @@ protected override void Up(MigrationBuilder migrationBuilder) table.PrimaryKey("PK_TicketBalances", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Tickets", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TicketerId = table.Column(type: "integer", nullable: false), + FirstMinterId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + BalancesCount = table.Column(type: "integer", nullable: false), + HoldersCount = table.Column(type: "integer", nullable: false), + TotalMinted = table.Column(type: "numeric", nullable: false), + TotalBurned = table.Column(type: "numeric", nullable: false), + TotalSupply = table.Column(type: "numeric", nullable: false), + OwnerId = table.Column(type: "integer", nullable: true), + IndexedAt = table.Column(type: "integer", nullable: true), + ContentHash = table.Column(type: "integer", nullable: false), + ContentTypeHash = table.Column(type: "integer", nullable: false), + Content = table.Column(type: "bytea", nullable: true), + ContentType = table.Column(type: "bytea", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tickets", x => x.Id); + }); + migrationBuilder.CreateTable( name: "TicketTransfers", columns: table => new @@ -91,7 +138,7 @@ protected override void Up(MigrationBuilder migrationBuilder) Amount = table.Column(type: "numeric", nullable: false), FromId = table.Column(type: "integer", nullable: true), ToId = table.Column(type: "integer", nullable: true), - OriginationId = table.Column(type: "bigint", nullable: true), + TransferTicketId = table.Column(type: "bigint", nullable: true), TransactionId = table.Column(type: "bigint", nullable: true), MigrationId = table.Column(type: "bigint", nullable: true), IndexedAt = table.Column(type: "integer", nullable: true) @@ -105,8 +152,8 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "AppState", keyColumn: "Id", keyValue: -1, - columns: new[] { "TicketBalancesCount", "TicketTransfersCount" }, - values: new object[] { 0, 0 }); + columns: new[] { "TicketBalancesCount", "TicketTransfersCount", "TicketsCount" }, + values: new object[] { 0, 0, 0 }); } /// @@ -115,16 +162,23 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "TicketBalances"); + migrationBuilder.DropTable( + name: "Tickets"); + migrationBuilder.DropTable( name: "TicketTransfers"); + migrationBuilder.DropColumn( + name: "SubIds", + table: "TransferTicketOps"); + migrationBuilder.DropColumn( name: "TicketTransfers", - table: "TransactionOps"); + table: "TransferTicketOps"); migrationBuilder.DropColumn( name: "TicketTransfers", - table: "OriginationOps"); + table: "TransactionOps"); migrationBuilder.DropColumn( name: "TicketBalancesCount", @@ -134,6 +188,10 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "TicketTransfersCount", table: "AppState"); + migrationBuilder.DropColumn( + name: "TicketsCount", + table: "AppState"); + migrationBuilder.DropColumn( name: "ActiveTicketsCount", table: "Accounts"); @@ -145,6 +203,10 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropColumn( name: "TicketTransfersCount", table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketsCount", + table: "Accounts"); } } } diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 9fca4f600..077403c8a 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3667,12 +3667,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("AccountId"); - - b.HasIndex("TicketId"); - - b.HasIndex("TicketerId"); - b.ToTable("TicketBalances"); }); @@ -5848,33 +5842,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Sender"); }); - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Ticket", "Ticket") - .WithMany() - .HasForeignKey("TicketId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Ticket"); - - b.Navigation("Ticketer"); - }); - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => { b.HasOne("Tzkt.Data.Models.Account", "Initiator") @@ -5928,15 +5895,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("Tzkt.Data.Models.Account", "Ticketer") - .WithMany() - .HasForeignKey("TicketerId"); - b.Navigation("Block"); b.Navigation("Sender"); - - b.Navigation("Ticketer"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => diff --git a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs index 626ad0ee6..77ab59c24 100644 --- a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs +++ b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs @@ -19,7 +19,7 @@ public class MigrationOperation public int? BigMapUpdates { get; set; } public int? TokenTransfers { get; set; } - //TODO Add Tickets to migrations + //TODO Add Tickets to migrations? public int? SubIds { get; set; } diff --git a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs index 0c9d10233..008971736 100644 --- a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs +++ b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs @@ -19,13 +19,6 @@ public class TransferTicketOperation : ManagerOperation public int? TicketTransfers { get; set; } public int? SubIds { get; set; } - - - //TODO Delete ForeignKey - #region relations - [ForeignKey(nameof(TicketerId))] - public Account Ticketer { get; set; } - #endregion } public static class TransferTicketOperationModel diff --git a/Tzkt.Data/Models/Scripts/TicketBalance.cs b/Tzkt.Data/Models/Scripts/TicketBalance.cs index eb8bb26f8..dacad5984 100644 --- a/Tzkt.Data/Models/Scripts/TicketBalance.cs +++ b/Tzkt.Data/Models/Scripts/TicketBalance.cs @@ -16,18 +16,6 @@ public class TicketBalance public int TransfersCount { get; set; } public BigInteger Balance { get; set; } public int? IndexedAt { get; set; } - - //TODO Delete ForeignKey - #region relations - [ForeignKey(nameof(TicketerId))] - public Account Ticketer { get; set; } - - [ForeignKey(nameof(AccountId))] - public Account Account { get; set; } - - [ForeignKey(nameof(TicketId))] - public Ticket Ticket { get; set; } - #endregion } public static class TicketBalanceModel diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 9d19aa4fd..cf4bf42e3 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -23,8 +23,6 @@ public virtual void Append(ManagerOperation op, IEnumerable update public virtual async Task Apply() { if (Updates.Count == 0) return; - //TODO We need cache here; - #region precache @@ -87,6 +85,18 @@ public virtual async Task Apply() var ticket = GetOrCreateTicket(op, contract, ticketUpdates.TicketToken); + /*List<(ManagerOperation op, TicketUpdate update)> transfers = new(); + + foreach (var updates in Updates.GroupBy(x => x.op.OpHash).Select(g => g.ToList()).ToList()) + { + foreach (var (managerOperation, update) in updates) + { + if (true) + { + transfers.Add(managerOperation, update); + } + } + }*/ //TODO First, group by opHash? //TODO Match updates, if successful, transfers, if not, burns and mints diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs index 8da537fb8..bfa19abd7 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs @@ -11,18 +11,22 @@ public Diagnostics(ProtocolHandler handler) : base(handler) { } protected override async Task TestTicketBalance(int level, TicketBalance balance) { + //TODO Make sure that's correct + var ticketer = await Cache.Accounts.GetAsync(balance.TicketerId); + var ticket = Cache.Tickets.Get(balance.TicketId); + var account = await Cache.Accounts.GetAsync(balance.AccountId); + var update = new { - ticketer = balance.Ticketer.Address, - content_type = Micheline.FromBytes(balance.Ticket.ContentType), - content = Micheline.FromBytes(balance.Ticket.Content) + ticketer = ticketer.Address, + content_type = Micheline.FromBytes(ticket.ContentType), + content = Micheline.FromBytes(ticket.Content) }; - var ticket = JsonSerializer.Serialize(update); - if (BigInteger.TryParse((await Rpc.GetTicketBalance(level, balance.Account.Address, ticket)).ToString(), out var remoteBalance)) + if (BigInteger.TryParse((await Rpc.GetTicketBalance(level, account.Address, JsonSerializer.Serialize(update))).ToString(), out var remoteBalance)) { if (remoteBalance != balance.Balance) - throw new Exception($"Diagnostics failed: wrong ticket balance for {balance.Account.Address}"); + throw new Exception($"Diagnostics failed: wrong ticket balance for {account.Address}"); } else { From ba60f8b07c10cf0d792a690f40a50263f5aa7bcd Mon Sep 17 00:00:00 2001 From: dmir Date: Mon, 7 Aug 2023 19:47:01 +0300 Subject: [PATCH 16/51] Clean up --- ....cs => 20230807164638_tickets.Designer.cs} | 5 +-- ...7_tickets.cs => 20230807164638_tickets.cs} | 1 - .../Migrations/TzktContextModelSnapshot.cs | 3 -- Tzkt.Data/Models/Scripts/TIcket.cs | 5 --- .../Operations/TransferTicketCommit.cs | 10 ++--- .../Operations/SmartRollupExecuteCommit.cs | 10 ++--- .../Commits/Operations/TransactionsCommit.cs | 11 +++--- .../Handlers/Proto17/Commits/TicketsCommit.cs | 38 ++++++------------- Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs | 2 + Tzkt.Sync/Services/Cache/TicketsCache.cs | 1 - 10 files changed, 28 insertions(+), 58 deletions(-) rename Tzkt.Data/Migrations/{20230807105327_tickets.Designer.cs => 20230807164638_tickets.Designer.cs} (99%) rename Tzkt.Data/Migrations/{20230807105327_tickets.cs => 20230807164638_tickets.cs} (99%) diff --git a/Tzkt.Data/Migrations/20230807105327_tickets.Designer.cs b/Tzkt.Data/Migrations/20230807164638_tickets.Designer.cs similarity index 99% rename from Tzkt.Data/Migrations/20230807105327_tickets.Designer.cs rename to Tzkt.Data/Migrations/20230807164638_tickets.Designer.cs index 2b4639c65..1f2a9b0d2 100644 --- a/Tzkt.Data/Migrations/20230807105327_tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230807164638_tickets.Designer.cs @@ -14,7 +14,7 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230807105327_tickets")] + [Migration("20230807164638_tickets")] partial class tickets { /// @@ -3607,9 +3607,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("HoldersCount") .HasColumnType("integer"); - b.Property("IndexedAt") - .HasColumnType("integer"); - b.Property("LastLevel") .HasColumnType("integer"); diff --git a/Tzkt.Data/Migrations/20230807105327_tickets.cs b/Tzkt.Data/Migrations/20230807164638_tickets.cs similarity index 99% rename from Tzkt.Data/Migrations/20230807105327_tickets.cs rename to Tzkt.Data/Migrations/20230807164638_tickets.cs index 6a3fa706d..d50c33c8b 100644 --- a/Tzkt.Data/Migrations/20230807105327_tickets.cs +++ b/Tzkt.Data/Migrations/20230807164638_tickets.cs @@ -115,7 +115,6 @@ protected override void Up(MigrationBuilder migrationBuilder) TotalBurned = table.Column(type: "numeric", nullable: false), TotalSupply = table.Column(type: "numeric", nullable: false), OwnerId = table.Column(type: "integer", nullable: true), - IndexedAt = table.Column(type: "integer", nullable: true), ContentHash = table.Column(type: "integer", nullable: false), ContentTypeHash = table.Column(type: "integer", nullable: false), Content = table.Column(type: "bytea", nullable: true), diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 077403c8a..88c6c3214 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3604,9 +3604,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("HoldersCount") .HasColumnType("integer"); - b.Property("IndexedAt") - .HasColumnType("integer"); - b.Property("LastLevel") .HasColumnType("integer"); diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs index 9f4b5d58a..1aeebdd50 100644 --- a/Tzkt.Data/Models/Scripts/TIcket.cs +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -23,7 +23,6 @@ public class Ticket public BigInteger TotalSupply { get; set; } public int? OwnerId { get; set; } - public int? IndexedAt { get; set; } public int ContentHash { get; set; } public int ContentTypeHash { get; set; } @@ -79,10 +78,6 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.LastLevel); - modelBuilder.Entity() - .HasIndex(x => x.IndexedAt) - .HasFilter($@"""{nameof(Ticket.IndexedAt)}"" is not null"); - // shadow property modelBuilder.Entity() .HasIndex("Metadata") diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 1c63db438..ed4141f5f 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -211,12 +211,10 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul ? new TicketToken { Ticketer = ticketToken.RequiredString("ticketer"), - ContentType = ticketToken.TryGetProperty("content_type", out var contentType) - ? Micheline.FromJson(contentType) - : null, - Content = ticketToken.TryGetProperty("content", out var content) - ? Micheline.FromJson(content) - : null, + ContentType = Micheline.FromJson(ticketToken.Required("content_type")), + Content = Micheline.FromJson(ticketToken.Required("content")), + ContentTypeHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content_type")).ToBytes()), + ContentHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content")).ToBytes()) } : null, Updates = x.TryGetProperty("updates", out var updates) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index 4e1697a50..767edea55 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -202,12 +202,10 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul ? new TicketToken { Ticketer = ticketToken.RequiredString("ticketer"), - ContentType = ticketToken.TryGetProperty("content_type", out var contentType) - ? Micheline.FromJson(contentType) - : null, - Content = ticketToken.TryGetProperty("content", out var content) - ? Micheline.FromJson(content) - : null, + ContentType = Micheline.FromJson(ticketToken.Required("content_type")), + Content = Micheline.FromJson(ticketToken.Required("content")), + ContentTypeHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content_type")).ToBytes()), + ContentHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content")).ToBytes()) } : null, Updates = x.TryGetProperty("updates", out var updates) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs index 8722932fa..2ed3084fd 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs @@ -1,5 +1,6 @@ using System.Text.Json; using Netezos.Encoding; +using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto17 { @@ -18,12 +19,10 @@ protected override IEnumerable ParseTicketUpdates(string property, ? new TicketToken { Ticketer = ticketToken.RequiredString("ticketer"), - ContentType = ticketToken.TryGetProperty("content_type", out var contentType) - ? Micheline.FromJson(contentType) - : null, - Content = ticketToken.TryGetProperty("content", out var content) - ? Micheline.FromJson(content) - : null, + ContentType = Micheline.FromJson(ticketToken.Required("content_type")), + Content = Micheline.FromJson(ticketToken.Required("content")), + ContentTypeHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content_type")).ToBytes()), + ContentHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content")).ToBytes()) } : null, Updates = x.TryGetProperty("updates", out var updates) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index cf4bf42e3..24d916455 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -30,7 +30,7 @@ public virtual async Task Apply() var ticketsSet = new HashSet<(int, int, int)>(); var balancesSet = new HashSet<(int, long)>(); - foreach (var (op, update) in Updates) + foreach (var (_, update) in Updates) { accountsSet.Add(update.TicketToken.Ticketer); foreach (var upd in update.Updates) @@ -40,27 +40,19 @@ public virtual async Task Apply() } await Cache.Accounts.Preload(accountsSet); - foreach (var (op, update) in Updates) + foreach (var (_, update) in Updates) { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) - { - //TODO Move out - var contentHash = Script.GetHash(update.TicketToken.Content.ToBytes()); - var contentTypeHash = Script.GetHash(update.TicketToken.ContentType.ToBytes()); - ticketsSet.Add((ticketer.Id, contentHash, contentTypeHash)); - } + ticketsSet.Add((ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash)); } await Cache.Tickets.Preload(ticketsSet); - foreach (var (op, update) in Updates) + foreach (var (_, update) in Updates) { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) { - //TODO Move out - var contentHash = Script.GetHash(update.TicketToken.Content.ToBytes()); - var contentTypeHash = Script.GetHash(update.TicketToken.ContentType.ToBytes()); - if (Cache.Tickets.TryGet(ticketer.Id, contentHash, contentTypeHash, out var ticket)) + if (Cache.Tickets.TryGet(ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash, out var ticket)) { foreach (var upd in update.Updates) { @@ -79,11 +71,11 @@ public virtual async Task Apply() { op.Block.Events |= BlockEvents.Tickets; - //TODO GetOrCreate? - var ticketer = await Cache.Accounts.GetAsync(ticketUpdates.TicketToken.Ticketer); - var contract = ticketer as Contract; + + //TODO Check all LastLevel fields. + var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; - var ticket = GetOrCreateTicket(op, contract, ticketUpdates.TicketToken); + var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); /*List<(ManagerOperation op, TicketUpdate update)> transfers = new(); @@ -103,7 +95,6 @@ public virtual async Task Apply() foreach (var ticketUpdate in ticketUpdates.Updates) { var amount = BigInteger.Parse(ticketUpdate.Amount); - //TODO Fix here for transfer_ticket var account = GetOrCreateAccount(op, ticketUpdate.Account); var balance = GetOrCreateTicketBalance(op, ticket, account); MintOrBurnTickets(op, ticket, account, balance, amount); @@ -144,10 +135,7 @@ Account GetOrCreateAccount(ManagerOperation op, string address) Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken ticketToken) { - var contentHash = Script.GetHash(ticketToken.Content.ToBytes()); - var contentTypeHash = Script.GetHash(ticketToken.ContentType.ToBytes()); - - if (Cache.Tickets.TryGet(contract.Id, contentHash, contentTypeHash, out var ticket)) return ticket; + if (Cache.Tickets.TryGet(contract.Id, ticketToken.ContentHash, ticketToken.ContentTypeHash, out var ticket)) return ticket; var state = Cache.AppState.Get(); state.TicketsCount++; @@ -176,9 +164,8 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic TotalSupply = BigInteger.Zero, Content = ticketToken.Content.ToBytes(), ContentType = ticketToken.ContentType.ToBytes(), - ContentHash = contentHash, - ContentTypeHash = contentTypeHash, - IndexedAt = op.Level <= state.Level ? state.Level + 1 : null //TODO Can be not null? + ContentHash = ticketToken.ContentHash, + ContentTypeHash = ticketToken.ContentTypeHash, }; Db.Tickets.Add(ticket); @@ -384,7 +371,6 @@ public virtual async Task Revert(Block block) foreach (var tr in transfers) ticketsSet.Add(tr.TicketId); - //TODO If I throw an exception here, balances will be broken. await Cache.Tickets.Preload(ticketsSet); foreach (var tr in transfers) diff --git a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs index 0fa329d39..cb9cbc663 100644 --- a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs +++ b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs @@ -13,6 +13,8 @@ public class TicketToken public string Ticketer { get; set; } public IMicheline ContentType { get; set; } public IMicheline Content { get; set; } + public int ContentTypeHash { get; set; } + public int ContentHash { get; set; } } public class Update diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs index 06b7b60d5..347ab0e60 100644 --- a/Tzkt.Sync/Services/Cache/TicketsCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -102,7 +102,6 @@ public async Task Preload(IEnumerable ids) } } - //TODO Fix/delete public async Task Preload(IEnumerable<(int, int, int)> ids) { var missed = ids.Where(x => !CachedByKey.ContainsKey(x)).ToHashSet(); From 57bcc2491741d3dbd6db2fac10d2c677a7ac7353 Mon Sep 17 00:00:00 2001 From: dmir Date: Tue, 8 Aug 2023 13:03:26 +0300 Subject: [PATCH 17/51] Clean up --- .../20230807164638_tickets.Designer.cs | 6224 ----------------- .../Migrations/20230807164638_tickets.cs | 211 - .../Migrations/TzktContextModelSnapshot.cs | 310 +- Tzkt.Data/Models/Scripts/TIcket.cs | 1 + Tzkt.Data/Models/Scripts/TicketBalance.cs | 5 - Tzkt.Data/Models/Scripts/TicketTransfer.cs | 5 - .../Handlers/Proto17/Commits/TicketsCommit.cs | 37 +- 7 files changed, 91 insertions(+), 6702 deletions(-) delete mode 100644 Tzkt.Data/Migrations/20230807164638_tickets.Designer.cs delete mode 100644 Tzkt.Data/Migrations/20230807164638_tickets.cs diff --git a/Tzkt.Data/Migrations/20230807164638_tickets.Designer.cs b/Tzkt.Data/Migrations/20230807164638_tickets.Designer.cs deleted file mode 100644 index 1f2a9b0d2..000000000 --- a/Tzkt.Data/Migrations/20230807164638_tickets.Designer.cs +++ /dev/null @@ -1,6224 +0,0 @@ -// -using System; -using System.Numerics; -using System.Text.Json; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using Tzkt.Data; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - [DbContext(typeof(TzktContext))] - [Migration("20230807164638_tickets")] - partial class tickets - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveRefutationGamesCount") - .HasColumnType("integer"); - - b.Property("ActiveTicketsCount") - .HasColumnType("integer"); - - b.Property("ActiveTokensCount") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character varying(37)"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("ContractsCount") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegationLevel") - .HasColumnType("integer"); - - b.Property("DelegationsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageCount") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("MigrationsCount") - .HasColumnType("integer"); - - b.Property("OriginationsCount") - .HasColumnType("integer"); - - b.Property("RefutationGamesCount") - .HasColumnType("integer"); - - b.Property("RevealsCount") - .HasColumnType("integer"); - - b.Property("RollupBonds") - .HasColumnType("bigint"); - - b.Property("RollupsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesCount") - .HasColumnType("integer"); - - b.Property("SmartRollupBonds") - .HasColumnType("bigint"); - - b.Property("SmartRollupCementCount") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteCount") - .HasColumnType("integer"); - - b.Property("SmartRollupsCount") - .HasColumnType("integer"); - - b.Property("Staked") - .HasColumnType("boolean"); - - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TransactionsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchCount") - .HasColumnType("integer"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.Property("UpdateConsensusKeyCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("DelegateId"); - - b.HasIndex("Extras"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); - - b.HasIndex("FirstLevel"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Staked"); - - b.HasIndex("Type"); - - b.ToTable("Accounts"); - - b.HasDiscriminator("Type").HasValue((byte)3); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("ActivationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.AppState", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountCounter") - .HasColumnType("integer"); - - b.Property("AccountsCount") - .HasColumnType("integer"); - - b.Property("ActivationOpsCount") - .HasColumnType("integer"); - - b.Property("BallotOpsCount") - .HasColumnType("integer"); - - b.Property("BigMapCounter") - .HasColumnType("integer"); - - b.Property("BigMapKeyCounter") - .HasColumnType("integer"); - - b.Property("BigMapUpdateCounter") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Chain") - .HasColumnType("text"); - - b.Property("ChainId") - .HasColumnType("text"); - - b.Property("CommitmentsCount") - .HasColumnType("integer"); - - b.Property("ConstantsCount") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("CyclesCount") - .HasColumnType("integer"); - - b.Property("DelegationOpsCount") - .HasColumnType("integer"); - - b.Property("DomainsLevel") - .HasColumnType("integer"); - - b.Property("DomainsNameRegistry") - .HasColumnType("text"); - - b.Property("DoubleBakingOpsCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingOpsCount") - .HasColumnType("integer"); - - b.Property("DrainDelegateOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsementOpsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardOpsCount") - .HasColumnType("integer"); - - b.Property("EventCounter") - .HasColumnType("integer"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxMessageCounter") - .HasColumnType("integer"); - - b.Property("IncreasePaidStorageOpsCount") - .HasColumnType("integer"); - - b.Property("KnownHead") - .HasColumnType("integer"); - - b.Property("LastSync") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerCounter") - .HasColumnType("integer"); - - b.Property("MigrationOpsCount") - .HasColumnType("integer"); - - b.Property("NextProtocol") - .HasColumnType("text"); - - b.Property("NonceRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("OperationCounter") - .HasColumnType("bigint"); - - b.Property("OriginationOpsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalOpsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("ProtocolsCount") - .HasColumnType("integer"); - - b.Property("QuoteBtc") - .HasColumnType("double precision"); - - b.Property("QuoteCny") - .HasColumnType("double precision"); - - b.Property("QuoteEth") - .HasColumnType("double precision"); - - b.Property("QuoteEur") - .HasColumnType("double precision"); - - b.Property("QuoteGbp") - .HasColumnType("double precision"); - - b.Property("QuoteJpy") - .HasColumnType("double precision"); - - b.Property("QuoteKrw") - .HasColumnType("double precision"); - - b.Property("QuoteLevel") - .HasColumnType("integer"); - - b.Property("QuoteUsd") - .HasColumnType("double precision"); - - b.Property("RefutationGameCounter") - .HasColumnType("integer"); - - b.Property("RegisterConstantOpsCount") - .HasColumnType("integer"); - - b.Property("RevealOpsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltyOpsCount") - .HasColumnType("integer"); - - b.Property("ScriptCounter") - .HasColumnType("integer"); - - b.Property("SetDepositsLimitOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupAddMessagesOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCementOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentCounter") - .HasColumnType("integer"); - - b.Property("SmartRollupExecuteOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginateOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupPublishOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRecoverBondOpsCount") - .HasColumnType("integer"); - - b.Property("SmartRollupRefuteOpsCount") - .HasColumnType("integer"); - - b.Property("StorageCounter") - .HasColumnType("integer"); - - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenBalancesCount") - .HasColumnType("integer"); - - b.Property("TokenTransfersCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TransactionOpsCount") - .HasColumnType("integer"); - - b.Property("TransferTicketOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupCommitOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupDispatchTicketsOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupFinalizeCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupOriginationOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRejectionOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupRemoveCommitmentOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupReturnBondOpsCount") - .HasColumnType("integer"); - - b.Property("TxRollupSubmitBatchOpsCount") - .HasColumnType("integer"); - - b.Property("UpdateConsensusKeyOpsCount") - .HasColumnType("integer"); - - b.Property("VdfRevelationOpsCount") - .HasColumnType("integer"); - - b.Property("VotingEpoch") - .HasColumnType("integer"); - - b.Property("VotingPeriod") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("AppState"); - - b.HasData( - new - { - Id = -1, - AccountCounter = 0, - AccountsCount = 0, - ActivationOpsCount = 0, - BallotOpsCount = 0, - BigMapCounter = 0, - BigMapKeyCounter = 0, - BigMapUpdateCounter = 0, - BlocksCount = 0, - CommitmentsCount = 0, - ConstantsCount = 0, - Cycle = -1, - CyclesCount = 0, - DelegationOpsCount = 0, - DomainsLevel = 0, - DoubleBakingOpsCount = 0, - DoubleEndorsingOpsCount = 0, - DoublePreendorsingOpsCount = 0, - DrainDelegateOpsCount = 0, - EndorsementOpsCount = 0, - EndorsingRewardOpsCount = 0, - EventCounter = 0, - EventsCount = 0, - Hash = "", - InboxMessageCounter = 0, - IncreasePaidStorageOpsCount = 0, - KnownHead = 0, - LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), - Level = -1, - ManagerCounter = 0, - MigrationOpsCount = 0, - NextProtocol = "", - NonceRevelationOpsCount = 0, - OperationCounter = 0L, - OriginationOpsCount = 0, - PreendorsementOpsCount = 0, - ProposalOpsCount = 0, - ProposalsCount = 0, - Protocol = "", - ProtocolsCount = 0, - QuoteBtc = 0.0, - QuoteCny = 0.0, - QuoteEth = 0.0, - QuoteEur = 0.0, - QuoteGbp = 0.0, - QuoteJpy = 0.0, - QuoteKrw = 0.0, - QuoteLevel = -1, - QuoteUsd = 0.0, - RefutationGameCounter = 0, - RegisterConstantOpsCount = 0, - RevealOpsCount = 0, - RevelationPenaltyOpsCount = 0, - ScriptCounter = 0, - SetDepositsLimitOpsCount = 0, - SmartRollupAddMessagesOpsCount = 0, - SmartRollupCementOpsCount = 0, - SmartRollupCommitmentCounter = 0, - SmartRollupExecuteOpsCount = 0, - SmartRollupOriginateOpsCount = 0, - SmartRollupPublishOpsCount = 0, - SmartRollupRecoverBondOpsCount = 0, - SmartRollupRefuteOpsCount = 0, - StorageCounter = 0, - TicketBalancesCount = 0, - TicketTransfersCount = 0, - TicketsCount = 0, - Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), - TokenBalancesCount = 0, - TokenTransfersCount = 0, - TokensCount = 0, - TransactionOpsCount = 0, - TransferTicketOpsCount = 0, - TxRollupCommitOpsCount = 0, - TxRollupDispatchTicketsOpsCount = 0, - TxRollupFinalizeCommitmentOpsCount = 0, - TxRollupOriginationOpsCount = 0, - TxRollupRejectionOpsCount = 0, - TxRollupRemoveCommitmentOpsCount = 0, - TxRollupReturnBondOpsCount = 0, - TxRollupSubmitBatchOpsCount = 0, - UpdateConsensusKeyOpsCount = 0, - VdfRevelationOpsCount = 0, - VotingEpoch = -1, - VotingPeriod = -1 - }); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStake") - .HasColumnType("bigint"); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("BlockFees") - .HasColumnType("bigint"); - - b.Property("BlockRewards") - .HasColumnType("bigint"); - - b.Property("Blocks") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleBakingRewards") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingRewards") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingLosses") - .HasColumnType("bigint"); - - b.Property("DoublePreendorsingRewards") - .HasColumnType("bigint"); - - b.Property("EndorsementRewards") - .HasColumnType("bigint"); - - b.Property("Endorsements") - .HasColumnType("integer"); - - b.Property("ExpectedBlocks") - .HasColumnType("double precision"); - - b.Property("ExpectedEndorsements") - .HasColumnType("double precision"); - - b.Property("FutureBlockRewards") - .HasColumnType("bigint"); - - b.Property("FutureBlocks") - .HasColumnType("integer"); - - b.Property("FutureEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("FutureEndorsements") - .HasColumnType("integer"); - - b.Property("MissedBlockFees") - .HasColumnType("bigint"); - - b.Property("MissedBlockRewards") - .HasColumnType("bigint"); - - b.Property("MissedBlocks") - .HasColumnType("integer"); - - b.Property("MissedEndorsementRewards") - .HasColumnType("bigint"); - - b.Property("MissedEndorsements") - .HasColumnType("integer"); - - b.Property("RevelationLosses") - .HasColumnType("bigint"); - - b.Property("RevelationRewards") - .HasColumnType("bigint"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Cycle", "BakerId") - .IsUnique(); - - b.ToTable("BakerCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Round") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("Type") - .HasColumnType("smallint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("Cycle", "BakerId"); - - b.ToTable("BakingRights"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Vote") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("BallotOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("ActiveKeys") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("KeyType") - .HasColumnType("bytea"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Ptr") - .HasColumnType("integer"); - - b.Property("StoragePath") - .HasColumnType("text"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TotalKeys") - .HasColumnType("integer"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.Property("ValueType") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasAlternateKey("Ptr"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Ptr") - .IsUnique(); - - b.ToTable("BigMaps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Active") - .HasColumnType("boolean"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("JsonKey") - .HasColumnType("jsonb"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("KeyHash") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("RawKey") - .HasColumnType("bytea"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("Updates") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonKey"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); - - b.HasIndex("JsonValue"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); - - b.HasIndex("LastLevel"); - - b.HasIndex("BigMapPtr", "Active") - .HasFilter("\"Active\" = true"); - - b.HasIndex("BigMapPtr", "KeyHash"); - - b.ToTable("BigMapKeys"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Action") - .HasColumnType("integer"); - - b.Property("BigMapKeyId") - .HasColumnType("integer"); - - b.Property("BigMapPtr") - .HasColumnType("integer"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("BigMapKeyId") - .HasFilter("\"BigMapKeyId\" is not null"); - - b.HasIndex("BigMapPtr"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("BigMapUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlockRound") - .HasColumnType("integer"); - - b.Property("Bonus") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Events") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("Fees") - .HasColumnType("bigint"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBToggle") - .HasColumnType("boolean"); - - b.Property("LBToggleEma") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Operations") - .HasColumnType("bigint"); - - b.Property("PayloadRound") - .HasColumnType("integer"); - - b.Property("ProducerId") - .HasColumnType("integer"); - - b.Property("ProposerId") - .HasColumnType("integer"); - - b.Property("ProtoCode") - .HasColumnType("integer"); - - b.Property("ResetBakerDeactivation") - .HasColumnType("integer"); - - b.Property("ResetProposerDeactivation") - .HasColumnType("integer"); - - b.Property("RevelationId") - .HasColumnType("bigint"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Validations") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Hash") - .IsUnique(); - - b.HasIndex("Level") - .IsUnique(); - - b.HasIndex("ProducerId"); - - b.HasIndex("ProposerId"); - - b.HasIndex("ProtoCode"); - - b.HasIndex("RevelationId") - .IsUnique(); - - b.HasIndex("SoftwareId"); - - b.ToTable("Blocks"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Address") - .IsRequired() - .HasMaxLength(37) - .HasColumnType("character(37)") - .IsFixedLength(); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique(); - - b.HasIndex("Id") - .IsUnique(); - - b.ToTable("Commitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("JsonPayload") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("RawPayload") - .HasColumnType("bytea"); - - b.Property("Tag") - .HasColumnType("text"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("Type") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("JsonPayload"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("Tag"); - - b.HasIndex("TransactionId"); - - b.HasIndex("ContractCodeHash", "Tag"); - - b.HasIndex("ContractId", "Tag"); - - b.ToTable("Events"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Seed") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("SelectedBakers") - .HasColumnType("integer"); - - b.Property("SelectedStake") - .HasColumnType("bigint"); - - b.Property("SnapshotIndex") - .HasColumnType("integer"); - - b.Property("SnapshotLevel") - .HasColumnType("integer"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalDelegated") - .HasColumnType("bigint"); - - b.Property("TotalDelegators") - .HasColumnType("integer"); - - b.Property("TotalStaking") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("Cycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PrevDelegateId") - .HasColumnType("integer"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("PrevDelegateId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.ToTable("DelegationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("DelegatorId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.HasIndex("DelegatorId"); - - b.HasIndex("Cycle", "BakerId"); - - b.HasIndex("Cycle", "DelegatorId") - .IsUnique(); - - b.ToTable("DelegatorCycles"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Domain", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasColumnType("text"); - - b.Property("Data") - .HasColumnType("jsonb"); - - b.Property("Expiration") - .HasColumnType("timestamp with time zone"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Name") - .HasColumnType("text"); - - b.Property("Owner") - .HasColumnType("text"); - - b.Property("Reverse") - .HasColumnType("boolean"); - - b.HasKey("Id"); - - b.HasIndex("Address"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Level"); - - b.HasIndex("Name"); - - b.HasIndex("Owner"); - - b.ToTable("Domains"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleBakingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoubleEndorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccusedLevel") - .HasColumnType("integer"); - - b.Property("AccuserId") - .HasColumnType("integer"); - - b.Property("AccuserReward") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OffenderId") - .HasColumnType("integer"); - - b.Property("OffenderLoss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("AccuserId"); - - b.HasIndex("Level"); - - b.HasIndex("OffenderId"); - - b.HasIndex("OpHash"); - - b.ToTable("DoublePreendorsingOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Fee") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("TargetId"); - - b.ToTable("DrainDelegateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Deposit") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("EndorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Expected") - .HasColumnType("bigint"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Received") - .HasColumnType("bigint"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("EndorsingRewardOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Change") - .HasColumnType("bigint"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Cycle"); - - b.ToTable("FreezerUpdates"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OperationId") - .HasColumnType("bigint"); - - b.Property("Payload") - .HasColumnType("bytea"); - - b.Property("PredecessorLevel") - .HasColumnType("integer"); - - b.Property("Protocol") - .HasColumnType("text"); - - b.Property("Type") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OperationId"); - - b.HasIndex("Type", "Id"); - - b.ToTable("InboxMessages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("IncreasePaidStorageOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("BalanceChange") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId"); - - b.HasIndex("Level"); - - b.HasIndex("ScriptId"); - - b.HasIndex("StorageId"); - - b.ToTable("MigrationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .IsRequired() - .HasMaxLength(32) - .HasColumnType("bytea") - .IsFixedLength(); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RevealedCycle") - .HasColumnType("integer"); - - b.Property("RevealedLevel") - .HasColumnType("integer"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasAlternateKey("RevealedLevel"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RevealedCycle"); - - b.HasIndex("SenderId"); - - b.ToTable("NonceRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("ContractCodeHash") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ScriptId") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractCodeHash") - .HasFilter("\"ContractCodeHash\" IS NOT NULL"); - - b.HasIndex("ContractId"); - - b.HasIndex("DelegateId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("Level"); - - b.HasIndex("ManagerId"); - - b.HasIndex("OpHash"); - - b.HasIndex("ScriptId"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.ToTable("OriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("Slots") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("DelegateId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("PreendorsementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstPeriod") - .HasColumnType("integer"); - - b.Property("Hash") - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastPeriod") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Upvotes") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Hash"); - - b.ToTable("Proposals"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Duplicated") - .HasColumnType("boolean"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("ProposalId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("Period"); - - b.HasIndex("ProposalId"); - - b.HasIndex("SenderId"); - - b.ToTable("ProposalOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotQuorumMax") - .HasColumnType("integer"); - - b.Property("BallotQuorumMin") - .HasColumnType("integer"); - - b.Property("BlockDeposit") - .HasColumnType("bigint"); - - b.Property("BlockReward0") - .HasColumnType("bigint"); - - b.Property("BlockReward1") - .HasColumnType("bigint"); - - b.Property("BlocksPerCommitment") - .HasColumnType("integer"); - - b.Property("BlocksPerCycle") - .HasColumnType("integer"); - - b.Property("BlocksPerSnapshot") - .HasColumnType("integer"); - - b.Property("BlocksPerVoting") - .HasColumnType("integer"); - - b.Property("ByteCost") - .HasColumnType("integer"); - - b.Property("Code") - .HasColumnType("integer"); - - b.Property("ConsensusThreshold") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("text"); - - b.Property("DoubleBakingPunishment") - .HasColumnType("bigint"); - - b.Property("DoubleEndorsingPunishmentDenominator") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingPunishmentNumerator") - .HasColumnType("integer"); - - b.Property("EndorsementDeposit") - .HasColumnType("bigint"); - - b.Property("EndorsementReward0") - .HasColumnType("bigint"); - - b.Property("EndorsementReward1") - .HasColumnType("bigint"); - - b.Property("EndorsersPerBlock") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstCycle") - .HasColumnType("integer"); - - b.Property("FirstCycleLevel") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FrozenDepositsPercentage") - .HasColumnType("integer"); - - b.Property("HardBlockGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationGasLimit") - .HasColumnType("integer"); - - b.Property("HardOperationStorageLimit") - .HasColumnType("integer"); - - b.Property("Hash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("LBSubsidy") - .HasColumnType("integer"); - - b.Property("LBToggleThreshold") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("MaxBakingReward") - .HasColumnType("bigint"); - - b.Property("MaxEndorsingReward") - .HasColumnType("bigint"); - - b.Property("MaxSlashingPeriod") - .HasColumnType("integer"); - - b.Property("MinParticipationDenominator") - .HasColumnType("integer"); - - b.Property("MinParticipationNumerator") - .HasColumnType("integer"); - - b.Property("NoRewardCycles") - .HasColumnType("integer"); - - b.Property("OriginationSize") - .HasColumnType("integer"); - - b.Property("PreservedCycles") - .HasColumnType("integer"); - - b.Property("ProposalQuorum") - .HasColumnType("integer"); - - b.Property("RampUpCycles") - .HasColumnType("integer"); - - b.Property("RevelationReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupChallengeWindow") - .HasColumnType("integer"); - - b.Property("SmartRollupCommitmentPeriod") - .HasColumnType("integer"); - - b.Property("SmartRollupOriginationSize") - .HasColumnType("integer"); - - b.Property("SmartRollupStakeAmount") - .HasColumnType("bigint"); - - b.Property("SmartRollupTimeoutPeriod") - .HasColumnType("integer"); - - b.Property("TimeBetweenBlocks") - .HasColumnType("integer"); - - b.Property("TokensPerRoll") - .HasColumnType("bigint"); - - b.Property("TxRollupCommitmentBond") - .HasColumnType("bigint"); - - b.Property("TxRollupOriginationSize") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Protocols"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Quote", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Btc") - .HasColumnType("double precision"); - - b.Property("Cny") - .HasColumnType("double precision"); - - b.Property("Eth") - .HasColumnType("double precision"); - - b.Property("Eur") - .HasColumnType("double precision"); - - b.Property("Gbp") - .HasColumnType("double precision"); - - b.Property("Jpy") - .HasColumnType("double precision"); - - b.Property("Krw") - .HasColumnType("double precision"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Usd") - .HasColumnType("double precision"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Quotes"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("InitiatorCommitmentId") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InitiatorLoss") - .HasColumnType("bigint"); - - b.Property("InitiatorReward") - .HasColumnType("bigint"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("LastMoveId") - .HasColumnType("bigint"); - - b.Property("OpponentCommitmentId") - .HasColumnType("integer"); - - b.Property("OpponentId") - .HasColumnType("integer"); - - b.Property("OpponentLoss") - .HasColumnType("bigint"); - - b.Property("OpponentReward") - .HasColumnType("bigint"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("FirstLevel"); - - b.HasIndex("InitiatorCommitmentId"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("LastLevel"); - - b.HasIndex("OpponentCommitmentId"); - - b.HasIndex("OpponentId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("RefutationGames"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .HasMaxLength(54) - .HasColumnType("character varying(54)"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("Refs") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("Value") - .HasColumnType("bytea"); - - b.HasKey("Id"); - - b.HasIndex("Address") - .IsUnique() - .HasFilter("\"Address\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RegisterConstantOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("RevealOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("MissedLevel") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Level"); - - b.ToTable("RevelationPenaltyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Script", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CodeSchema") - .HasColumnType("bytea"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ParameterSchema") - .HasColumnType("bytea"); - - b.Property("StorageSchema") - .HasColumnType("bytea"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("Views") - .HasColumnType("bytea[]"); - - b.HasKey("Id"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Scripts"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Limit") - .HasColumnType("text"); - - b.Property("OpHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SetDepositsLimitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MessagesCount") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupAddMessagesOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("SmartRollupCementOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Hash") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("PredecessorId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Stakers") - .HasColumnType("integer"); - - b.Property("State") - .HasColumnType("text"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Successors") - .HasColumnType("integer"); - - b.Property("Ticks") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Hash"); - - b.HasIndex("InboxLevel"); - - b.HasIndex("LastLevel"); - - b.HasIndex("PredecessorId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("Hash", "SmartRollupId"); - - b.ToTable("SmartRollupCommitments"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupExecuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("Kernel") - .HasColumnType("bytea"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("OriginationProof") - .HasColumnType("bytea"); - - b.Property("ParameterType") - .HasColumnType("bytea"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupOriginateOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("BondStatus") - .HasColumnType("integer"); - - b.Property("CommitmentId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("Flags") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitmentId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("SmartRollupId", "BondStatus", "SenderId") - .HasFilter("\"BondStatus\" IS NOT NULL"); - - b.ToTable("SmartRollupPublishOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("StakerId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.HasIndex("StakerId"); - - b.ToTable("SmartRollupRecoverBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("DissectionEnd") - .HasColumnType("bigint"); - - b.Property("DissectionStart") - .HasColumnType("bigint"); - - b.Property("DissectionSteps") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GameId") - .HasColumnType("integer"); - - b.Property("GameStatus") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Move") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("SmartRollupId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("GameId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("SmartRollupId"); - - b.ToTable("SmartRollupRefuteOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("bigint"); - - b.Property("DelegateId") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Level") - .HasFilter("\"DelegateId\" IS NULL"); - - b.ToTable("SnapshotBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Software", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("Extras") - .HasColumnType("jsonb"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("ShortHash") - .IsRequired() - .HasMaxLength(8) - .HasColumnType("character(8)") - .IsFixedLength(); - - b.HasKey("Id"); - - b.ToTable("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Date") - .HasColumnType("timestamp with time zone"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("TotalActivated") - .HasColumnType("bigint"); - - b.Property("TotalBanished") - .HasColumnType("bigint"); - - b.Property("TotalBootstrapped") - .HasColumnType("bigint"); - - b.Property("TotalBurned") - .HasColumnType("bigint"); - - b.Property("TotalCommitments") - .HasColumnType("bigint"); - - b.Property("TotalCreated") - .HasColumnType("bigint"); - - b.Property("TotalFrozen") - .HasColumnType("bigint"); - - b.Property("TotalRollupBonds") - .HasColumnType("bigint"); - - b.Property("TotalSmartRollupBonds") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Cycle") - .IsUnique() - .HasFilter("\"Cycle\" IS NOT NULL"); - - b.HasIndex("Date") - .IsUnique() - .HasFilter("\"Date\" IS NOT NULL"); - - b.HasIndex("Level") - .IsUnique(); - - b.ToTable("Statistics"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Storage", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("Current") - .HasColumnType("boolean"); - - b.Property("JsonValue") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("RawValue") - .HasColumnType("bytea"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("ContractId", "Current") - .HasFilter("\"Current\" = true"); - - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("Content") - .HasColumnType("bytea"); - - b.Property("ContentHash") - .HasColumnType("integer"); - - b.Property("ContentType") - .HasColumnType("bytea"); - - b.Property("ContentTypeHash") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TotalBurned") - .HasColumnType("numeric"); - - b.Property("TotalMinted") - .HasColumnType("numeric"); - - b.Property("TotalSupply") - .HasColumnType("numeric"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("numeric"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("TicketBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("numeric"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("TransferTicketId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TicketTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Token", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TokenId") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("ContractId", "TokenId") - .IsUnique(); - - b.ToTable("Tokens"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("ContractId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("LastLevel"); - - b.HasIndex("TokenId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "ContractId"); - - b.HasIndex("AccountId", "TokenId") - .IsUnique(); - - b.ToTable("TokenBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("ContractId") - .HasColumnType("integer"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("OriginationId") - .HasColumnType("bigint"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TokenId") - .HasColumnType("bigint"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("ContractId"); - - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("IndexedAt") - .HasFilter("\"IndexedAt\" is not null"); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("OriginationId") - .HasFilter("\"OriginationId\" is not null"); - - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); - - b.HasIndex("TokenId"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.ToTable("TokenTransfers"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("BigMapUpdates") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("InitiatorId") - .HasColumnType("integer"); - - b.Property("InternalDelegations") - .HasColumnType("smallint"); - - b.Property("InternalOperations") - .HasColumnType("smallint"); - - b.Property("InternalOriginations") - .HasColumnType("smallint"); - - b.Property("InternalTransactions") - .HasColumnType("smallint"); - - b.Property("JsonParameters") - .HasColumnType("jsonb"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Nonce") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawParameters") - .HasColumnType("bytea"); - - b.Property("ResetDeactivation") - .HasColumnType("integer"); - - b.Property("SenderCodeHash") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageId") - .HasColumnType("integer"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("TargetCodeHash") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("TicketTransfers") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.Property("TokenTransfers") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("InitiatorId"); - - b.HasIndex("JsonParameters"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderCodeHash") - .HasFilter("\"SenderCodeHash\" IS NOT NULL"); - - b.HasIndex("SenderId"); - - b.HasIndex("StorageId"); - - b.HasIndex("TargetCodeHash") - .HasFilter("\"TargetCodeHash\" IS NOT NULL"); - - b.HasIndex("TargetId"); - - b.ToTable("TransactionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Entrypoint") - .HasColumnType("text"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("JsonContent") - .HasColumnType("text"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RawContent") - .HasColumnType("bytea"); - - b.Property("RawType") - .HasColumnType("bytea"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("SubIds") - .HasColumnType("integer"); - - b.Property("TargetId") - .HasColumnType("integer"); - - b.Property("TicketTransfers") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.HasIndex("TargetId"); - - b.HasIndex("TicketerId"); - - b.ToTable("TransferTicketOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupCommitOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupDispatchTicketsOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupFinalizeCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupOriginationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("CommitterId") - .HasColumnType("integer"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Loss") - .HasColumnType("bigint"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("CommitterId"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRejectionOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupRemoveCommitmentOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Bond") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupReturnBondOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("RollupId") - .HasColumnType("integer"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("RollupId"); - - b.HasIndex("SenderId"); - - b.ToTable("TxRollupSubmitBatchOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("ActivationCycle") - .HasColumnType("integer"); - - b.Property("AllocationFee") - .HasColumnType("bigint"); - - b.Property("BakerFee") - .HasColumnType("bigint"); - - b.Property("Counter") - .HasColumnType("integer"); - - b.Property("Errors") - .HasColumnType("text"); - - b.Property("GasLimit") - .HasColumnType("integer"); - - b.Property("GasUsed") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("PublicKeyHash") - .HasColumnType("text"); - - b.Property("SenderId") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("smallint"); - - b.Property("StorageFee") - .HasColumnType("bigint"); - - b.Property("StorageLimit") - .HasColumnType("integer"); - - b.Property("StorageUsed") - .HasColumnType("integer"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.HasIndex("SenderId"); - - b.ToTable("UpdateConsensusKeyOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Cycle") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("OpHash") - .IsRequired() - .HasMaxLength(51) - .HasColumnType("character(51)") - .IsFixedLength(); - - b.Property("Proof") - .HasColumnType("bytea"); - - b.Property("Reward") - .HasColumnType("bigint"); - - b.Property("Solution") - .HasColumnType("bytea"); - - b.Property("Timestamp") - .HasColumnType("timestamp with time zone"); - - b.HasKey("Id"); - - b.HasIndex("BakerId"); - - b.HasIndex("Cycle"); - - b.HasIndex("Level"); - - b.HasIndex("OpHash"); - - b.ToTable("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BallotsQuorum") - .HasColumnType("integer"); - - b.Property("Dictator") - .HasColumnType("integer"); - - b.Property("Epoch") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("Index") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("NayBallots") - .HasColumnType("integer"); - - b.Property("NayVotingPower") - .HasColumnType("bigint"); - - b.Property("ParticipationEma") - .HasColumnType("integer"); - - b.Property("PassBallots") - .HasColumnType("integer"); - - b.Property("PassVotingPower") - .HasColumnType("bigint"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("SingleWinner") - .HasColumnType("boolean"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("Supermajority") - .HasColumnType("integer"); - - b.Property("TopUpvotes") - .HasColumnType("integer"); - - b.Property("TopVotingPower") - .HasColumnType("bigint"); - - b.Property("TotalBakers") - .HasColumnType("integer"); - - b.Property("TotalVotingPower") - .HasColumnType("bigint"); - - b.Property("UpvotesQuorum") - .HasColumnType("integer"); - - b.Property("YayBallots") - .HasColumnType("integer"); - - b.Property("YayVotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasAlternateKey("Index"); - - b.HasIndex("Epoch"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Index") - .IsUnique(); - - b.ToTable("VotingPeriods"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("integer"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BakerId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("Period") - .HasColumnType("integer"); - - b.Property("Status") - .HasColumnType("integer"); - - b.Property("VotingPower") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("Period"); - - b.HasIndex("Period", "BakerId") - .IsUnique(); - - b.ToTable("VotingSnapshots"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CodeHash") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("EventsCount") - .HasColumnType("integer"); - - b.Property("Kind") - .HasColumnType("smallint"); - - b.Property("ManagerId") - .HasColumnType("integer"); - - b.Property("Spendable") - .HasColumnType("boolean"); - - b.Property("Tags") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - - b.Property("TokensCount") - .HasColumnType("integer"); - - b.Property("TypeHash") - .HasColumnType("integer"); - - b.Property("WeirdDelegateId") - .HasColumnType("integer"); - - b.HasIndex("CodeHash"); - - b.HasIndex("CreatorId"); - - b.HasIndex("ManagerId"); - - b.HasIndex("TypeHash"); - - b.HasIndex("WeirdDelegateId"); - - b.HasIndex("Type", "Kind") - .HasFilter("\"Type\" = 2"); - - b.HasDiscriminator().HasValue((byte)2); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)4); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("ActiveStakers") - .HasColumnType("integer"); - - b.Property("CementedCommitments") - .HasColumnType("integer"); - - b.Property("CreatorId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("integer") - .HasColumnName("CreatorId"); - - b.Property("ExecutedCommitments") - .HasColumnType("integer"); - - b.Property("GenesisCommitment") - .HasColumnType("text"); - - b.Property("InboxLevel") - .HasColumnType("integer"); - - b.Property("LastCommitment") - .HasColumnType("text"); - - b.Property("OrphanCommitments") - .HasColumnType("integer"); - - b.Property("PendingCommitments") - .HasColumnType("integer"); - - b.Property("PvmKind") - .HasColumnType("integer"); - - b.Property("RefutedCommitments") - .HasColumnType("integer"); - - b.Property("TotalStakers") - .HasColumnType("integer"); - - b.HasIndex("CreatorId"); - - b.HasDiscriminator().HasValue((byte)5); - }); - - modelBuilder.Entity("Tzkt.Data.Models.User", b => - { - b.HasBaseType("Tzkt.Data.Models.Account"); - - b.Property("Activated") - .HasColumnType("boolean"); - - b.Property("PublicKey") - .HasColumnType("text"); - - b.Property("RegisterConstantsCount") - .HasColumnType("integer"); - - b.Property("Revealed") - .HasColumnType("boolean"); - - b.Property("SetDepositsLimitsCount") - .HasColumnType("integer"); - - b.HasDiscriminator().HasValue((byte)0); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasBaseType("Tzkt.Data.Models.User"); - - b.Property("ActivationLevel") - .HasColumnType("integer"); - - b.Property("BallotsCount") - .HasColumnType("integer"); - - b.Property("BlocksCount") - .HasColumnType("integer"); - - b.Property("DeactivationLevel") - .HasColumnType("integer"); - - b.Property("DelegatedBalance") - .HasColumnType("bigint"); - - b.Property("DelegatorsCount") - .HasColumnType("integer"); - - b.Property("DoubleBakingCount") - .HasColumnType("integer"); - - b.Property("DoubleEndorsingCount") - .HasColumnType("integer"); - - b.Property("DoublePreendorsingCount") - .HasColumnType("integer"); - - b.Property("EndorsementsCount") - .HasColumnType("integer"); - - b.Property("EndorsingRewardsCount") - .HasColumnType("integer"); - - b.Property("FrozenDeposit") - .HasColumnType("bigint"); - - b.Property("FrozenDepositLimit") - .HasColumnType("bigint"); - - b.Property("NonceRevelationsCount") - .HasColumnType("integer"); - - b.Property("PreendorsementsCount") - .HasColumnType("integer"); - - b.Property("ProposalsCount") - .HasColumnType("integer"); - - b.Property("RevelationPenaltiesCount") - .HasColumnType("integer"); - - b.Property("SoftwareId") - .HasColumnType("integer"); - - b.Property("StakingBalance") - .HasColumnType("bigint"); - - b.Property("VdfRevelationsCount") - .HasColumnType("integer"); - - b.HasIndex("SoftwareId"); - - b.HasIndex("Type", "Staked") - .HasFilter("\"Type\" = 1"); - - b.HasDiscriminator().HasValue((byte)1); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Account", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany("DelegatedAccounts") - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") - .WithMany("CreatedAccounts") - .HasForeignKey("FirstLevel") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Delegate"); - - b.Navigation("FirstBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => - { - b.HasOne("Tzkt.Data.Models.User", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Activations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Account"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Ballots") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") - .WithMany() - .HasForeignKey("ProposerId"); - - b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") - .WithMany() - .HasForeignKey("ProtoCode") - .HasPrincipalKey("Code") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") - .WithOne("RevealedBlock") - .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); - - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Proposer"); - - b.Navigation("Protocol"); - - b.Navigation("Revelation"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Delegations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") - .WithMany() - .HasForeignKey("PrevDelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("PrevDelegate"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleBakings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoubleEndorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") - .WithMany() - .HasForeignKey("AccuserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DoublePreendorsings") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Offender") - .WithMany() - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Accuser"); - - b.Navigation("Block"); - - b.Navigation("Offender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("DrainDelegateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Endorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("IncreasePaidStorageOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Account") - .WithMany() - .HasForeignKey("AccountId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Migrations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Account"); - - b.Navigation("Block"); - - b.Navigation("Script"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Revelations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Contract", "Contract") - .WithMany() - .HasForeignKey("ContractId"); - - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId"); - - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Originations") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.Script", "Script") - .WithMany() - .HasForeignKey("ScriptId"); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.Navigation("Block"); - - b.Navigation("Contract"); - - b.Navigation("Delegate"); - - b.Navigation("Initiator"); - - b.Navigation("Manager"); - - b.Navigation("Script"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") - .WithMany() - .HasForeignKey("DelegateId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Preendorsements") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Delegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Proposals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") - .WithMany() - .HasForeignKey("ProposalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Delegate", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Proposal"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RegisterConstants") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Reveals") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("RevelationPenalties") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SetDepositsLimits") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupAddMessagesOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupCementOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupExecuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupOriginateOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupPublishOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRecoverBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("SmartRollupRefuteOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Initiator") - .WithMany() - .HasForeignKey("InitiatorId"); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("Transactions") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Storage", "Storage") - .WithMany() - .HasForeignKey("StorageId"); - - b.HasOne("Tzkt.Data.Models.Account", "Target") - .WithMany() - .HasForeignKey("TargetId"); - - b.Navigation("Block"); - - b.Navigation("Initiator"); - - b.Navigation("Sender"); - - b.Navigation("Storage"); - - b.Navigation("Target"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TransferTicketOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupCommitOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupDispatchTicketsOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupFinalizeCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupOriginationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRejectionOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupRemoveCommitmentOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupReturnBondOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("TxRollupSubmitBatchOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => - { - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("UpdateConsensusKeyOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Account", "Sender") - .WithMany() - .HasForeignKey("SenderId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Block"); - - b.Navigation("Sender"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => - { - b.HasOne("Tzkt.Data.Models.Delegate", "Baker") - .WithMany() - .HasForeignKey("BakerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Tzkt.Data.Models.Block", "Block") - .WithMany("VdfRevelationOps") - .HasForeignKey("Level") - .HasPrincipalKey("Level") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Baker"); - - b.Navigation("Block"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Contract", b => - { - b.HasOne("Tzkt.Data.Models.Account", "Creator") - .WithMany() - .HasForeignKey("CreatorId"); - - b.HasOne("Tzkt.Data.Models.User", "Manager") - .WithMany() - .HasForeignKey("ManagerId"); - - b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") - .WithMany() - .HasForeignKey("WeirdDelegateId"); - - b.Navigation("Creator"); - - b.Navigation("Manager"); - - b.Navigation("WeirdDelegate"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.HasOne("Tzkt.Data.Models.Software", "Software") - .WithMany() - .HasForeignKey("SoftwareId"); - - b.Navigation("Software"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Block", b => - { - b.Navigation("Activations"); - - b.Navigation("Ballots"); - - b.Navigation("CreatedAccounts"); - - b.Navigation("Delegations"); - - b.Navigation("DoubleBakings"); - - b.Navigation("DoubleEndorsings"); - - b.Navigation("DoublePreendorsings"); - - b.Navigation("DrainDelegateOps"); - - b.Navigation("Endorsements"); - - b.Navigation("IncreasePaidStorageOps"); - - b.Navigation("Migrations"); - - b.Navigation("Originations"); - - b.Navigation("Preendorsements"); - - b.Navigation("Proposals"); - - b.Navigation("RegisterConstants"); - - b.Navigation("Reveals"); - - b.Navigation("RevelationPenalties"); - - b.Navigation("Revelations"); - - b.Navigation("SetDepositsLimits"); - - b.Navigation("SmartRollupAddMessagesOps"); - - b.Navigation("SmartRollupCementOps"); - - b.Navigation("SmartRollupExecuteOps"); - - b.Navigation("SmartRollupOriginateOps"); - - b.Navigation("SmartRollupPublishOps"); - - b.Navigation("SmartRollupRecoverBondOps"); - - b.Navigation("SmartRollupRefuteOps"); - - b.Navigation("Transactions"); - - b.Navigation("TransferTicketOps"); - - b.Navigation("TxRollupCommitOps"); - - b.Navigation("TxRollupDispatchTicketsOps"); - - b.Navigation("TxRollupFinalizeCommitmentOps"); - - b.Navigation("TxRollupOriginationOps"); - - b.Navigation("TxRollupRejectionOps"); - - b.Navigation("TxRollupRemoveCommitmentOps"); - - b.Navigation("TxRollupReturnBondOps"); - - b.Navigation("TxRollupSubmitBatchOps"); - - b.Navigation("UpdateConsensusKeyOps"); - - b.Navigation("VdfRevelationOps"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => - { - b.Navigation("RevealedBlock"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => - { - b.Navigation("DelegatedAccounts"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/Tzkt.Data/Migrations/20230807164638_tickets.cs b/Tzkt.Data/Migrations/20230807164638_tickets.cs deleted file mode 100644 index d50c33c8b..000000000 --- a/Tzkt.Data/Migrations/20230807164638_tickets.cs +++ /dev/null @@ -1,211 +0,0 @@ -using System.Numerics; -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class tickets : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "SubIds", - table: "TransferTicketOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "TransferTicketOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "TransactionOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketBalancesCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketTransfersCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "ActiveTicketsCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketBalancesCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketTransfersCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketsCount", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.CreateTable( - name: "TicketBalances", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TicketerId = table.Column(type: "integer", nullable: false), - TicketId = table.Column(type: "bigint", nullable: false), - AccountId = table.Column(type: "integer", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - TransfersCount = table.Column(type: "integer", nullable: false), - Balance = table.Column(type: "numeric", nullable: false), - IndexedAt = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_TicketBalances", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Tickets", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TicketerId = table.Column(type: "integer", nullable: false), - FirstMinterId = table.Column(type: "integer", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - TransfersCount = table.Column(type: "integer", nullable: false), - BalancesCount = table.Column(type: "integer", nullable: false), - HoldersCount = table.Column(type: "integer", nullable: false), - TotalMinted = table.Column(type: "numeric", nullable: false), - TotalBurned = table.Column(type: "numeric", nullable: false), - TotalSupply = table.Column(type: "numeric", nullable: false), - OwnerId = table.Column(type: "integer", nullable: true), - ContentHash = table.Column(type: "integer", nullable: false), - ContentTypeHash = table.Column(type: "integer", nullable: false), - Content = table.Column(type: "bytea", nullable: true), - ContentType = table.Column(type: "bytea", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Tickets", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "TicketTransfers", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Level = table.Column(type: "integer", nullable: false), - TicketerId = table.Column(type: "integer", nullable: false), - TicketId = table.Column(type: "bigint", nullable: false), - Amount = table.Column(type: "numeric", nullable: false), - FromId = table.Column(type: "integer", nullable: true), - ToId = table.Column(type: "integer", nullable: true), - TransferTicketId = table.Column(type: "bigint", nullable: true), - TransactionId = table.Column(type: "bigint", nullable: true), - MigrationId = table.Column(type: "bigint", nullable: true), - IndexedAt = table.Column(type: "integer", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_TicketTransfers", x => x.Id); - }); - - migrationBuilder.UpdateData( - table: "AppState", - keyColumn: "Id", - keyValue: -1, - columns: new[] { "TicketBalancesCount", "TicketTransfersCount", "TicketsCount" }, - values: new object[] { 0, 0, 0 }); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TicketBalances"); - - migrationBuilder.DropTable( - name: "Tickets"); - - migrationBuilder.DropTable( - name: "TicketTransfers"); - - migrationBuilder.DropColumn( - name: "SubIds", - table: "TransferTicketOps"); - - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "TransferTicketOps"); - - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "TransactionOps"); - - migrationBuilder.DropColumn( - name: "TicketBalancesCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "TicketTransfersCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "TicketsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "ActiveTicketsCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketBalancesCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketTransfersCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketsCount", - table: "Accounts"); - } - } -} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 88c6c3214..d220d8ac8 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -1,6 +1,5 @@ // using System; -using System.Numerics; using System.Text.Json; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; @@ -19,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("ProductVersion", "7.0.4") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -35,9 +34,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); - b.Property("ActiveTicketsCount") - .HasColumnType("integer"); - b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -130,12 +126,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -204,7 +194,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Type"); - b.ToTable("Accounts"); + b.ToTable("Accounts", (string)null); b.HasDiscriminator("Type").HasValue((byte)3); @@ -246,7 +236,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("ActivationOps"); + b.ToTable("ActivationOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.AppState", b => @@ -458,15 +448,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageCounter") .HasColumnType("integer"); - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -523,7 +504,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("AppState"); + b.ToTable("AppState", (string)null); b.HasData( new @@ -592,9 +573,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, StorageCounter = 0, - TicketBalancesCount = 0, - TicketTransfersCount = 0, - TicketsCount = 0, Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TokenBalancesCount = 0, TokenTransfersCount = 0, @@ -729,7 +707,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Cycle", "BakerId") .IsUnique(); - b.ToTable("BakerCycles"); + b.ToTable("BakerCycles", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => @@ -769,7 +747,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Cycle", "BakerId"); - b.ToTable("BakingRights"); + b.ToTable("BakingRights", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => @@ -824,7 +802,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("BallotOps"); + b.ToTable("BallotOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => @@ -883,7 +861,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Ptr") .IsUnique(); - b.ToTable("BigMaps"); + b.ToTable("BigMaps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => @@ -949,7 +927,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("BigMapPtr", "KeyHash"); - b.ToTable("BigMapKeys"); + b.ToTable("BigMapKeys", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => @@ -1008,7 +986,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TransactionId") .HasFilter("\"TransactionId\" is not null"); - b.ToTable("BigMapUpdates"); + b.ToTable("BigMapUpdates", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Block", b => @@ -1110,7 +1088,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SoftwareId"); - b.ToTable("Blocks"); + b.ToTable("Blocks", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => @@ -1144,7 +1122,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Id") .IsUnique(); - b.ToTable("Commitments"); + b.ToTable("Commitments", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => @@ -1203,7 +1181,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContractId", "Tag"); - b.ToTable("Events"); + b.ToTable("Events", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => @@ -1260,7 +1238,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Index") .IsUnique(); - b.ToTable("Cycles"); + b.ToTable("Cycles", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => @@ -1354,7 +1332,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("DelegationOps"); + b.ToTable("DelegationOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => @@ -1388,7 +1366,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Cycle", "DelegatorId") .IsUnique(); - b.ToTable("DelegatorCycles"); + b.ToTable("DelegatorCycles", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Domain", b => @@ -1440,7 +1418,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Owner"); - b.ToTable("Domains"); + b.ToTable("Domains", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => @@ -1488,7 +1466,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("DoubleBakingOps"); + b.ToTable("DoubleBakingOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => @@ -1536,7 +1514,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("DoubleEndorsingOps"); + b.ToTable("DoubleEndorsingOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => @@ -1584,7 +1562,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("DoublePreendorsingOps"); + b.ToTable("DoublePreendorsingOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => @@ -1629,7 +1607,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TargetId"); - b.ToTable("DrainDelegateOps"); + b.ToTable("DrainDelegateOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => @@ -1675,7 +1653,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("EndorsementOps"); + b.ToTable("EndorsementOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => @@ -1707,7 +1685,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level"); - b.ToTable("EndorsingRewardOps"); + b.ToTable("EndorsingRewardOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => @@ -1731,7 +1709,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Cycle"); - b.ToTable("FreezerUpdates"); + b.ToTable("FreezerUpdates", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => @@ -1768,7 +1746,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Type", "Id"); - b.ToTable("InboxMessages"); + b.ToTable("InboxMessages", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => @@ -1841,7 +1819,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("IncreasePaidStorageOps"); + b.ToTable("IncreasePaidStorageOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => @@ -1892,7 +1870,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("StorageId"); - b.ToTable("MigrationOps"); + b.ToTable("MigrationOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => @@ -1950,7 +1928,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("NonceRevelationOps"); + b.ToTable("NonceRevelationOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => @@ -2071,7 +2049,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("StorageId"); - b.ToTable("OriginationOps"); + b.ToTable("OriginationOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => @@ -2111,7 +2089,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("PreendorsementOps"); + b.ToTable("PreendorsementOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => @@ -2157,7 +2135,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Hash"); - b.ToTable("Proposals"); + b.ToTable("Proposals", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => @@ -2212,7 +2190,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("ProposalOps"); + b.ToTable("ProposalOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => @@ -2384,7 +2362,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Protocols"); + b.ToTable("Protocols", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Quote", b => @@ -2430,7 +2408,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level") .IsUnique(); - b.ToTable("Quotes"); + b.ToTable("Quotes", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => @@ -2493,7 +2471,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId"); - b.ToTable("RefutationGames"); + b.ToTable("RefutationGames", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => @@ -2571,7 +2549,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("RegisterConstantOps"); + b.ToTable("RegisterConstantOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => @@ -2635,7 +2613,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("RevealOps"); + b.ToTable("RevealOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => @@ -2667,7 +2645,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level"); - b.ToTable("RevelationPenaltyOps"); + b.ToTable("RevelationPenaltyOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Script", b => @@ -2719,7 +2697,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContractId", "Current") .HasFilter("\"Current\" = true"); - b.ToTable("Scripts"); + b.ToTable("Scripts", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => @@ -2783,7 +2761,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("SetDepositsLimitOps"); + b.ToTable("SetDepositsLimitOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => @@ -2850,7 +2828,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("SmartRollupAddMessagesOps"); + b.ToTable("SmartRollupAddMessagesOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => @@ -2920,7 +2898,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("SmartRollupCementOps"); + b.ToTable("SmartRollupCementOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => @@ -2984,7 +2962,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Hash", "SmartRollupId"); - b.ToTable("SmartRollupCommitments"); + b.ToTable("SmartRollupCommitments", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => @@ -3058,7 +3036,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId"); - b.ToTable("SmartRollupExecuteOps"); + b.ToTable("SmartRollupExecuteOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => @@ -3142,7 +3120,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId"); - b.ToTable("SmartRollupOriginateOps"); + b.ToTable("SmartRollupOriginateOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => @@ -3228,7 +3206,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId", "BondStatus", "SenderId") .HasFilter("\"BondStatus\" IS NOT NULL"); - b.ToTable("SmartRollupPublishOps"); + b.ToTable("SmartRollupPublishOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => @@ -3305,7 +3283,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("StakerId"); - b.ToTable("SmartRollupRecoverBondOps"); + b.ToTable("SmartRollupRecoverBondOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => @@ -3394,7 +3372,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId"); - b.ToTable("SmartRollupRefuteOps"); + b.ToTable("SmartRollupRefuteOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => @@ -3431,7 +3409,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level") .HasFilter("\"DelegateId\" IS NULL"); - b.ToTable("SnapshotBalances"); + b.ToTable("SnapshotBalances", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Software", b => @@ -3462,7 +3440,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Software"); + b.ToTable("Software", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => @@ -3522,7 +3500,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level") .IsUnique(); - b.ToTable("Statistics"); + b.ToTable("Statistics", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Storage", b => @@ -3569,145 +3547,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContractId", "Current") .HasFilter("\"Current\" = true"); - b.ToTable("Storages"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("Content") - .HasColumnType("bytea"); - - b.Property("ContentHash") - .HasColumnType("integer"); - - b.Property("ContentType") - .HasColumnType("bytea"); - - b.Property("ContentTypeHash") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("OwnerId") - .HasColumnType("integer"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TotalBurned") - .HasColumnType("numeric"); - - b.Property("TotalMinted") - .HasColumnType("numeric"); - - b.Property("TotalSupply") - .HasColumnType("numeric"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .HasColumnType("numeric"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.ToTable("TicketBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .HasColumnType("numeric"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("IndexedAt") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("TransferTicketId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.ToTable("TicketTransfers"); + b.ToTable("Storages", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Token", b => @@ -3789,7 +3629,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContractId", "TokenId") .IsUnique(); - b.ToTable("Tokens"); + b.ToTable("Tokens", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => @@ -3849,7 +3689,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("AccountId", "TokenId") .IsUnique(); - b.ToTable("TokenBalances"); + b.ToTable("TokenBalances", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => @@ -3920,7 +3760,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TransactionId") .HasFilter("\"TransactionId\" is not null"); - b.ToTable("TokenTransfers"); + b.ToTable("TokenTransfers", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => @@ -4027,9 +3867,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -4061,7 +3898,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TargetId"); - b.ToTable("TransactionOps"); + b.ToTable("TransactionOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => @@ -4130,15 +3967,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); - b.Property("SubIds") - .HasColumnType("integer"); - b.Property("TargetId") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("TicketerId") .HasColumnType("integer"); @@ -4157,7 +3988,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TicketerId"); - b.ToTable("TransferTicketOps"); + b.ToTable("TransferTicketOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => @@ -4229,7 +4060,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupCommitOps"); + b.ToTable("TxRollupCommitOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => @@ -4298,7 +4129,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupDispatchTicketsOps"); + b.ToTable("TxRollupDispatchTicketsOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => @@ -4367,7 +4198,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupFinalizeCommitmentOps"); + b.ToTable("TxRollupFinalizeCommitmentOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => @@ -4436,7 +4267,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupOriginationOps"); + b.ToTable("TxRollupOriginationOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => @@ -4516,7 +4347,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupRejectionOps"); + b.ToTable("TxRollupRejectionOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => @@ -4585,7 +4416,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupRemoveCommitmentOps"); + b.ToTable("TxRollupRemoveCommitmentOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => @@ -4657,7 +4488,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupReturnBondOps"); + b.ToTable("TxRollupReturnBondOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => @@ -4726,7 +4557,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupSubmitBatchOps"); + b.ToTable("TxRollupSubmitBatchOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => @@ -4799,7 +4630,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("UpdateConsensusKeyOps"); + b.ToTable("UpdateConsensusKeyOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => @@ -4847,7 +4678,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("VdfRevelationOps"); + b.ToTable("VdfRevelationOps", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => @@ -4939,7 +4770,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Index") .IsUnique(); - b.ToTable("VotingPeriods"); + b.ToTable("VotingPeriods", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => @@ -4972,7 +4803,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Period", "BakerId") .IsUnique(); - b.ToTable("VotingSnapshots"); + b.ToTable("VotingSnapshots", (string)null); }); modelBuilder.Entity("Tzkt.Data.Models.Contract", b => @@ -5002,9 +4833,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); - b.Property("TicketsCount") - .HasColumnType("integer"); - b.Property("TokensCount") .HasColumnType("integer"); diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs index 1aeebdd50..fd9f595f4 100644 --- a/Tzkt.Data/Models/Scripts/TIcket.cs +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -22,6 +22,7 @@ public class Ticket public BigInteger TotalBurned { get; set; } public BigInteger TotalSupply { get; set; } + //TODO Make sure we need that public int? OwnerId { get; set; } public int ContentHash { get; set; } diff --git a/Tzkt.Data/Models/Scripts/TicketBalance.cs b/Tzkt.Data/Models/Scripts/TicketBalance.cs index dacad5984..d975ae576 100644 --- a/Tzkt.Data/Models/Scripts/TicketBalance.cs +++ b/Tzkt.Data/Models/Scripts/TicketBalance.cs @@ -15,7 +15,6 @@ public class TicketBalance public int LastLevel { get; set; } public int TransfersCount { get; set; } public BigInteger Balance { get; set; } - public int? IndexedAt { get; set; } } public static class TicketBalanceModel @@ -73,10 +72,6 @@ public static void BuildTicketBalanceModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.LastLevel); - - modelBuilder.Entity() - .HasIndex(x => x.IndexedAt) - .HasFilter($@"""{nameof(TicketBalance.IndexedAt)}"" is not null"); #endregion } } diff --git a/Tzkt.Data/Models/Scripts/TicketTransfer.cs b/Tzkt.Data/Models/Scripts/TicketTransfer.cs index 0a768e533..9ecb8a03d 100644 --- a/Tzkt.Data/Models/Scripts/TicketTransfer.cs +++ b/Tzkt.Data/Models/Scripts/TicketTransfer.cs @@ -18,7 +18,6 @@ public class TicketTransfer public long? TransferTicketId { get; set; } public long? TransactionId { get; set; } public long? MigrationId { get; set; } - public int? IndexedAt { get; set; } } public static class TicketTransferModel @@ -55,10 +54,6 @@ public static void BuildTicketTransferModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.Level); - modelBuilder.Entity() - .HasIndex(x => x.IndexedAt) - .HasFilter($@"""{nameof(TicketTransfer.IndexedAt)}"" is not null"); - modelBuilder.Entity() .HasIndex(x => x.TransferTicketId) .HasFilter($@"""{nameof(TicketTransfer.TransferTicketId)}"" is not null"); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 24d916455..3967a294a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -198,8 +198,7 @@ TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Accou TicketerId = ticket.TicketerId, FirstLevel = op.Level, LastLevel = op.Level, - Balance = BigInteger.Zero, - IndexedAt = op.Level <= state.Level ? state.Level + 1 : null + Balance = BigInteger.Zero }; Db.TicketBalances.Add(ticketBalance); Cache.TicketBalances.Add(ticketBalance); @@ -236,9 +235,14 @@ void TransferTickets(ManagerOperation op, Contract contract, Ticket ticket, Db.TryAttach(from); from.TicketTransfersCount++; + from.LastLevel = op.Level; Db.TryAttach(to); - if (to != from) to.TicketTransfersCount++; + if (to != from) + { + to.TicketTransfersCount++; + to.LastLevel = op.Level; + } Db.TryAttach(fromBalance); fromBalance.Balance -= amount; @@ -285,14 +289,13 @@ void TransferTickets(ManagerOperation op, Contract contract, Ticket ticket, TicketId = ticket.Id, TicketerId = ticket.TicketerId, TransactionId = (op as TransactionOperation)?.Id, - TransferTicketId = (op as OriginationOperation)?.Id, - IndexedAt = op.Level <= state.Level ? state.Level + 1 : null + TransferTicketId = (op as OriginationOperation)?.Id }); } void MintOrBurnTickets(ManagerOperation op, Ticket ticket, Account account, TicketBalance balance, - BigInteger diff) + BigInteger amount) { switch (op) { @@ -306,26 +309,29 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, Db.TryAttach(account); account.TicketTransfersCount++; + account.LastLevel = op.Level; Db.TryAttach(balance); - balance.Balance += diff; + balance.Balance += amount; balance.TransfersCount++; balance.LastLevel = op.Level; + //TODO Check transfersCount, balancesCount, holdersCount ticket.TransfersCount++; + ticket.LastLevel = op.Level; if (balance.Balance == BigInteger.Zero) { account.ActiveTicketsCount--; ticket.HoldersCount--; } - if (balance.Balance == diff) + if (balance.Balance == amount) { account.ActiveTicketsCount++; ticket.HoldersCount++; } - if (diff > 0) ticket.TotalMinted += diff; - else ticket.TotalBurned += -diff; - ticket.TotalSupply += diff; + if (amount > 0) ticket.TotalMinted += amount; + else ticket.TotalBurned += -amount; + ticket.TotalSupply += amount; var state = Cache.AppState.Get(); state.TicketTransfersCount++; @@ -338,15 +344,14 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, - Amount = diff > BigInteger.Zero ? diff : -diff, - FromId = diff < BigInteger.Zero ? account.Id : null, - ToId = diff > BigInteger.Zero ? account.Id : null, + Amount = amount > BigInteger.Zero ? amount : -amount, + FromId = amount < BigInteger.Zero ? account.Id : null, + ToId = amount > BigInteger.Zero ? account.Id : null, Level = op.Level, TicketId = ticket.Id, TicketerId = ticket.TicketerId, TransactionId = (op as TransactionOperation)?.Id, - TransferTicketId = (op as TransferTicketOperation)?.Id, - IndexedAt = op.Level <= state.Level ? state.Level + 1 : null + TransferTicketId = (op as TransferTicketOperation)?.Id }); } From d7ca9e9d3550d55b96fe544cdf0c8686ebbbfa94 Mon Sep 17 00:00:00 2001 From: dmir Date: Wed, 9 Aug 2023 19:24:11 +0300 Subject: [PATCH 18/51] Fixes --- .../Migrations/20230425183139_Nairobi.cs | 28 -- ....cs => 20230809161830_tickets.Designer.cs} | 236 ++++++++++- .../Migrations/20230809161830_tickets.cs | 338 ++++++++++++++++ .../Migrations/TzktContextModelSnapshot.cs | 368 ++++++++++++++---- Tzkt.Data/Models/Scripts/TIcket.cs | 13 +- Tzkt.Data/TzktContext.cs | 6 + .../Commits/Operations/TransactionsCommit.cs | 53 ++- .../Operations/TransferTicketCommit.cs | 46 ++- .../Operations/SmartRollupExecuteCommit.cs | 51 ++- .../Commits/Operations/TransactionsCommit.cs | 50 ++- .../Handlers/Proto17/Commits/TicketsCommit.cs | 90 ++--- .../Proto17/Diagnostics/Diagnostics.cs | 4 +- .../Handlers/Proto17/Proto17Handler.cs | 12 +- Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs | 6 +- 14 files changed, 1076 insertions(+), 225 deletions(-) delete mode 100644 Tzkt.Data/Migrations/20230425183139_Nairobi.cs rename Tzkt.Data/Migrations/{20230425183139_Nairobi.Designer.cs => 20230809161830_tickets.Designer.cs} (96%) create mode 100644 Tzkt.Data/Migrations/20230809161830_tickets.cs diff --git a/Tzkt.Data/Migrations/20230425183139_Nairobi.cs b/Tzkt.Data/Migrations/20230425183139_Nairobi.cs deleted file mode 100644 index e5e425504..000000000 --- a/Tzkt.Data/Migrations/20230425183139_Nairobi.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class Nairobi : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Protocol", - table: "InboxMessages", - type: "text", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Protocol", - table: "InboxMessages"); - } - } -} diff --git a/Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs b/Tzkt.Data/Migrations/20230809161830_tickets.Designer.cs similarity index 96% rename from Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs rename to Tzkt.Data/Migrations/20230809161830_tickets.Designer.cs index 0d4207510..2b984129c 100644 --- a/Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs +++ b/Tzkt.Data/Migrations/20230809161830_tickets.Designer.cs @@ -13,15 +13,15 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230425183139_Nairobi")] - partial class Nairobi + [Migration("20230809161830_tickets")] + partial class tickets { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("ProductVersion", "7.0.5") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -37,6 +37,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -129,6 +132,12 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -451,6 +460,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("StorageCounter") .HasColumnType("integer"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -576,6 +594,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TokenBalancesCount = 0, TokenTransfersCount = 0, @@ -3553,6 +3574,203 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("Storages"); }); + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentTypeHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("TicketerId"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LastLevel"); + + b.HasIndex("TicketId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("TicketerId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "TicketId") + .IsUnique(); + + b.HasIndex("AccountId", "TicketerId"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("TransferTicketId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.HasIndex("TransferTicketId") + .HasFilter("\"TransferTicketId\" is not null"); + + b.ToTable("TicketTransfers"); + }); + modelBuilder.Entity("Tzkt.Data.Models.Token", b => { b.Property("Id") @@ -3870,6 +4088,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3970,9 +4191,15 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("TicketerId") .HasColumnType("integer"); @@ -4836,6 +5063,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("TokensCount") .HasColumnType("integer"); diff --git a/Tzkt.Data/Migrations/20230809161830_tickets.cs b/Tzkt.Data/Migrations/20230809161830_tickets.cs new file mode 100644 index 000000000..5846ed8cb --- /dev/null +++ b/Tzkt.Data/Migrations/20230809161830_tickets.cs @@ -0,0 +1,338 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class tickets : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SubIds", + table: "TransferTicketOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "TransferTicketOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "TransactionOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "Protocol", + table: "InboxMessages", + type: "text", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketBalancesCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketTransfersCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketsCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ActiveTicketsCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketBalancesCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketTransfersCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketsCount", + table: "Accounts", + type: "integer", + nullable: true); + + migrationBuilder.CreateTable( + name: "TicketBalances", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TicketerId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "bigint", nullable: false), + AccountId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + Balance = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketBalances", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Tickets", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TicketerId = table.Column(type: "integer", nullable: false), + FirstMinterId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + BalancesCount = table.Column(type: "integer", nullable: false), + HoldersCount = table.Column(type: "integer", nullable: false), + TotalMinted = table.Column(type: "text", nullable: false), + TotalBurned = table.Column(type: "text", nullable: false), + TotalSupply = table.Column(type: "text", nullable: false), + ContentHash = table.Column(type: "integer", nullable: false), + ContentTypeHash = table.Column(type: "integer", nullable: false), + RawContent = table.Column(type: "bytea", nullable: true), + RawType = table.Column(type: "bytea", nullable: true), + JsonContent = table.Column(type: "text", nullable: true), + Metadata = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tickets", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TicketTransfers", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Level = table.Column(type: "integer", nullable: false), + TicketerId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "bigint", nullable: false), + Amount = table.Column(type: "text", nullable: false), + FromId = table.Column(type: "integer", nullable: true), + ToId = table.Column(type: "integer", nullable: true), + TransferTicketId = table.Column(type: "bigint", nullable: true), + TransactionId = table.Column(type: "bigint", nullable: true), + MigrationId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketTransfers", x => x.Id); + }); + + migrationBuilder.UpdateData( + table: "AppState", + keyColumn: "Id", + keyValue: -1, + columns: new[] { "TicketBalancesCount", "TicketTransfersCount", "TicketsCount" }, + values: new object[] { 0, 0, 0 }); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId", + table: "TicketBalances", + column: "AccountId", + filter: "\"Balance\" != '0'"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId_TicketerId", + table: "TicketBalances", + columns: new[] { "AccountId", "TicketerId" }); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId_TicketId", + table: "TicketBalances", + columns: new[] { "AccountId", "TicketId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_Id", + table: "TicketBalances", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_LastLevel", + table: "TicketBalances", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_TicketerId", + table: "TicketBalances", + column: "TicketerId", + filter: "\"Balance\" != '0'"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_TicketId", + table: "TicketBalances", + column: "TicketId", + filter: "\"Balance\" != '0'"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_FirstMinterId", + table: "Tickets", + column: "FirstMinterId"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_Id", + table: "Tickets", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_LastLevel", + table: "Tickets", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_Metadata", + table: "Tickets", + column: "Metadata") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_TicketerId", + table: "Tickets", + column: "TicketerId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_FromId", + table: "TicketTransfers", + column: "FromId", + filter: "\"FromId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_Id", + table: "TicketTransfers", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_Level", + table: "TicketTransfers", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_MigrationId", + table: "TicketTransfers", + column: "MigrationId", + filter: "\"MigrationId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TicketerId", + table: "TicketTransfers", + column: "TicketerId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TicketId", + table: "TicketTransfers", + column: "TicketId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_ToId", + table: "TicketTransfers", + column: "ToId", + filter: "\"ToId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TransactionId", + table: "TicketTransfers", + column: "TransactionId", + filter: "\"TransactionId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TransferTicketId", + table: "TicketTransfers", + column: "TransferTicketId", + filter: "\"TransferTicketId\" is not null"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TicketBalances"); + + migrationBuilder.DropTable( + name: "Tickets"); + + migrationBuilder.DropTable( + name: "TicketTransfers"); + + migrationBuilder.DropColumn( + name: "SubIds", + table: "TransferTicketOps"); + + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "TransferTicketOps"); + + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "TransactionOps"); + + migrationBuilder.DropColumn( + name: "Protocol", + table: "InboxMessages"); + + migrationBuilder.DropColumn( + name: "TicketBalancesCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "TicketTransfersCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "TicketsCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "ActiveTicketsCount", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketBalancesCount", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketTransfersCount", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketsCount", + table: "Accounts"); + } + } +} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index d220d8ac8..5ca456812 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("ProductVersion", "7.0.5") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -34,6 +34,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -126,6 +129,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -194,7 +203,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Type"); - b.ToTable("Accounts", (string)null); + b.ToTable("Accounts"); b.HasDiscriminator("Type").HasValue((byte)3); @@ -236,7 +245,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("ActivationOps", (string)null); + b.ToTable("ActivationOps"); }); modelBuilder.Entity("Tzkt.Data.Models.AppState", b => @@ -448,6 +457,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageCounter") .HasColumnType("integer"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -504,7 +522,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("AppState", (string)null); + b.ToTable("AppState"); b.HasData( new @@ -573,6 +591,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TokenBalancesCount = 0, TokenTransfersCount = 0, @@ -707,7 +728,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Cycle", "BakerId") .IsUnique(); - b.ToTable("BakerCycles", (string)null); + b.ToTable("BakerCycles"); }); modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => @@ -747,7 +768,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Cycle", "BakerId"); - b.ToTable("BakingRights", (string)null); + b.ToTable("BakingRights"); }); modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => @@ -802,7 +823,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("BallotOps", (string)null); + b.ToTable("BallotOps"); }); modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => @@ -861,7 +882,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Ptr") .IsUnique(); - b.ToTable("BigMaps", (string)null); + b.ToTable("BigMaps"); }); modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => @@ -927,7 +948,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("BigMapPtr", "KeyHash"); - b.ToTable("BigMapKeys", (string)null); + b.ToTable("BigMapKeys"); }); modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => @@ -986,7 +1007,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TransactionId") .HasFilter("\"TransactionId\" is not null"); - b.ToTable("BigMapUpdates", (string)null); + b.ToTable("BigMapUpdates"); }); modelBuilder.Entity("Tzkt.Data.Models.Block", b => @@ -1088,7 +1109,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SoftwareId"); - b.ToTable("Blocks", (string)null); + b.ToTable("Blocks"); }); modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => @@ -1122,7 +1143,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Id") .IsUnique(); - b.ToTable("Commitments", (string)null); + b.ToTable("Commitments"); }); modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => @@ -1181,7 +1202,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContractId", "Tag"); - b.ToTable("Events", (string)null); + b.ToTable("Events"); }); modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => @@ -1238,7 +1259,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Index") .IsUnique(); - b.ToTable("Cycles", (string)null); + b.ToTable("Cycles"); }); modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => @@ -1332,7 +1353,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("DelegationOps", (string)null); + b.ToTable("DelegationOps"); }); modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => @@ -1366,7 +1387,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Cycle", "DelegatorId") .IsUnique(); - b.ToTable("DelegatorCycles", (string)null); + b.ToTable("DelegatorCycles"); }); modelBuilder.Entity("Tzkt.Data.Models.Domain", b => @@ -1418,7 +1439,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Owner"); - b.ToTable("Domains", (string)null); + b.ToTable("Domains"); }); modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => @@ -1466,7 +1487,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("DoubleBakingOps", (string)null); + b.ToTable("DoubleBakingOps"); }); modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => @@ -1514,7 +1535,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("DoubleEndorsingOps", (string)null); + b.ToTable("DoubleEndorsingOps"); }); modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => @@ -1562,7 +1583,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("DoublePreendorsingOps", (string)null); + b.ToTable("DoublePreendorsingOps"); }); modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => @@ -1607,7 +1628,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TargetId"); - b.ToTable("DrainDelegateOps", (string)null); + b.ToTable("DrainDelegateOps"); }); modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => @@ -1653,7 +1674,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("EndorsementOps", (string)null); + b.ToTable("EndorsementOps"); }); modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => @@ -1685,7 +1706,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level"); - b.ToTable("EndorsingRewardOps", (string)null); + b.ToTable("EndorsingRewardOps"); }); modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => @@ -1709,7 +1730,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Cycle"); - b.ToTable("FreezerUpdates", (string)null); + b.ToTable("FreezerUpdates"); }); modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => @@ -1746,7 +1767,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Type", "Id"); - b.ToTable("InboxMessages", (string)null); + b.ToTable("InboxMessages"); }); modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => @@ -1819,7 +1840,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("IncreasePaidStorageOps", (string)null); + b.ToTable("IncreasePaidStorageOps"); }); modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => @@ -1870,7 +1891,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("StorageId"); - b.ToTable("MigrationOps", (string)null); + b.ToTable("MigrationOps"); }); modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => @@ -1928,7 +1949,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("NonceRevelationOps", (string)null); + b.ToTable("NonceRevelationOps"); }); modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => @@ -2049,7 +2070,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("StorageId"); - b.ToTable("OriginationOps", (string)null); + b.ToTable("OriginationOps"); }); modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => @@ -2089,7 +2110,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("PreendorsementOps", (string)null); + b.ToTable("PreendorsementOps"); }); modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => @@ -2135,7 +2156,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Hash"); - b.ToTable("Proposals", (string)null); + b.ToTable("Proposals"); }); modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => @@ -2190,7 +2211,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("ProposalOps", (string)null); + b.ToTable("ProposalOps"); }); modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => @@ -2362,7 +2383,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Protocols", (string)null); + b.ToTable("Protocols"); }); modelBuilder.Entity("Tzkt.Data.Models.Quote", b => @@ -2408,7 +2429,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level") .IsUnique(); - b.ToTable("Quotes", (string)null); + b.ToTable("Quotes"); }); modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => @@ -2471,7 +2492,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId"); - b.ToTable("RefutationGames", (string)null); + b.ToTable("RefutationGames"); }); modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => @@ -2549,7 +2570,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("RegisterConstantOps", (string)null); + b.ToTable("RegisterConstantOps"); }); modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => @@ -2613,7 +2634,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("RevealOps", (string)null); + b.ToTable("RevealOps"); }); modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => @@ -2645,7 +2666,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level"); - b.ToTable("RevelationPenaltyOps", (string)null); + b.ToTable("RevelationPenaltyOps"); }); modelBuilder.Entity("Tzkt.Data.Models.Script", b => @@ -2697,7 +2718,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContractId", "Current") .HasFilter("\"Current\" = true"); - b.ToTable("Scripts", (string)null); + b.ToTable("Scripts"); }); modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => @@ -2761,7 +2782,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("SetDepositsLimitOps", (string)null); + b.ToTable("SetDepositsLimitOps"); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => @@ -2828,7 +2849,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("SmartRollupAddMessagesOps", (string)null); + b.ToTable("SmartRollupAddMessagesOps"); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => @@ -2898,7 +2919,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("SmartRollupCementOps", (string)null); + b.ToTable("SmartRollupCementOps"); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => @@ -2962,7 +2983,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Hash", "SmartRollupId"); - b.ToTable("SmartRollupCommitments", (string)null); + b.ToTable("SmartRollupCommitments"); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => @@ -3036,7 +3057,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId"); - b.ToTable("SmartRollupExecuteOps", (string)null); + b.ToTable("SmartRollupExecuteOps"); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => @@ -3120,7 +3141,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId"); - b.ToTable("SmartRollupOriginateOps", (string)null); + b.ToTable("SmartRollupOriginateOps"); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => @@ -3206,7 +3227,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId", "BondStatus", "SenderId") .HasFilter("\"BondStatus\" IS NOT NULL"); - b.ToTable("SmartRollupPublishOps", (string)null); + b.ToTable("SmartRollupPublishOps"); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => @@ -3283,7 +3304,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("StakerId"); - b.ToTable("SmartRollupRecoverBondOps", (string)null); + b.ToTable("SmartRollupRecoverBondOps"); }); modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => @@ -3372,7 +3393,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SmartRollupId"); - b.ToTable("SmartRollupRefuteOps", (string)null); + b.ToTable("SmartRollupRefuteOps"); }); modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => @@ -3409,7 +3430,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level") .HasFilter("\"DelegateId\" IS NULL"); - b.ToTable("SnapshotBalances", (string)null); + b.ToTable("SnapshotBalances"); }); modelBuilder.Entity("Tzkt.Data.Models.Software", b => @@ -3440,7 +3461,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Software", (string)null); + b.ToTable("Software"); }); modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => @@ -3500,7 +3521,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level") .IsUnique(); - b.ToTable("Statistics", (string)null); + b.ToTable("Statistics"); }); modelBuilder.Entity("Tzkt.Data.Models.Storage", b => @@ -3547,7 +3568,204 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContractId", "Current") .HasFilter("\"Current\" = true"); - b.ToTable("Storages", (string)null); + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentTypeHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("TicketerId"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LastLevel"); + + b.HasIndex("TicketId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("TicketerId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "TicketId") + .IsUnique(); + + b.HasIndex("AccountId", "TicketerId"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("TransferTicketId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.HasIndex("TransferTicketId") + .HasFilter("\"TransferTicketId\" is not null"); + + b.ToTable("TicketTransfers"); }); modelBuilder.Entity("Tzkt.Data.Models.Token", b => @@ -3629,7 +3847,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContractId", "TokenId") .IsUnique(); - b.ToTable("Tokens", (string)null); + b.ToTable("Tokens"); }); modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => @@ -3689,7 +3907,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("AccountId", "TokenId") .IsUnique(); - b.ToTable("TokenBalances", (string)null); + b.ToTable("TokenBalances"); }); modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => @@ -3760,7 +3978,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TransactionId") .HasFilter("\"TransactionId\" is not null"); - b.ToTable("TokenTransfers", (string)null); + b.ToTable("TokenTransfers"); }); modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => @@ -3867,6 +4085,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3898,7 +4119,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TargetId"); - b.ToTable("TransactionOps", (string)null); + b.ToTable("TransactionOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => @@ -3967,9 +4188,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("TicketerId") .HasColumnType("integer"); @@ -3988,7 +4215,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TicketerId"); - b.ToTable("TransferTicketOps", (string)null); + b.ToTable("TransferTicketOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => @@ -4060,7 +4287,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupCommitOps", (string)null); + b.ToTable("TxRollupCommitOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => @@ -4129,7 +4356,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupDispatchTicketsOps", (string)null); + b.ToTable("TxRollupDispatchTicketsOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => @@ -4198,7 +4425,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupFinalizeCommitmentOps", (string)null); + b.ToTable("TxRollupFinalizeCommitmentOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => @@ -4267,7 +4494,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupOriginationOps", (string)null); + b.ToTable("TxRollupOriginationOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => @@ -4347,7 +4574,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupRejectionOps", (string)null); + b.ToTable("TxRollupRejectionOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => @@ -4416,7 +4643,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupRemoveCommitmentOps", (string)null); + b.ToTable("TxRollupRemoveCommitmentOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => @@ -4488,7 +4715,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupReturnBondOps", (string)null); + b.ToTable("TxRollupReturnBondOps"); }); modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => @@ -4557,7 +4784,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("TxRollupSubmitBatchOps", (string)null); + b.ToTable("TxRollupSubmitBatchOps"); }); modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => @@ -4630,7 +4857,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("SenderId"); - b.ToTable("UpdateConsensusKeyOps", (string)null); + b.ToTable("UpdateConsensusKeyOps"); }); modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => @@ -4678,7 +4905,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("OpHash"); - b.ToTable("VdfRevelationOps", (string)null); + b.ToTable("VdfRevelationOps"); }); modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => @@ -4770,7 +4997,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Index") .IsUnique(); - b.ToTable("VotingPeriods", (string)null); + b.ToTable("VotingPeriods"); }); modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => @@ -4803,7 +5030,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Period", "BakerId") .IsUnique(); - b.ToTable("VotingSnapshots", (string)null); + b.ToTable("VotingSnapshots"); }); modelBuilder.Entity("Tzkt.Data.Models.Contract", b => @@ -4833,6 +5060,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("TokensCount") .HasColumnType("integer"); diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs index fd9f595f4..aa62182ee 100644 --- a/Tzkt.Data/Models/Scripts/TIcket.cs +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -1,5 +1,4 @@ -using System; -using System.Numerics; +using System.Numerics; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -22,14 +21,14 @@ public class Ticket public BigInteger TotalBurned { get; set; } public BigInteger TotalSupply { get; set; } - //TODO Make sure we need that - public int? OwnerId { get; set; } - public int ContentHash { get; set; } public int ContentTypeHash { get; set; } - public byte[] Content { get; set; } - public byte[] ContentType { get; set; } + //TODO Do we need to build models? + //TODO To RawContent like in TransferTicketOps? + public byte[] RawContent { get; set; } + public byte[] RawType { get; set; } + public string JsonContent { get; set; } } public static class TicketModel diff --git a/Tzkt.Data/TzktContext.cs b/Tzkt.Data/TzktContext.cs index 22d6d53b2..e9c6db056 100644 --- a/Tzkt.Data/TzktContext.cs +++ b/Tzkt.Data/TzktContext.cs @@ -233,6 +233,12 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.BuildTokenTransferModel(); #endregion + #region tickets + modelBuilder.BuildTicketModel(); + modelBuilder.BuildTicketBalanceModel(); + modelBuilder.BuildTicketTransferModel(); + #endregion + #region rollups modelBuilder.BuildSmartRollupCommitmentModel(); modelBuilder.BuildRefutationGameModel(); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index 0f4d310d0..4e49e44e8 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -697,28 +697,41 @@ protected virtual IEnumerable ParseTicketUpdates(string property, if (!result.TryGetProperty(property, out var ticketUpdates)) return null; - return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + var res = new List(); + foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { - TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) - ? new TicketToken - { - Ticketer = ticketToken.RequiredString("ticketer"), - ContentType = ticketToken.TryGetProperty("content_type", out var contentType) - ? Micheline.FromJson(contentType) - : null, - Content = ticketToken.TryGetProperty("content", out var content) - ? Micheline.FromJson(content) - : null, - } - : null, - Updates = x.TryGetProperty("updates", out var updates) - ? updates.RequiredArray().EnumerateArray().Select(y => new Update + try + { + var ticketToken = update.Required("ticket_token"); + var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); + var value = Micheline.FromJson(ticketToken.Required("content")); + var rawContent = micheType.Optimize(value).ToBytes(); + var rawType = micheType.ToMicheline().ToBytes(); + res.Add(new TicketUpdate { - Account = y.RequiredString("account"), - Amount = y.RequiredString("amount") - }) - : null - }); + TicketToken = new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + RawType = rawType, + RawContent = rawContent, + JsonContent = micheType.Humanize(value), + ContentTypeHash = Script.GetHash(rawType), + ContentHash = Script.GetHash(rawContent) + }, + Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = y.RequiredString("amount") + }) + }); + } + catch (Exception ex) + { + Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); + } + } + + return res; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index ed4141f5f..259e2dff0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -205,14 +205,52 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; - return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + var res = new List(); + foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { + try + { + var ticketToken = update.Required("ticket_token"); + var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); + var value = Micheline.FromJson(ticketToken.Required("content")); + var rawContent = micheType.Optimize(value).ToBytes(); + var rawType = micheType.ToMicheline().ToBytes(); + res.Add(new TicketUpdate + { + TicketToken = new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + RawType = rawType, + RawContent = rawContent, + JsonContent = micheType.Humanize(value), + ContentTypeHash = Script.GetHash(rawType), + ContentHash = Script.GetHash(rawContent) + }, + Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = y.RequiredString("amount") + }) + }); + } + catch (Exception ex) + { + Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); + } + } + + return res; + + /*return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + { + + TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) ? new TicketToken { Ticketer = ticketToken.RequiredString("ticketer"), - ContentType = Micheline.FromJson(ticketToken.Required("content_type")), - Content = Micheline.FromJson(ticketToken.Required("content")), + RawType = Micheline.FromJson(ticketToken.Required("content_type")).ToBytes(), + RawContent = Micheline.FromJson(ticketToken.Required("content")).ToBytes(), ContentTypeHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content_type")).ToBytes()), ContentHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content")).ToBytes()) } @@ -224,7 +262,7 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul Amount = y.RequiredString("amount") }) : null - }); + });*/ } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index 767edea55..b9ad334d6 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using Netezos.Contracts; using Netezos.Encoding; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -196,26 +197,40 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; - return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + var res = new List(); + foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { - TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) - ? new TicketToken - { - Ticketer = ticketToken.RequiredString("ticketer"), - ContentType = Micheline.FromJson(ticketToken.Required("content_type")), - Content = Micheline.FromJson(ticketToken.Required("content")), - ContentTypeHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content_type")).ToBytes()), - ContentHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content")).ToBytes()) - } - : null, - Updates = x.TryGetProperty("updates", out var updates) - ? updates.RequiredArray().EnumerateArray().Select(y => new Update + try + { + var ticketToken = update.Required("ticket_token"); + var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); + var value = Micheline.FromJson(ticketToken.Required("content")); + var rawContent = micheType.Optimize(value).ToBytes(); + var rawType = micheType.ToMicheline().ToBytes(); + res.Add(new TicketUpdate { - Account = y.RequiredString("account"), - Amount = y.RequiredString("amount") - }) - : null - }); + TicketToken = new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + RawType = rawType, + RawContent = rawContent, + ContentTypeHash = Script.GetHash(rawType), + ContentHash = Script.GetHash(rawContent) + }, + Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = y.RequiredString("amount") + }) + }); + } + catch (Exception ex) + { + Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); + } + } + + return res; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs index 2ed3084fd..4a0092cb7 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs @@ -1,4 +1,5 @@ using System.Text.Json; +using Netezos.Contracts; using Netezos.Encoding; using Tzkt.Data.Models; @@ -13,26 +14,41 @@ protected override IEnumerable ParseTicketUpdates(string property, if (!result.TryGetProperty(property, out var ticketUpdates)) return null; - return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate + var res = new List(); + foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { - TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) - ? new TicketToken + try + { + var ticketToken = update.Required("ticket_token"); + var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); + var value = Micheline.FromJson(ticketToken.Required("content")); + var rawContent = micheType.Optimize(value).ToBytes(); + var rawType = micheType.ToMicheline().ToBytes(); + res.Add(new TicketUpdate { - Ticketer = ticketToken.RequiredString("ticketer"), - ContentType = Micheline.FromJson(ticketToken.Required("content_type")), - Content = Micheline.FromJson(ticketToken.Required("content")), - ContentTypeHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content_type")).ToBytes()), - ContentHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content")).ToBytes()) - } - : null, - Updates = x.TryGetProperty("updates", out var updates) - ? updates.RequiredArray().EnumerateArray().Select(y => new Update + TicketToken = new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + RawType = rawType, + RawContent = rawContent, + JsonContent = micheType.Humanize(value), + ContentTypeHash = Script.GetHash(rawType), + ContentHash = Script.GetHash(rawContent) + }, + Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = y.RequiredString("amount") + }) + }); + } + catch (Exception ex) { - Account = y.RequiredString("account"), - Amount = y.RequiredString("amount") - }) - : null - }); + Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); + } + } + + return res; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 3967a294a..c5414124d 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -69,9 +69,9 @@ public virtual async Task Apply() foreach (var (op, ticketUpdates) in Updates) { + Db.TryAttach(op.Block); op.Block.Events |= BlockEvents.Tickets; - //TODO Check all LastLevel fields. var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; @@ -127,6 +127,7 @@ Account GetOrCreateAccount(ManagerOperation op, string address) Db.Accounts.Add(account); Cache.Accounts.Add(account); + //TODO Do we need to attach it twice? Db.TryAttach(op.Block); op.Block.Events |= BlockEvents.NewAccounts; } @@ -140,8 +141,6 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic var state = Cache.AppState.Get(); state.TicketsCount++; - //Initiator to internal tx, sender for transfer_ticket and parent transaction - ticket = new Ticket { Id = op switch @@ -162,8 +161,9 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic TotalBurned = BigInteger.Zero, TotalMinted = BigInteger.Zero, TotalSupply = BigInteger.Zero, - Content = ticketToken.Content.ToBytes(), - ContentType = ticketToken.ContentType.ToBytes(), + RawContent = ticketToken.RawContent, + RawType = ticketToken.RawType, + JsonContent = ticketToken.JsonContent, ContentHash = ticketToken.ContentHash, ContentTypeHash = ticketToken.ContentTypeHash, }; @@ -174,45 +174,43 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic Db.TryAttach(contract); contract.TicketsCount++; - Db.TryAttach(op.Block); return ticket; } TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Account account) { - if (!Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) - { - var state = Cache.AppState.Get(); - state.TicketBalancesCount++; + if (Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) return ticketBalance; + + var state = Cache.AppState.Get(); + state.TicketBalancesCount++; - ticketBalance = new TicketBalance + ticketBalance = new TicketBalance + { + Id = op switch { - Id = op switch - { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - AccountId = account.Id, - TicketId = ticket.Id, - TicketerId = ticket.TicketerId, - FirstLevel = op.Level, - LastLevel = op.Level, - Balance = BigInteger.Zero - }; - Db.TicketBalances.Add(ticketBalance); - Cache.TicketBalances.Add(ticketBalance); + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + AccountId = account.Id, + TicketId = ticket.Id, + TicketerId = ticket.TicketerId, + FirstLevel = op.Level, + LastLevel = op.Level, + Balance = BigInteger.Zero + }; + Db.TicketBalances.Add(ticketBalance); + Cache.TicketBalances.Add(ticketBalance); - Db.TryAttach(ticket); - ticket.BalancesCount++; + Db.TryAttach(ticket); + ticket.BalancesCount++; - Db.TryAttach(account); - account.TicketBalancesCount++; - if (account.FirstLevel > op.Level) - { - account.FirstLevel = op.Level; - op.Block.Events |= BlockEvents.NewAccounts; - } + Db.TryAttach(account); + account.TicketBalancesCount++; + if (account.FirstLevel > op.Level) + { + account.FirstLevel = op.Level; + op.Block.Events |= BlockEvents.NewAccounts; } return ticketBalance; } @@ -267,8 +265,6 @@ void TransferTickets(ManagerOperation op, Contract contract, Ticket ticket, to.ActiveTicketsCount++; ticket.HoldersCount++; } - if (contract.Tags.HasFlag(ContractTags.Nft)) - ticket.OwnerId = to.Id; } var state = Cache.AppState.Get(); @@ -297,6 +293,7 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, Account account, TicketBalance balance, BigInteger amount) { + Db.TryAttach(op); switch (op) { case TransferTicketOperation transfer1: @@ -317,6 +314,7 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, balance.LastLevel = op.Level; //TODO Check transfersCount, balancesCount, holdersCount + Db.TryAttach(ticket); ticket.TransfersCount++; ticket.LastLevel = op.Level; if (balance.Balance == BigInteger.Zero) @@ -409,9 +407,9 @@ public virtual async Task Revert(Block block) foreach (var transfer in transfers) { var ticket = Cache.Tickets.Get(transfer.TicketId); - var contract = (Contract)Cache.Accounts.GetCached(ticket.TicketerId); Db.TryAttach(ticket); ticket.LastLevel = block.Level; + ticket.TransfersCount--; if (ticket.FirstLevel == block.Level) ticketsToRemove.Add(ticket); @@ -443,7 +441,6 @@ public virtual async Task Revert(Block block) if (toBalance.FirstLevel == block.Level) ticketBalancesToRemove.Add(toBalance); - ticket.TransfersCount--; if (transfer.Amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) { if (fromBalance.Balance == transfer.Amount) @@ -456,9 +453,6 @@ public virtual async Task Revert(Block block) to.ActiveTicketsCount--; ticket.HoldersCount--; } - - if (contract.Tags.HasFlag(ContractTags.Nft)) - ticket.OwnerId = from.Id; } state.TicketTransfersCount--; @@ -481,7 +475,6 @@ public virtual async Task Revert(Block block) if (toBalance.FirstLevel == block.Level) ticketBalancesToRemove.Add(toBalance); - ticket.TransfersCount--; if (transfer.Amount != BigInteger.Zero) { if (toBalance.Balance == BigInteger.Zero) @@ -489,9 +482,9 @@ public virtual async Task Revert(Block block) to.ActiveTicketsCount--; ticket.HoldersCount--; } - - if (contract.Tags.HasFlag(ContractTags.Nft)) - ticket.OwnerId = null; + + ticket.TotalMinted -= transfer.Amount; + ticket.TotalSupply -= transfer.Amount; } state.TicketTransfersCount--; @@ -514,7 +507,6 @@ public virtual async Task Revert(Block block) if (fromBalance.FirstLevel == block.Level) ticketBalancesToRemove.Add(fromBalance); - ticket.TransfersCount--; if (transfer.Amount != BigInteger.Zero) { if (fromBalance.Balance == transfer.Amount) @@ -523,8 +515,8 @@ public virtual async Task Revert(Block block) ticket.HoldersCount++; } - if (contract.Tags.HasFlag(ContractTags.Nft)) - ticket.OwnerId = from.Id; + ticket.TotalBurned -= transfer.Amount; + ticket.TotalSupply += transfer.Amount; } state.TicketTransfersCount--; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs index bfa19abd7..2d7ebefee 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs @@ -19,8 +19,8 @@ protected override async Task TestTicketBalance(int level, TicketBalance balance var update = new { ticketer = ticketer.Address, - content_type = Micheline.FromBytes(ticket.ContentType), - content = Micheline.FromBytes(ticket.Content) + content_type = Micheline.FromBytes(ticket.RawType), + content = Micheline.FromBytes(ticket.RawContent) }; if (BigInteger.TryParse((await Rpc.GetTicketBalance(level, account.Address, JsonSerializer.Serialize(update))).ToString(), out var remoteBalance)) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index 4c06838c6..0706a2bc5 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -482,12 +482,12 @@ public override async Task Revert() if (currBlock.Operations.HasFlag(Operations.SmartRollupRefute)) operations.AddRange(await Db.SmartRollupRefuteOps.Where(x => x.Level == currBlock.Level).ToListAsync()); - if (currBlock.Events.HasFlag(BlockEvents.NewAccounts)) - { - await Db.Entry(currBlock).Collection(x => x.CreatedAccounts).LoadAsync(); - foreach (var account in currBlock.CreatedAccounts) - Cache.Accounts.Add(account); - } +if (currBlock.Events.HasFlag(BlockEvents.NewAccounts)) +{ + await Db.Entry(currBlock).Collection(x => x.CreatedAccounts).LoadAsync(); + foreach (var account in currBlock.CreatedAccounts) + Cache.Accounts.Add(account); +} #endregion await new VotingCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs index cb9cbc663..f72fc809b 100644 --- a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs +++ b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs @@ -11,8 +11,10 @@ public class TicketUpdate public class TicketToken { public string Ticketer { get; set; } - public IMicheline ContentType { get; set; } - public IMicheline Content { get; set; } + public byte[] RawType { get; set; } + public byte[] RawContent { get; set; } + public string JsonContent { get; set; } + public int ContentTypeHash { get; set; } public int ContentHash { get; set; } } From 55c99eb28788fa7a1e9a285066098bfcb9293217 Mon Sep 17 00:00:00 2001 From: dmir Date: Thu, 10 Aug 2023 13:23:52 +0300 Subject: [PATCH 19/51] parentId --- Tzkt.Data/Models/Scripts/TIcket.cs | 2 - .../Handlers/Proto17/Commits/TicketsCommit.cs | 72 ++++++++++--------- .../Handlers/Proto17/Proto17Handler.cs | 12 ++-- 3 files changed, 43 insertions(+), 43 deletions(-) diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs index aa62182ee..630e8f2c7 100644 --- a/Tzkt.Data/Models/Scripts/TIcket.cs +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -24,8 +24,6 @@ public class Ticket public int ContentHash { get; set; } public int ContentTypeHash { get; set; } - //TODO Do we need to build models? - //TODO To RawContent like in TransferTicketOps? public byte[] RawContent { get; set; } public byte[] RawType { get; set; } public string JsonContent { get; set; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index c5414124d..0b8ce207f 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -6,18 +6,20 @@ namespace Tzkt.Sync.Protocols.Proto17 { +//TODO Move to Proto16 class TicketsCommit : ProtocolCommit { public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } - readonly List<(ManagerOperation op,TicketUpdate update)> Updates = new(); + readonly Dictionary> Updates = new(); - public virtual void Append(ManagerOperation op, IEnumerable updates) + public virtual void Append(long parentId, ManagerOperation op, IEnumerable updates) { - foreach (var update in updates) + if (!Updates.TryGetValue(parentId, out var list)) { - Updates.Add((op, update)); + Updates.Add(parentId, list = new List<(ManagerOperation op, TicketUpdate update)>()); } + list.AddRange(updates.Select(update => (op, update)).ToList()); } public virtual async Task Apply() @@ -30,7 +32,9 @@ public virtual async Task Apply() var ticketsSet = new HashSet<(int, int, int)>(); var balancesSet = new HashSet<(int, long)>(); - foreach (var (_, update) in Updates) + var list = Updates.SelectMany(x => x.Value).Select(x => x.update).ToList(); + + foreach (var update in list) { accountsSet.Add(update.TicketToken.Ticketer); foreach (var upd in update.Updates) @@ -39,8 +43,8 @@ public virtual async Task Apply() } } await Cache.Accounts.Preload(accountsSet); - - foreach (var (_, update) in Updates) + + foreach (var update in list) { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) ticketsSet.Add((ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash)); @@ -48,7 +52,7 @@ public virtual async Task Apply() await Cache.Tickets.Preload(ticketsSet); - foreach (var (_, update) in Updates) + foreach (var update in list) { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) { @@ -67,39 +71,39 @@ public virtual async Task Apply() #endregion - foreach (var (op, ticketUpdates) in Updates) + foreach (var (parentId, opUpdates) in Updates) { - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.Tickets; + foreach (var (op, ticketUpdates) in opUpdates) + { + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.Tickets; - //TODO Check all LastLevel fields. - var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; - - var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); + var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; + var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); - /*List<(ManagerOperation op, TicketUpdate update)> transfers = new(); - - foreach (var updates in Updates.GroupBy(x => x.op.OpHash).Select(g => g.ToList()).ToList()) - { - foreach (var (managerOperation, update) in updates) + /*List<(ManagerOperation op, TicketUpdate update)> transfers = new(); + + foreach (var updates in Updates.GroupBy(x => x.op.OpHash).Select(g => g.ToList()).ToList()) { - if (true) + foreach (var (managerOperation, update) in updates) { - transfers.Add(managerOperation, update); + if (true) + { + transfers.Add(managerOperation, update); + } } - } - }*/ + }*/ - //TODO First, group by opHash? - //TODO Match updates, if successful, transfers, if not, burns and mints - foreach (var ticketUpdate in ticketUpdates.Updates) - { - var amount = BigInteger.Parse(ticketUpdate.Amount); - var account = GetOrCreateAccount(op, ticketUpdate.Account); - var balance = GetOrCreateTicketBalance(op, ticket, account); - MintOrBurnTickets(op, ticket, account, balance, amount); + //TODO First, group by parentTx? + //TODO Match updates, if successful, transfers, if not, burns and mints + foreach (var ticketUpdate in ticketUpdates.Updates) + { + var amount = BigInteger.Parse(ticketUpdate.Amount); + var account = GetOrCreateAccount(op, ticketUpdate.Account); + var balance = GetOrCreateTicketBalance(op, ticket, account); + MintOrBurnTickets(op, ticket, account, balance, amount); + } } - } } @@ -220,7 +224,6 @@ void TransferTickets(ManagerOperation op, Contract contract, Ticket ticket, Account to, TicketBalance toBalance, BigInteger amount) { - //TODO Need to be tested switch (op) { case TransferTicketOperation transfer1: @@ -313,7 +316,6 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, balance.TransfersCount++; balance.LastLevel = op.Level; - //TODO Check transfersCount, balancesCount, holdersCount Db.TryAttach(ticket); ticket.TransfersCount++; ticket.LastLevel = op.Level; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index 0706a2bc5..861038327 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -171,7 +171,7 @@ public override async Task Commit(JsonElement block) if (parent.BigMapDiffs != null) bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); if (parent.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction, parent.TicketUpdates); + ticketsCommit.Append(parent.Transaction.Id, parent.Transaction, parent.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) { @@ -194,7 +194,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent.Transaction.Id, internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -233,7 +233,7 @@ public override async Task Commit(JsonElement block) var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); if (parent1.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation, parent1.TicketUpdates); + ticketsCommit.Append(parent1.Operation.Id, parent1.Operation, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) @@ -246,7 +246,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent1.Operation.Id, internalTx.Transaction, internalTx.TicketUpdates); break; default: throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); @@ -264,7 +264,7 @@ public override async Task Commit(JsonElement block) var parent2 = new SmartRollupExecuteCommit(this); await parent2.Apply(blockCommit.Block, operation, content); if (parent2.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation, parent2.TicketUpdates); + ticketsCommit.Append(parent2.Operation.Id, parent2.Operation, parent2.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult2)) { foreach (var internalContent in internalResult2.EnumerateArray()) @@ -286,7 +286,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent2.Operation.Id, internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); From 93f9ec0dcb39c6885ce72008ff3d83f1251eebff Mon Sep 17 00:00:00 2001 From: dmir Date: Thu, 10 Aug 2023 16:49:34 +0300 Subject: [PATCH 20/51] WIP Transfers --- .../Commits/Operations/TransactionsCommit.cs | 9 +- .../Operations/TransferTicketCommit.cs | 3 +- .../Operations/SmartRollupExecuteCommit.cs | 5 +- .../Commits/Operations/TransactionsCommit.cs | 6 +- .../Handlers/Proto17/Commits/TicketsCommit.cs | 97 ++++++++++++++----- Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs | 4 +- 6 files changed, 86 insertions(+), 38 deletions(-) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index 4e49e44e8..de8003ef2 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -1,10 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; +using System.Numerics; using System.Text.Json; -using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Logging; using Netezos.Contracts; using Netezos.Encoding; @@ -692,6 +688,7 @@ protected virtual int GetConsumedGas(JsonElement result) return result.OptionalInt32("consumed_gas") ?? 0; } + //TODO Move to Proto16 protected virtual IEnumerable ParseTicketUpdates(string property, JsonElement result) { if (!result.TryGetProperty(property, out var ticketUpdates)) @@ -721,7 +718,7 @@ protected virtual IEnumerable ParseTicketUpdates(string property, Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update { Account = y.RequiredString("account"), - Amount = y.RequiredString("amount") + Amount = BigInteger.Parse(y.RequiredString("amount")) }) }); } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 259e2dff0..8f9abaffd 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -200,6 +200,7 @@ public virtual async Task Revert(Block block, TransferTicketOperation operation) Cache.AppState.ReleaseOperationId(); } + //TODO Move to Proto16 protected virtual IEnumerable ParseTicketUpdates(JsonElement result) { if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) @@ -229,7 +230,7 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update { Account = y.RequiredString("account"), - Amount = y.RequiredString("amount") + Amount = BigInteger.Parse(y.RequiredString("amount")) }) }); } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index b9ad334d6..ac8342ec3 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -1,4 +1,5 @@ -using System.Text.Json; +using System.Numerics; +using System.Text.Json; using Netezos.Contracts; using Netezos.Encoding; using Tzkt.Data.Models; @@ -220,7 +221,7 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update { Account = y.RequiredString("account"), - Amount = y.RequiredString("amount") + Amount = BigInteger.Parse(y.RequiredString("amount")) }) }); } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs index 4a0092cb7..7bad60df8 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs @@ -1,10 +1,12 @@ -using System.Text.Json; +using System.Numerics; +using System.Text.Json; using Netezos.Contracts; using Netezos.Encoding; using Tzkt.Data.Models; namespace Tzkt.Sync.Protocols.Proto17 { + //TODO Move to Proto16 class TransactionsCommit : Proto14.TransactionsCommit { public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } @@ -38,7 +40,7 @@ protected override IEnumerable ParseTicketUpdates(string property, Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update { Account = y.RequiredString("account"), - Amount = y.RequiredString("amount") + Amount = BigInteger.Parse(y.RequiredString("amount")) }) }); } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 0b8ce207f..689e42ac5 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -73,35 +73,78 @@ public virtual async Task Apply() foreach (var (parentId, opUpdates) in Updates) { - foreach (var (op, ticketUpdates) in opUpdates) + //TODO Will we add transfers to itself? + if (opUpdates.SelectMany(x => x.update.Updates).Count() == 1 || + opUpdates.BigSum(x => x.update.Updates.BigSum(y => y.Amount)) != BigInteger.Zero) { - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.Tickets; + foreach (var (op, ticketUpdates) in opUpdates) + { + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.Tickets; - var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; - var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); - - /*List<(ManagerOperation op, TicketUpdate update)> transfers = new(); - - foreach (var updates in Updates.GroupBy(x => x.op.OpHash).Select(g => g.ToList()).ToList()) + var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; + var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); + + foreach (var ticketUpdate in ticketUpdates.Updates) + { + var account = GetOrCreateAccount(op, ticketUpdate.Account); + var balance = GetOrCreateTicketBalance(op, ticket, account); + MintOrBurnTickets(op, ticket, account, balance, ticketUpdate.Amount); + } + } + } + else if (opUpdates.Sum(x => x.update.Updates.Count(y => y.Amount < BigInteger.Zero)) == 1) + { + var from = opUpdates.SelectMany(x => x.update.Updates).First(y => y.Amount < BigInteger.Zero); + foreach (var (op, ticketUpdates) in opUpdates) { - foreach (var (managerOperation, update) in updates) + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.Tickets; + + var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; + var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); + + foreach (var ticketUpdate in ticketUpdates.Updates) { - if (true) - { - transfers.Add(managerOperation, update); - } + if (from.Account == ticketUpdate.Account) continue; + TransferTickets(op, ticket, from.Account, ticketUpdate.Account, ticketUpdate.Amount); } - }*/ + } + } + else if (opUpdates.Sum(x => x.update.Updates.Count(y => y.Amount > BigInteger.Zero)) == 1) + { + var to = opUpdates.SelectMany(x => x.update.Updates).First(y => y.Amount > BigInteger.Zero); + foreach (var (op, ticketUpdates) in opUpdates) + { + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.Tickets; + + var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; + var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); - //TODO First, group by parentTx? - //TODO Match updates, if successful, transfers, if not, burns and mints - foreach (var ticketUpdate in ticketUpdates.Updates) + foreach (var ticketUpdate in ticketUpdates.Updates) + { + if (to.Account == ticketUpdate.Account) continue; + TransferTickets(op, ticket, ticketUpdate.Account, to.Account, ticketUpdate.Amount); + } + } + } + else + { + foreach (var (op, ticketUpdates) in opUpdates) { - var amount = BigInteger.Parse(ticketUpdate.Amount); - var account = GetOrCreateAccount(op, ticketUpdate.Account); - var balance = GetOrCreateTicketBalance(op, ticket, account); - MintOrBurnTickets(op, ticket, account, balance, amount); + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.Tickets; + + var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; + var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); + + foreach (var ticketUpdate in ticketUpdates.Updates) + { + var account = GetOrCreateAccount(op, ticketUpdate.Account); + var balance = GetOrCreateTicketBalance(op, ticket, account); + MintOrBurnTickets(op, ticket, account, balance, ticketUpdate.Amount); + } } } } @@ -219,11 +262,15 @@ TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Accou return ticketBalance; } - void TransferTickets(ManagerOperation op, Contract contract, Ticket ticket, - Account from, TicketBalance fromBalance, - Account to, TicketBalance toBalance, + void TransferTickets(ManagerOperation op, Ticket ticket, + string fromAddress, string toAddress, BigInteger amount) { + var from = GetOrCreateAccount(op, fromAddress); + var fromBalance = GetOrCreateTicketBalance(op, ticket, from); + var to = GetOrCreateAccount(op, toAddress); + var toBalance = GetOrCreateTicketBalance(op, ticket, to); + switch (op) { case TransferTicketOperation transfer1: diff --git a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs index f72fc809b..d0e5f6c62 100644 --- a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs +++ b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs @@ -1,4 +1,4 @@ -using Netezos.Encoding; +using System.Numerics; namespace Tzkt.Sync.Protocols { @@ -22,6 +22,6 @@ public class TicketToken public class Update { public string Account { get; set; } - public string Amount { get; set; } + public BigInteger Amount { get; set; } } } \ No newline at end of file From d1a371ed1673c0059875f0df784787ad2d37d1ac Mon Sep 17 00:00:00 2001 From: dmir Date: Thu, 10 Aug 2023 18:24:47 +0300 Subject: [PATCH 21/51] Move to Proto16 --- .../Handlers/Proto16/Commits/TicketsCommit.cs | 601 +++++++++++++++++ .../Handlers/Proto16/Proto16Handler.cs | 17 +- .../Handlers/Proto17/Commits/TicketsCommit.cs | 612 +----------------- 3 files changed, 620 insertions(+), 610 deletions(-) create mode 100644 Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs new file mode 100644 index 000000000..c4e490be3 --- /dev/null +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -0,0 +1,601 @@ +using System.Numerics; +using Microsoft.EntityFrameworkCore; +using Netezos.Encoding; +using Tzkt.Data.Models; +using Tzkt.Data.Models.Base; + +namespace Tzkt.Sync.Protocols.Proto16 +{ + class TicketsCommit : ProtocolCommit + { + public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } + + readonly Dictionary> Updates = new(); + + public virtual void Append(long parentId, ManagerOperation op, IEnumerable updates) + { + if (!Updates.TryGetValue(parentId, out var list)) + { + Updates.Add(parentId, list = new List<(ManagerOperation op, TicketUpdate update)>()); + } + list.AddRange(updates.Select(update => (op, update)).ToList()); + } + + public virtual async Task Apply() + { + if (Updates.Count == 0) return; + + #region precache + + var accountsSet = new HashSet(); + var ticketsSet = new HashSet<(int, int, int)>(); + var balancesSet = new HashSet<(int, long)>(); + + var list = Updates.SelectMany(x => x.Value).Select(x => x.update).ToList(); + + foreach (var update in list) + { + accountsSet.Add(update.TicketToken.Ticketer); + foreach (var upd in update.Updates) + { + accountsSet.Add(upd.Account); + } + } + await Cache.Accounts.Preload(accountsSet); + + foreach (var update in list) + { + if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) + ticketsSet.Add((ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash)); + } + + await Cache.Tickets.Preload(ticketsSet); + + foreach (var update in list) + { + if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) + { + if (Cache.Tickets.TryGet(ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash, out var ticket)) + { + foreach (var upd in update.Updates) + { + if (Cache.Accounts.TryGetCached(upd.Account, out var acc)) + balancesSet.Add((acc.Id, ticket.Id)); + } + } + } + } + + await Cache.TicketBalances.Preload(balancesSet); + + #endregion + + foreach (var (_, opUpdates) in Updates) + { + var a = new Dictionary updates)>(); + + foreach (var (op, upd) in opUpdates) + { + var ticketer = GetOrCreateAccount(op, upd.TicketToken.Ticketer) as Contract; + var ticket = GetOrCreateTicket(op, ticketer, upd.TicketToken); + + if (!a.TryGetValue(ticket, out var upds)) + { + a.Add(ticket, upds = new() + { + updates = new List(), + operation = op + }); + } + upds.updates.AddRange(upd.Updates); + //TODO That's wrong + upds.operation = op; + } + + foreach (var (ticket, (op, updates)) in a) + { + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.Tickets; + + //TODO Will we add transfers to itself? + if (updates.Count == 1 || updates.BigSum(x => x.Amount) != BigInteger.Zero) + { + foreach (var ticketUpdate in updates) + { + var account = GetOrCreateAccount(op, ticketUpdate.Account); + var balance = GetOrCreateTicketBalance(op, ticket, account); + MintOrBurnTickets(op, ticket, account, balance, ticketUpdate.Amount); + } + } + else if (updates.Count(x => x.Amount < BigInteger.Zero) == 1) + { + var from = updates.First(x => x.Amount < BigInteger.Zero); + foreach (var ticketUpdate in updates) + { + if (from.Account == ticketUpdate.Account) continue; + TransferTickets(op, ticket, from.Account, ticketUpdate.Account, ticketUpdate.Amount); + } + } + else if (updates.Count(x => x.Amount > BigInteger.Zero) == 1) + { + var to = updates.First(x => x.Amount > BigInteger.Zero); + foreach (var ticketUpdate in updates) + { + if (to.Account == ticketUpdate.Account) continue; + TransferTickets(op, ticket, ticketUpdate.Account, to.Account, ticketUpdate.Amount); + } + } + else + { + foreach (var ticketUpdate in updates) + { + var account = GetOrCreateAccount(op, ticketUpdate.Account); + var balance = GetOrCreateTicketBalance(op, ticket, account); + MintOrBurnTickets(op, ticket, account, balance, ticketUpdate.Amount); + } + } + } + } + } + + Account GetOrCreateAccount(ManagerOperation op, string address) + { + if (!Cache.Accounts.TryGetCached(address, out var account)) + { + account = address[0] == 't' && address[1] == 'z' + ? new User + { + Id = Cache.AppState.NextAccountId(), + Address = address, + FirstLevel = op.Level, + LastLevel = op.Level, + Type = AccountType.User + } + : new Account + { + Id = Cache.AppState.NextAccountId(), + Address = address, + FirstLevel = op.Level, + LastLevel = op.Level, + Type = AccountType.Ghost + }; + Db.Accounts.Add(account); + Cache.Accounts.Add(account); + + //TODO Do we need to attach it twice? + Db.TryAttach(op.Block); + op.Block.Events |= BlockEvents.NewAccounts; + } + return account; + } + + Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken ticketToken) + { + if (Cache.Tickets.TryGet(contract.Id, ticketToken.ContentHash, ticketToken.ContentTypeHash, out var ticket)) return ticket; + + var state = Cache.AppState.Get(); + state.TicketsCount++; + + ticket = new Ticket + { + Id = op switch + { + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + TicketerId = contract.Id, + FirstMinterId = op switch + { + ContractOperation contractOperation => contractOperation.InitiatorId ?? contractOperation.SenderId, + TransferTicketOperation transfer => transfer.SenderId, + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + FirstLevel = op.Level, + LastLevel = op.Level, + TotalBurned = BigInteger.Zero, + TotalMinted = BigInteger.Zero, + TotalSupply = BigInteger.Zero, + RawContent = ticketToken.RawContent, + RawType = ticketToken.RawType, + JsonContent = ticketToken.JsonContent, + ContentHash = ticketToken.ContentHash, + ContentTypeHash = ticketToken.ContentTypeHash, + }; + + Db.Tickets.Add(ticket); + Cache.Tickets.Add(ticket); + + Db.TryAttach(contract); + contract.TicketsCount++; + + return ticket; + } + + TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Account account) + { + if (Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) return ticketBalance; + + var state = Cache.AppState.Get(); + state.TicketBalancesCount++; + + ticketBalance = new TicketBalance + { + Id = op switch + { + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + AccountId = account.Id, + TicketId = ticket.Id, + TicketerId = ticket.TicketerId, + FirstLevel = op.Level, + LastLevel = op.Level, + Balance = BigInteger.Zero + }; + Db.TicketBalances.Add(ticketBalance); + Cache.TicketBalances.Add(ticketBalance); + + Db.TryAttach(ticket); + ticket.BalancesCount++; + + Db.TryAttach(account); + account.TicketBalancesCount++; + if (account.FirstLevel > op.Level) + { + account.FirstLevel = op.Level; + op.Block.Events |= BlockEvents.NewAccounts; + } + return ticketBalance; + } + + void TransferTickets(ManagerOperation op, Ticket ticket, + string fromAddress, string toAddress, + BigInteger amount) + { + var from = GetOrCreateAccount(op, fromAddress); + var fromBalance = GetOrCreateTicketBalance(op, ticket, from); + var to = GetOrCreateAccount(op, toAddress); + var toBalance = GetOrCreateTicketBalance(op, ticket, to); + + switch (op) + { + case TransferTicketOperation transfer1: + transfer1.TicketTransfers = (transfer1.TicketTransfers ?? 0) + 1; + break; + case TransactionOperation tx: + tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; + break; + } + + Db.TryAttach(from); + from.TicketTransfersCount++; + from.LastLevel = op.Level; + + Db.TryAttach(to); + if (to != from) + { + to.TicketTransfersCount++; + to.LastLevel = op.Level; + } + + Db.TryAttach(fromBalance); + fromBalance.Balance -= amount; + fromBalance.TransfersCount++; + fromBalance.LastLevel = op.Level; + + Db.TryAttach(toBalance); + toBalance.Balance += amount; + if (toBalance != fromBalance) toBalance.TransfersCount++; + toBalance.LastLevel = op.Level; + + ticket.TransfersCount++; + if (amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) + { + if (fromBalance.Balance == BigInteger.Zero) + { + from.ActiveTicketsCount--; + ticket.HoldersCount--; + } + if (toBalance.Balance == amount) + { + to.ActiveTicketsCount++; + ticket.HoldersCount++; + } + } + + var state = Cache.AppState.Get(); + state.TicketTransfersCount++; + + Db.TicketTransfers.Add(new TicketTransfer + { + Id = op switch + { + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + Amount = amount, + FromId = from.Id, + ToId = to.Id, + Level = op.Level, + TicketId = ticket.Id, + TicketerId = ticket.TicketerId, + TransactionId = (op as TransactionOperation)?.Id, + TransferTicketId = (op as OriginationOperation)?.Id + }); + } + + void MintOrBurnTickets(ManagerOperation op, Ticket ticket, + Account account, TicketBalance balance, + BigInteger amount) + { + Db.TryAttach(op); + switch (op) + { + case TransferTicketOperation transfer1: + transfer1.TicketTransfers = (transfer1.TicketTransfers ?? 0) + 1; + break; + case TransactionOperation tx: + tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; + break; + } + + Db.TryAttach(account); + account.TicketTransfersCount++; + account.LastLevel = op.Level; + + Db.TryAttach(balance); + balance.Balance += amount; + balance.TransfersCount++; + balance.LastLevel = op.Level; + + Db.TryAttach(ticket); + ticket.TransfersCount++; + ticket.LastLevel = op.Level; + if (balance.Balance == BigInteger.Zero) + { + account.ActiveTicketsCount--; + ticket.HoldersCount--; + } + if (balance.Balance == amount) + { + account.ActiveTicketsCount++; + ticket.HoldersCount++; + } + if (amount > 0) ticket.TotalMinted += amount; + else ticket.TotalBurned += -amount; + ticket.TotalSupply += amount; + + var state = Cache.AppState.Get(); + state.TicketTransfersCount++; + + Db.TicketTransfers.Add(new TicketTransfer + { + Id = op switch + { + ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + Amount = amount > BigInteger.Zero ? amount : -amount, + FromId = amount < BigInteger.Zero ? account.Id : null, + ToId = amount > BigInteger.Zero ? account.Id : null, + Level = op.Level, + TicketId = ticket.Id, + TicketerId = ticket.TicketerId, + TransactionId = (op as TransactionOperation)?.Id, + TransferTicketId = (op as TransferTicketOperation)?.Id + }); + } + + public virtual async Task Revert(Block block) + { + if (!block.Events.HasFlag(BlockEvents.Tickets)) + return; + + var state = Cache.AppState.Get(); + + var transfers = await Db.TicketTransfers + .AsNoTracking() + .Where(x => x.Level == block.Level) + .OrderByDescending(x => x.Id) + .ToListAsync(); + + #region precache + var accountsSet = new HashSet(); + var ticketsSet = new HashSet(); + var balancesSet = new HashSet<(int, long)>(); + + foreach (var tr in transfers) + ticketsSet.Add(tr.TicketId); + + await Cache.Tickets.Preload(ticketsSet); + + foreach (var tr in transfers) + { + if (tr.FromId is int fromId) + { + accountsSet.Add(fromId); + balancesSet.Add((fromId, tr.TicketId)); + } + + if (tr.ToId is int toId) + { + accountsSet.Add(toId); + balancesSet.Add((toId, tr.TicketId)); + } + } + + foreach (var id in ticketsSet) + { + var ticket = Cache.Tickets.Get(id); + accountsSet.Add(ticket.TicketerId); + } + + await Cache.Accounts.Preload(accountsSet); + await Cache.TicketBalances.Preload(balancesSet); + #endregion + + var ticketsToRemove = new HashSet(); + var ticketBalancesToRemove = new HashSet(); + + foreach (var transfer in transfers) + { + var ticket = Cache.Tickets.Get(transfer.TicketId); + Db.TryAttach(ticket); + ticket.LastLevel = block.Level; + ticket.TransfersCount--; + if (ticket.FirstLevel == block.Level) + ticketsToRemove.Add(ticket); + + if (transfer.FromId is int fromId && transfer.ToId is int toId) + { + #region revert transfer + var from = Cache.Accounts.GetCached(fromId); + var to = Cache.Accounts.GetCached(toId); + var fromBalance = Cache.TicketBalances.Get(from.Id, ticket.Id); + var toBalance = Cache.TicketBalances.Get(to.Id, ticket.Id); + + Db.TryAttach(from); + Db.TryAttach(to); + Db.TryAttach(fromBalance); + Db.TryAttach(toBalance); + + from.TicketTransfersCount--; + if (to != from) to.TicketTransfersCount--; + + fromBalance.Balance += transfer.Amount; + fromBalance.TransfersCount--; + fromBalance.LastLevel = block.Level; + if (fromBalance.FirstLevel == block.Level) + ticketBalancesToRemove.Add(fromBalance); + + toBalance.Balance -= transfer.Amount; + if (toBalance != fromBalance) toBalance.TransfersCount--; + toBalance.LastLevel = block.Level; + if (toBalance.FirstLevel == block.Level) + ticketBalancesToRemove.Add(toBalance); + + if (transfer.Amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) + { + if (fromBalance.Balance == transfer.Amount) + { + from.ActiveTicketsCount++; + ticket.HoldersCount++; + } + if (toBalance.Balance == BigInteger.Zero) + { + to.ActiveTicketsCount--; + ticket.HoldersCount--; + } + } + + state.TicketTransfersCount--; + #endregion + } + else if (transfer.ToId != null) + { + #region revert mint + var to = Cache.Accounts.GetCached((int)transfer.ToId); + var toBalance = Cache.TicketBalances.Get(to.Id, ticket.Id); + + Db.TryAttach(to); + Db.TryAttach(toBalance); + + to.TicketTransfersCount--; + + toBalance.Balance -= transfer.Amount; + toBalance.TransfersCount--; + toBalance.LastLevel = block.Level; + if (toBalance.FirstLevel == block.Level) + ticketBalancesToRemove.Add(toBalance); + + if (transfer.Amount != BigInteger.Zero) + { + if (toBalance.Balance == BigInteger.Zero) + { + to.ActiveTicketsCount--; + ticket.HoldersCount--; + } + + ticket.TotalMinted -= transfer.Amount; + ticket.TotalSupply -= transfer.Amount; + } + + state.TicketTransfersCount--; + #endregion + } + else + { + #region revert burn + var from = Cache.Accounts.GetCached((int)transfer.FromId); + var fromBalance = Cache.TicketBalances.Get(from.Id, ticket.Id); + + Db.TryAttach(from); + Db.TryAttach(fromBalance); + + from.TicketTransfersCount--; + + fromBalance.Balance += transfer.Amount; + fromBalance.TransfersCount--; + fromBalance.LastLevel = block.Level; + if (fromBalance.FirstLevel == block.Level) + ticketBalancesToRemove.Add(fromBalance); + + if (transfer.Amount != BigInteger.Zero) + { + if (fromBalance.Balance == transfer.Amount) + { + from.ActiveTicketsCount++; + ticket.HoldersCount++; + } + + ticket.TotalBurned -= transfer.Amount; + ticket.TotalSupply += transfer.Amount; + } + + state.TicketTransfersCount--; + #endregion + } + } + + foreach (var ticketBalance in ticketBalancesToRemove) + { + if (ticketBalance.FirstLevel == block.Level) + { + Db.TicketBalances.Remove(ticketBalance); + Cache.TicketBalances.Remove(ticketBalance); + + var t = Cache.Tickets.Get(ticketBalance.TicketId); + Db.TryAttach(t); + t.BalancesCount--; + + var a = Cache.Accounts.GetCached(ticketBalance.AccountId); + Db.TryAttach(a); + a.TicketBalancesCount--; + + state.TicketBalancesCount--; + } + } + + foreach (var ticket in ticketsToRemove) + { + if (ticket.FirstLevel == block.Level) + { + Db.Tickets.Remove(ticket); + Cache.Tickets.Remove(ticket); + + var c = (Contract)Cache.Accounts.GetCached(ticket.TicketerId); + Db.TryAttach(c); + c.TicketsCount--; + + state.TicketsCount--; + } + } + + await Db.Database.ExecuteSqlRawAsync($@"DELETE FROM ""TicketTransfers"" WHERE ""Level"" = {block.Level};"); + } + } +} \ No newline at end of file diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs index 6c7b2fce9..f542fcfd9 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs @@ -131,6 +131,7 @@ public override async Task Commit(JsonElement block) #endregion var bigMapCommit = new BigMapCommit(this); + var ticketsCommit = new TicketsCommit(this); #region operations 3 foreach (var operation in operations[3].EnumerateArray()) @@ -169,6 +170,8 @@ public override async Task Commit(JsonElement block) await parent.Apply(blockCommit.Block, operation, content); if (parent.BigMapDiffs != null) bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); + if (parent.TicketUpdates != null) + ticketsCommit.Append(parent.Transaction.Id, parent.Transaction, parent.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) { @@ -190,6 +193,8 @@ public override async Task Commit(JsonElement block) await internalTx.ApplyInternal(blockCommit.Block, parent.Transaction, internalContent); if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(parent.Transaction.Id, internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -227,6 +232,8 @@ public override async Task Commit(JsonElement block) case "transfer_ticket": var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); + if (parent1.TicketUpdates != null) + ticketsCommit.Append(parent1.Operation.Id, parent1.Operation, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) @@ -238,6 +245,8 @@ public override async Task Commit(JsonElement block) await internalTx.ApplyInternal(blockCommit.Block, parent1.Operation, internalContent); if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(parent1.Operation.Id, internalTx.Transaction, internalTx.TicketUpdates); break; default: throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); @@ -254,6 +263,8 @@ public override async Task Commit(JsonElement block) case "smart_rollup_execute_outbox_message": var parent2 = new SmartRollupExecuteCommit(this); await parent2.Apply(blockCommit.Block, operation, content); + if (parent2.TicketUpdates != null) + ticketsCommit.Append(parent2.Operation.Id, parent2.Operation, parent2.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult2)) { foreach (var internalContent in internalResult2.EnumerateArray()) @@ -274,6 +285,8 @@ public override async Task Commit(JsonElement block) await internalTx.ApplyInternal(blockCommit.Block, parent2.Operation, internalContent); if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); + if (internalTx.TicketUpdates != null) + ticketsCommit.Append(parent2.Operation.Id, internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -309,7 +322,8 @@ public override async Task Commit(JsonElement block) new InboxCommit(this).Apply(blockCommit.Block); - await bigMapCommit.Apply(); + await bigMapCommit.Apply(); + await ticketsCommit.Apply(); await new TokensCommit(this).Apply(blockCommit.Block, bigMapCommit.Updates); var brCommit = new BakingRightsCommit(this); @@ -486,6 +500,7 @@ public override async Task Revert() await new DelegatorCycleCommit(this).Revert(currBlock); await new BakingRightsCommit(this).Revert(currBlock); await new TokensCommit(this).Revert(currBlock); + await new TicketsCommit(this).Revert(currBlock); await new BigMapCommit(this).Revert(currBlock); await new ContractEventCommit(this).Revert(currBlock); await new InboxCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs index 689e42ac5..4e010482c 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/TicketsCommit.cs @@ -1,613 +1,7 @@ -using System.Numerics; -using Microsoft.EntityFrameworkCore; -using Netezos.Encoding; -using Tzkt.Data.Models; -using Tzkt.Data.Models.Base; - -namespace Tzkt.Sync.Protocols.Proto17 +namespace Tzkt.Sync.Protocols.Proto17 { -//TODO Move to Proto16 - class TicketsCommit : ProtocolCommit + class TicketsCommit : Proto16.TicketsCommit { public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } - - readonly Dictionary> Updates = new(); - - public virtual void Append(long parentId, ManagerOperation op, IEnumerable updates) - { - if (!Updates.TryGetValue(parentId, out var list)) - { - Updates.Add(parentId, list = new List<(ManagerOperation op, TicketUpdate update)>()); - } - list.AddRange(updates.Select(update => (op, update)).ToList()); - } - - public virtual async Task Apply() - { - if (Updates.Count == 0) return; - - #region precache - - var accountsSet = new HashSet(); - var ticketsSet = new HashSet<(int, int, int)>(); - var balancesSet = new HashSet<(int, long)>(); - - var list = Updates.SelectMany(x => x.Value).Select(x => x.update).ToList(); - - foreach (var update in list) - { - accountsSet.Add(update.TicketToken.Ticketer); - foreach (var upd in update.Updates) - { - accountsSet.Add(upd.Account); - } - } - await Cache.Accounts.Preload(accountsSet); - - foreach (var update in list) - { - if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) - ticketsSet.Add((ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash)); - } - - await Cache.Tickets.Preload(ticketsSet); - - foreach (var update in list) - { - if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) - { - if (Cache.Tickets.TryGet(ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash, out var ticket)) - { - foreach (var upd in update.Updates) - { - if (Cache.Accounts.TryGetCached(upd.Account, out var acc)) - balancesSet.Add((acc.Id, ticket.Id)); - } - } - } - } - - await Cache.TicketBalances.Preload(balancesSet); - - #endregion - - foreach (var (parentId, opUpdates) in Updates) - { - //TODO Will we add transfers to itself? - if (opUpdates.SelectMany(x => x.update.Updates).Count() == 1 || - opUpdates.BigSum(x => x.update.Updates.BigSum(y => y.Amount)) != BigInteger.Zero) - { - foreach (var (op, ticketUpdates) in opUpdates) - { - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.Tickets; - - var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; - var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); - - foreach (var ticketUpdate in ticketUpdates.Updates) - { - var account = GetOrCreateAccount(op, ticketUpdate.Account); - var balance = GetOrCreateTicketBalance(op, ticket, account); - MintOrBurnTickets(op, ticket, account, balance, ticketUpdate.Amount); - } - } - } - else if (opUpdates.Sum(x => x.update.Updates.Count(y => y.Amount < BigInteger.Zero)) == 1) - { - var from = opUpdates.SelectMany(x => x.update.Updates).First(y => y.Amount < BigInteger.Zero); - foreach (var (op, ticketUpdates) in opUpdates) - { - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.Tickets; - - var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; - var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); - - foreach (var ticketUpdate in ticketUpdates.Updates) - { - if (from.Account == ticketUpdate.Account) continue; - TransferTickets(op, ticket, from.Account, ticketUpdate.Account, ticketUpdate.Amount); - } - } - } - else if (opUpdates.Sum(x => x.update.Updates.Count(y => y.Amount > BigInteger.Zero)) == 1) - { - var to = opUpdates.SelectMany(x => x.update.Updates).First(y => y.Amount > BigInteger.Zero); - foreach (var (op, ticketUpdates) in opUpdates) - { - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.Tickets; - - var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; - var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); - - foreach (var ticketUpdate in ticketUpdates.Updates) - { - if (to.Account == ticketUpdate.Account) continue; - TransferTickets(op, ticket, ticketUpdate.Account, to.Account, ticketUpdate.Amount); - } - } - } - else - { - foreach (var (op, ticketUpdates) in opUpdates) - { - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.Tickets; - - var ticketer = GetOrCreateAccount(op, ticketUpdates.TicketToken.Ticketer) as Contract; - var ticket = GetOrCreateTicket(op, ticketer, ticketUpdates.TicketToken); - - foreach (var ticketUpdate in ticketUpdates.Updates) - { - var account = GetOrCreateAccount(op, ticketUpdate.Account); - var balance = GetOrCreateTicketBalance(op, ticket, account); - MintOrBurnTickets(op, ticket, account, balance, ticketUpdate.Amount); - } - } - } - } - } - - Account GetOrCreateAccount(ManagerOperation op, string address) - { - if (!Cache.Accounts.TryGetCached(address, out var account)) - { - account = address[0] == 't' && address[1] == 'z' - ? new User - { - Id = Cache.AppState.NextAccountId(), - Address = address, - FirstLevel = op.Level, - LastLevel = op.Level, - Type = AccountType.User - } - : new Account - { - Id = Cache.AppState.NextAccountId(), - Address = address, - FirstLevel = op.Level, - LastLevel = op.Level, - Type = AccountType.Ghost - }; - Db.Accounts.Add(account); - Cache.Accounts.Add(account); - - //TODO Do we need to attach it twice? - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.NewAccounts; - } - return account; - } - - Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken ticketToken) - { - if (Cache.Tickets.TryGet(contract.Id, ticketToken.ContentHash, ticketToken.ContentTypeHash, out var ticket)) return ticket; - - var state = Cache.AppState.Get(); - state.TicketsCount++; - - ticket = new Ticket - { - Id = op switch - { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - TicketerId = contract.Id, - FirstMinterId = op switch - { - ContractOperation contractOperation => contractOperation.InitiatorId ?? contractOperation.SenderId, - TransferTicketOperation transfer => transfer.SenderId, - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - FirstLevel = op.Level, - LastLevel = op.Level, - TotalBurned = BigInteger.Zero, - TotalMinted = BigInteger.Zero, - TotalSupply = BigInteger.Zero, - RawContent = ticketToken.RawContent, - RawType = ticketToken.RawType, - JsonContent = ticketToken.JsonContent, - ContentHash = ticketToken.ContentHash, - ContentTypeHash = ticketToken.ContentTypeHash, - }; - - Db.Tickets.Add(ticket); - Cache.Tickets.Add(ticket); - - Db.TryAttach(contract); - contract.TicketsCount++; - - return ticket; - } - - TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Account account) - { - if (Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) return ticketBalance; - - var state = Cache.AppState.Get(); - state.TicketBalancesCount++; - - ticketBalance = new TicketBalance - { - Id = op switch - { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - AccountId = account.Id, - TicketId = ticket.Id, - TicketerId = ticket.TicketerId, - FirstLevel = op.Level, - LastLevel = op.Level, - Balance = BigInteger.Zero - }; - Db.TicketBalances.Add(ticketBalance); - Cache.TicketBalances.Add(ticketBalance); - - Db.TryAttach(ticket); - ticket.BalancesCount++; - - Db.TryAttach(account); - account.TicketBalancesCount++; - if (account.FirstLevel > op.Level) - { - account.FirstLevel = op.Level; - op.Block.Events |= BlockEvents.NewAccounts; - } - return ticketBalance; - } - - void TransferTickets(ManagerOperation op, Ticket ticket, - string fromAddress, string toAddress, - BigInteger amount) - { - var from = GetOrCreateAccount(op, fromAddress); - var fromBalance = GetOrCreateTicketBalance(op, ticket, from); - var to = GetOrCreateAccount(op, toAddress); - var toBalance = GetOrCreateTicketBalance(op, ticket, to); - - switch (op) - { - case TransferTicketOperation transfer1: - transfer1.TicketTransfers = (transfer1.TicketTransfers ?? 0) + 1; - break; - case TransactionOperation tx: - tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; - break; - } - - Db.TryAttach(from); - from.TicketTransfersCount++; - from.LastLevel = op.Level; - - Db.TryAttach(to); - if (to != from) - { - to.TicketTransfersCount++; - to.LastLevel = op.Level; - } - - Db.TryAttach(fromBalance); - fromBalance.Balance -= amount; - fromBalance.TransfersCount++; - fromBalance.LastLevel = op.Level; - - Db.TryAttach(toBalance); - toBalance.Balance += amount; - if (toBalance != fromBalance) toBalance.TransfersCount++; - toBalance.LastLevel = op.Level; - - ticket.TransfersCount++; - if (amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) - { - if (fromBalance.Balance == BigInteger.Zero) - { - from.ActiveTicketsCount--; - ticket.HoldersCount--; - } - if (toBalance.Balance == amount) - { - to.ActiveTicketsCount++; - ticket.HoldersCount++; - } - } - - var state = Cache.AppState.Get(); - state.TicketTransfersCount++; - - Db.TicketTransfers.Add(new TicketTransfer - { - Id = op switch - { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - Amount = amount, - FromId = from.Id, - ToId = to.Id, - Level = op.Level, - TicketId = ticket.Id, - TicketerId = ticket.TicketerId, - TransactionId = (op as TransactionOperation)?.Id, - TransferTicketId = (op as OriginationOperation)?.Id - }); - } - - void MintOrBurnTickets(ManagerOperation op, Ticket ticket, - Account account, TicketBalance balance, - BigInteger amount) - { - Db.TryAttach(op); - switch (op) - { - case TransferTicketOperation transfer1: - transfer1.TicketTransfers = (transfer1.TicketTransfers ?? 0) + 1; - break; - case TransactionOperation tx: - tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; - break; - } - - Db.TryAttach(account); - account.TicketTransfersCount++; - account.LastLevel = op.Level; - - Db.TryAttach(balance); - balance.Balance += amount; - balance.TransfersCount++; - balance.LastLevel = op.Level; - - Db.TryAttach(ticket); - ticket.TransfersCount++; - ticket.LastLevel = op.Level; - if (balance.Balance == BigInteger.Zero) - { - account.ActiveTicketsCount--; - ticket.HoldersCount--; - } - if (balance.Balance == amount) - { - account.ActiveTicketsCount++; - ticket.HoldersCount++; - } - if (amount > 0) ticket.TotalMinted += amount; - else ticket.TotalBurned += -amount; - ticket.TotalSupply += amount; - - var state = Cache.AppState.Get(); - state.TicketTransfersCount++; - - Db.TicketTransfers.Add(new TicketTransfer - { - Id = op switch - { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - Amount = amount > BigInteger.Zero ? amount : -amount, - FromId = amount < BigInteger.Zero ? account.Id : null, - ToId = amount > BigInteger.Zero ? account.Id : null, - Level = op.Level, - TicketId = ticket.Id, - TicketerId = ticket.TicketerId, - TransactionId = (op as TransactionOperation)?.Id, - TransferTicketId = (op as TransferTicketOperation)?.Id - }); - } - - public virtual async Task Revert(Block block) - { - if (!block.Events.HasFlag(BlockEvents.Tickets)) - return; - - var state = Cache.AppState.Get(); - - var transfers = await Db.TicketTransfers - .AsNoTracking() - .Where(x => x.Level == block.Level) - .OrderByDescending(x => x.Id) - .ToListAsync(); - - #region precache - var accountsSet = new HashSet(); - var ticketsSet = new HashSet(); - var balancesSet = new HashSet<(int, long)>(); - - foreach (var tr in transfers) - ticketsSet.Add(tr.TicketId); - - await Cache.Tickets.Preload(ticketsSet); - - foreach (var tr in transfers) - { - if (tr.FromId is int fromId) - { - accountsSet.Add(fromId); - balancesSet.Add((fromId, tr.TicketId)); - } - - if (tr.ToId is int toId) - { - accountsSet.Add(toId); - balancesSet.Add((toId, tr.TicketId)); - } - } - - foreach (var id in ticketsSet) - { - var ticket = Cache.Tickets.Get(id); - accountsSet.Add(ticket.TicketerId); - } - - await Cache.Accounts.Preload(accountsSet); - await Cache.TicketBalances.Preload(balancesSet); - #endregion - - var ticketsToRemove = new HashSet(); - var ticketBalancesToRemove = new HashSet(); - - foreach (var transfer in transfers) - { - var ticket = Cache.Tickets.Get(transfer.TicketId); - Db.TryAttach(ticket); - ticket.LastLevel = block.Level; - ticket.TransfersCount--; - if (ticket.FirstLevel == block.Level) - ticketsToRemove.Add(ticket); - - if (transfer.FromId is int fromId && transfer.ToId is int toId) - { - #region revert transfer - var from = Cache.Accounts.GetCached(fromId); - var to = Cache.Accounts.GetCached(toId); - var fromBalance = Cache.TicketBalances.Get(from.Id, ticket.Id); - var toBalance = Cache.TicketBalances.Get(to.Id, ticket.Id); - - Db.TryAttach(from); - Db.TryAttach(to); - Db.TryAttach(fromBalance); - Db.TryAttach(toBalance); - - from.TicketTransfersCount--; - if (to != from) to.TicketTransfersCount--; - - fromBalance.Balance += transfer.Amount; - fromBalance.TransfersCount--; - fromBalance.LastLevel = block.Level; - if (fromBalance.FirstLevel == block.Level) - ticketBalancesToRemove.Add(fromBalance); - - toBalance.Balance -= transfer.Amount; - if (toBalance != fromBalance) toBalance.TransfersCount--; - toBalance.LastLevel = block.Level; - if (toBalance.FirstLevel == block.Level) - ticketBalancesToRemove.Add(toBalance); - - if (transfer.Amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) - { - if (fromBalance.Balance == transfer.Amount) - { - from.ActiveTicketsCount++; - ticket.HoldersCount++; - } - if (toBalance.Balance == BigInteger.Zero) - { - to.ActiveTicketsCount--; - ticket.HoldersCount--; - } - } - - state.TicketTransfersCount--; - #endregion - } - else if (transfer.ToId != null) - { - #region revert mint - var to = Cache.Accounts.GetCached((int)transfer.ToId); - var toBalance = Cache.TicketBalances.Get(to.Id, ticket.Id); - - Db.TryAttach(to); - Db.TryAttach(toBalance); - - to.TicketTransfersCount--; - - toBalance.Balance -= transfer.Amount; - toBalance.TransfersCount--; - toBalance.LastLevel = block.Level; - if (toBalance.FirstLevel == block.Level) - ticketBalancesToRemove.Add(toBalance); - - if (transfer.Amount != BigInteger.Zero) - { - if (toBalance.Balance == BigInteger.Zero) - { - to.ActiveTicketsCount--; - ticket.HoldersCount--; - } - - ticket.TotalMinted -= transfer.Amount; - ticket.TotalSupply -= transfer.Amount; - } - - state.TicketTransfersCount--; - #endregion - } - else - { - #region revert burn - var from = Cache.Accounts.GetCached((int)transfer.FromId); - var fromBalance = Cache.TicketBalances.Get(from.Id, ticket.Id); - - Db.TryAttach(from); - Db.TryAttach(fromBalance); - - from.TicketTransfersCount--; - - fromBalance.Balance += transfer.Amount; - fromBalance.TransfersCount--; - fromBalance.LastLevel = block.Level; - if (fromBalance.FirstLevel == block.Level) - ticketBalancesToRemove.Add(fromBalance); - - if (transfer.Amount != BigInteger.Zero) - { - if (fromBalance.Balance == transfer.Amount) - { - from.ActiveTicketsCount++; - ticket.HoldersCount++; - } - - ticket.TotalBurned -= transfer.Amount; - ticket.TotalSupply += transfer.Amount; - } - - state.TicketTransfersCount--; - #endregion - } - } - - foreach (var ticketBalance in ticketBalancesToRemove) - { - if (ticketBalance.FirstLevel == block.Level) - { - Db.TicketBalances.Remove(ticketBalance); - Cache.TicketBalances.Remove(ticketBalance); - - var t = Cache.Tickets.Get(ticketBalance.TicketId); - Db.TryAttach(t); - t.BalancesCount--; - - var a = Cache.Accounts.GetCached(ticketBalance.AccountId); - Db.TryAttach(a); - a.TicketBalancesCount--; - - state.TicketBalancesCount--; - } - } - - foreach (var ticket in ticketsToRemove) - { - if (ticket.FirstLevel == block.Level) - { - Db.Tickets.Remove(ticket); - Cache.Tickets.Remove(ticket); - - var c = (Contract)Cache.Accounts.GetCached(ticket.TicketerId); - Db.TryAttach(c); - c.TicketsCount--; - - state.TicketsCount--; - } - } - - await Db.Database.ExecuteSqlRawAsync($@"DELETE FROM ""TicketTransfers"" WHERE ""Level"" = {block.Level};"); - } } -} +} \ No newline at end of file From 7cd383c069e85d4bbdaceb1682cc54bec4b4aa3b Mon Sep 17 00:00:00 2001 From: dmir Date: Fri, 11 Aug 2023 12:18:07 +0300 Subject: [PATCH 22/51] Update SonarCloud --- .github/workflows/build.yml | 17 +++++----- .../Proto16/Diagnostics/Diagnostics.cs | 32 +++++++++++++++++- .../Proto17/Diagnostics/Diagnostics.cs | 33 ++----------------- Tzkt.Sync/Services/Observer/Observer.cs | 15 ++------- 4 files changed, 45 insertions(+), 52 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76ab70f3c..0a2c677ce 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,22 +12,23 @@ jobs: runs-on: windows-latest if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }} steps: - - name: Set up JDK 11 - uses: actions/setup-java@v1 + - name: Set up JDK 17 + uses: actions/setup-java@v3 with: - java-version: 1.11 - - uses: actions/checkout@v2 + java-version: 17 + distribution: 'zulu' # Alternative distribution options are available. + - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Cache SonarCloud packages - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: ~\sonar\cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache SonarCloud scanner id: cache-sonar-scanner - uses: actions/cache@v1 + uses: actions/cache@v3 with: path: .\.sonar\scanner key: ${{ runner.os }}-sonar-scanner @@ -44,6 +45,6 @@ jobs: SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} shell: powershell run: | - .\.sonar\scanner\dotnet-sonarscanner begin /k:"baking-bad_tzkt" /o:"baking-bad" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" + .\.sonar\scanner\dotnet-sonarscanner begin /k:"baking-bad_tzkt" /o:"baking-bad" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" dotnet build - .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" + .\.sonar\scanner\dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs index f3d3f5f28..baa9809d0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs @@ -1,7 +1,37 @@ -namespace Tzkt.Sync.Protocols.Proto16 +using System.Numerics; +using System.Text.Json; +using Netezos.Encoding; +using Tzkt.Data.Models; + +namespace Tzkt.Sync.Protocols.Proto16 { class Diagnostics : Proto14.Diagnostics { public Diagnostics(ProtocolHandler handler) : base(handler) { } + + protected override async Task TestTicketBalance(int level, TicketBalance balance) + { + //TODO Make sure that's correct + var ticketer = await Cache.Accounts.GetAsync(balance.TicketerId); + var ticket = Cache.Tickets.Get(balance.TicketId); + var account = await Cache.Accounts.GetAsync(balance.AccountId); + + var update = new + { + ticketer = ticketer.Address, + content_type = Micheline.FromBytes(ticket.RawType), + content = Micheline.FromBytes(ticket.RawContent) + }; + + if (BigInteger.TryParse(await Rpc.GetTicketBalance(level, account.Address, JsonSerializer.Serialize(update)), out var remoteBalance)) + { + if (remoteBalance != balance.Balance) + throw new Exception($"Diagnostics failed: wrong ticket balance for {account.Address}"); + } + else + { + throw new Exception("Failed to get ticket balance"); + } + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs index 2d7ebefee..355aea78b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Diagnostics/Diagnostics.cs @@ -1,37 +1,8 @@ -using System.Numerics; -using System.Text.Json; -using Netezos.Encoding; -using Tzkt.Data.Models; - -namespace Tzkt.Sync.Protocols.Proto17 +namespace Tzkt.Sync.Protocols.Proto17 { - class Diagnostics : Proto14.Diagnostics + class Diagnostics : Proto16.Diagnostics { public Diagnostics(ProtocolHandler handler) : base(handler) { } - protected override async Task TestTicketBalance(int level, TicketBalance balance) - { - //TODO Make sure that's correct - var ticketer = await Cache.Accounts.GetAsync(balance.TicketerId); - var ticket = Cache.Tickets.Get(balance.TicketId); - var account = await Cache.Accounts.GetAsync(balance.AccountId); - - var update = new - { - ticketer = ticketer.Address, - content_type = Micheline.FromBytes(ticket.RawType), - content = Micheline.FromBytes(ticket.RawContent) - }; - - if (BigInteger.TryParse((await Rpc.GetTicketBalance(level, account.Address, JsonSerializer.Serialize(update))).ToString(), out var remoteBalance)) - { - if (remoteBalance != balance.Balance) - throw new Exception($"Diagnostics failed: wrong ticket balance for {account.Address}"); - } - else - { - throw new Exception("Failed to get ticket balance"); - } - } } } diff --git a/Tzkt.Sync/Services/Observer/Observer.cs b/Tzkt.Sync/Services/Observer/Observer.cs index 145ec5d7e..f4401f066 100644 --- a/Tzkt.Sync/Services/Observer/Observer.cs +++ b/Tzkt.Sync/Services/Observer/Observer.cs @@ -150,12 +150,7 @@ private async Task RebaseLocalBranchAsync(CancellationToken cancelToken) while (AppState.Level >= 0 && !cancelToken.IsCancellationRequested) { var header = await Node.GetHeaderAsync(AppState.Level); - - var initRevert = false; - if (!initRevert) - { - if (AppState.Hash == header.Hash) break; - } + if (AppState.Hash == header.Hash) break; Logger.LogError("Invalid head [{level}:{hash}]. Reverting...", AppState.Level, AppState.Hash); using (Metrics.Measure.Timer.Time(MetricsRegistry.RevertBlockTime)) @@ -177,12 +172,8 @@ private async Task ApplyUpdatesAsync(CancellationToken cancelToken) var header = await Node.GetHeaderAsync(); if (AppState.Level == header.Level) break; - var initRevert = false; - if (initRevert) - { - if (AppState.Level >= 0) - throw new ValidationException("Test", true); - } + //if (AppState.Level >= 0) + // throw new ValidationException("Test", true); Logger.LogDebug($"Applying block..."); using (Metrics.Measure.Timer.Time(MetricsRegistry.ApplyBlockTime)) From f616a3d302c97d999107f7acba60bde86e9883ec Mon Sep 17 00:00:00 2001 From: dmir Date: Fri, 11 Aug 2023 14:30:10 +0300 Subject: [PATCH 23/51] Clean up --- Makefile | 4 +- Tzkt.Data/Models/Accounts/Account.cs | 1 - Tzkt.Data/Models/Accounts/Contract.cs | 1 - .../Operations/Base/ContractOperation.cs | 1 + .../Operations/Fictive/MigrationOperation.cs | 3 +- .../Models/Operations/TransactionOperation.cs | 1 - .../Operations/TransferTicketOperation.cs | 3 +- Tzkt.Sync.Tests/Database/AppStateTests.cs | 9 +++ .../Commits/Operations/DelegationsCommit.cs | 6 ++ .../Commits/Operations/OriginationsCommit.cs | 20 ++++-- .../Commits/Operations/TransactionsCommit.cs | 1 - .../Operations/TransferTicketCommit.cs | 64 +++++++++++-------- .../Operations/TxRollupOriginationCommit.cs | 10 ++- .../Operations/SmartRollupOriginateCommit.cs | 10 ++- .../Handlers/Proto16/Commits/TicketsCommit.cs | 2 +- .../Proto16/Diagnostics/Diagnostics.cs | 1 - .../Commits/Operations/TransactionsCommit.cs | 51 +-------------- .../Handlers/Proto17/Proto17Handler.cs | 12 ++-- Tzkt.Sync/Services/TezosNode/TezosNode.cs | 8 +-- Tzkt.Sync/Utils/TzktClient.cs | 2 +- docker-compose.ghost.yml | 1 + docker-compose.nairobi.yml | 1 + 22 files changed, 100 insertions(+), 112 deletions(-) diff --git a/Makefile b/Makefile index b6438cff9..531a89df7 100644 --- a/Makefile +++ b/Makefile @@ -111,5 +111,5 @@ mumbai-stop: mumbai-db-start: docker-compose -f docker-compose.mumbai.yml up -d mumbai-db reset: - docker-compose -f docker-compose.nairobi.yml down --volumes - docker-compose -f docker-compose.nairobi.yml up -d nairobi-db \ No newline at end of file + docker-compose -f docker-compose.mumbai.yml down --volumes + docker-compose -f docker-compose.mumbai.yml up -d mumbai-db \ No newline at end of file diff --git a/Tzkt.Data/Models/Accounts/Account.cs b/Tzkt.Data/Models/Accounts/Account.cs index dac96e2b1..916424728 100644 --- a/Tzkt.Data/Models/Accounts/Account.cs +++ b/Tzkt.Data/Models/Accounts/Account.cs @@ -24,7 +24,6 @@ public class Account public int TokenBalancesCount { get; set; } public int TokenTransfersCount { get; set; } - public int ActiveTicketsCount { get; set; } public int TicketBalancesCount { get; set; } public int TicketTransfersCount { get; set; } diff --git a/Tzkt.Data/Models/Accounts/Contract.cs b/Tzkt.Data/Models/Accounts/Contract.cs index 8f7390a8a..e838c6fdd 100644 --- a/Tzkt.Data/Models/Accounts/Contract.cs +++ b/Tzkt.Data/Models/Accounts/Contract.cs @@ -12,7 +12,6 @@ public class Contract : Account public ContractTags Tags { get; set; } public int TokensCount { get; set; } public int EventsCount { get; set; } - public int TicketsCount { get; set; } public bool? Spendable { get; set; } diff --git a/Tzkt.Data/Models/Operations/Base/ContractOperation.cs b/Tzkt.Data/Models/Operations/Base/ContractOperation.cs index 9d8315d1f..70cfcb8a5 100644 --- a/Tzkt.Data/Models/Operations/Base/ContractOperation.cs +++ b/Tzkt.Data/Models/Operations/Base/ContractOperation.cs @@ -5,6 +5,7 @@ public class ContractOperation : InternalOperation public int? StorageId { get; set; } public int? BigMapUpdates { get; set; } public int? TokenTransfers { get; set; } + public int? SubIds { get; set; } } } diff --git a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs index 77ab59c24..75c18c06e 100644 --- a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs +++ b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs @@ -18,8 +18,7 @@ public class MigrationOperation public int? StorageId { get; set; } public int? BigMapUpdates { get; set; } public int? TokenTransfers { get; set; } - - //TODO Add Tickets to migrations? + public int? TicketTransfers { get; set; } public int? SubIds { get; set; } diff --git a/Tzkt.Data/Models/Operations/TransactionOperation.cs b/Tzkt.Data/Models/Operations/TransactionOperation.cs index 9ff983341..801d7c0af 100644 --- a/Tzkt.Data/Models/Operations/TransactionOperation.cs +++ b/Tzkt.Data/Models/Operations/TransactionOperation.cs @@ -23,7 +23,6 @@ public class TransactionOperation : ContractOperation public short? InternalTransactions { get; set; } public int? EventsCount { get; set; } - public int? TicketTransfers { get; set; } #region relations diff --git a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs index 008971736..c69531335 100644 --- a/Tzkt.Data/Models/Operations/TransferTicketOperation.cs +++ b/Tzkt.Data/Models/Operations/TransferTicketOperation.cs @@ -1,5 +1,4 @@ -using System.ComponentModel.DataAnnotations.Schema; -using System.Numerics; +using System.Numerics; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Tzkt.Data.Models.Base; diff --git a/Tzkt.Sync.Tests/Database/AppStateTests.cs b/Tzkt.Sync.Tests/Database/AppStateTests.cs index 52f1729a8..8497f3469 100644 --- a/Tzkt.Sync.Tests/Database/AppStateTests.cs +++ b/Tzkt.Sync.Tests/Database/AppStateTests.cs @@ -265,6 +265,15 @@ await db.TransactionOps.CountAsync(x => x.InitiatorId == null) + if (state.TokenTransfersCount != await db.TokenTransfers.CountAsync()) throw new Exception("Invalid AppState.TokenTransfersCount"); + if (state.TicketsCount != await db.Tickets.CountAsync()) + throw new Exception("Invalid AppState.TicketsCount"); + + if (state.TicketBalancesCount != await db.TicketBalances.CountAsync()) + throw new Exception("Invalid AppState.TicketBalancesCount"); + + if (state.TicketTransfersCount != await db.TicketTransfers.CountAsync()) + throw new Exception("Invalid AppState.TicketTransfersCount"); + if (state.EventsCount != await db.Events.CountAsync()) throw new Exception("Invalid AppState.EventsCount"); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/DelegationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/DelegationsCommit.cs index e1b2ca66e..28b48ba7f 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/DelegationsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/DelegationsCommit.cs @@ -464,6 +464,9 @@ void UpgradeUser(DelegationOperation delegation) ActiveTokensCount = user.ActiveTokensCount, TokenBalancesCount = user.TokenBalancesCount, TokenTransfersCount = user.TokenTransfersCount, + ActiveTicketsCount = user.ActiveTicketsCount, + TicketBalancesCount = user.TicketBalancesCount, + TicketTransfersCount = user.TicketTransfersCount, TransferTicketCount = user.TransferTicketCount, TxRollupCommitCount = user.TxRollupCommitCount, TxRollupDispatchTicketsCount = user.TxRollupDispatchTicketsCount, @@ -721,6 +724,9 @@ void DowngradeDelegate(DelegationOperation delegation) ActiveTokensCount = delegat.ActiveTokensCount, TokenBalancesCount = delegat.TokenBalancesCount, TokenTransfersCount = delegat.TokenTransfersCount, + ActiveTicketsCount = delegat.ActiveTicketsCount, + TicketBalancesCount = delegat.TicketBalancesCount, + TicketTransfersCount = delegat.TicketTransfersCount, TransferTicketCount = delegat.TransferTicketCount, TxRollupCommitCount = delegat.TxRollupCommitCount, TxRollupDispatchTicketsCount = delegat.TxRollupDispatchTicketsCount, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/OriginationsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/OriginationsCommit.cs index 4a6b17dac..fcb6cb5f8 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/OriginationsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/OriginationsCommit.cs @@ -64,7 +64,10 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content Spendable = GetSpendable(content), ActiveTokensCount = ghost.ActiveTokensCount, TokenBalancesCount = ghost.TokenBalancesCount, - TokenTransfersCount = ghost.TokenTransfersCount + TokenTransfersCount = ghost.TokenTransfersCount, + ActiveTicketsCount = ghost.ActiveTicketsCount, + TicketBalancesCount = ghost.TicketBalancesCount, + TicketTransfersCount = ghost.TicketTransfersCount }; Db.Entry(ghost).State = EntityState.Detached; Db.Entry(contract).State = EntityState.Modified; @@ -262,7 +265,10 @@ public virtual async Task ApplyInternal(Block block, ManagerOperation parent, Js Spendable = GetSpendable(content), ActiveTokensCount = ghost.ActiveTokensCount, TokenBalancesCount = ghost.TokenBalancesCount, - TokenTransfersCount = ghost.TokenTransfersCount + TokenTransfersCount = ghost.TokenTransfersCount, + ActiveTicketsCount = ghost.ActiveTicketsCount, + TicketBalancesCount = ghost.TicketBalancesCount, + TicketTransfersCount = ghost.TicketTransfersCount }; Db.Entry(ghost).State = EntityState.Detached; Db.Entry(contract).State = EntityState.Modified; @@ -473,7 +479,7 @@ public virtual async Task Revert(Block block, OriginationOperation origination) if (contract.Kind > ContractKind.DelegatorContract) await RevertScript(origination); - if (contract.TokenTransfersCount == 0) + if (contract.TokenTransfersCount == 0 && contract.TicketTransfersCount == 0) { Db.Contracts.Remove(contract); Cache.Accounts.Remove(contract); @@ -490,6 +496,9 @@ public virtual async Task Revert(Block block, OriginationOperation origination) ActiveTokensCount = contract.ActiveTokensCount, TokenBalancesCount = contract.TokenBalancesCount, TokenTransfersCount = contract.TokenTransfersCount, + ActiveTicketsCount = contract.ActiveTicketsCount, + TicketBalancesCount = contract.TicketBalancesCount, + TicketTransfersCount = contract.TicketTransfersCount, Type = AccountType.Ghost, }; @@ -598,7 +607,7 @@ public virtual async Task RevertInternal(Block block, OriginationOperation origi if (contract.Kind > ContractKind.DelegatorContract) await RevertScript(origination); - if (contract.TokenTransfersCount == 0) + if (contract.TokenTransfersCount == 0 && contract.TicketTransfersCount == 0) { Db.Contracts.Remove(contract); Cache.Accounts.Remove(contract); @@ -615,6 +624,9 @@ public virtual async Task RevertInternal(Block block, OriginationOperation origi ActiveTokensCount = contract.ActiveTokensCount, TokenBalancesCount = contract.TokenBalancesCount, TokenTransfersCount = contract.TokenTransfersCount, + ActiveTicketsCount = contract.ActiveTicketsCount, + TicketBalancesCount = contract.TicketBalancesCount, + TicketTransfersCount = contract.TicketTransfersCount, Type = AccountType.Ghost, }; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index de8003ef2..2f0d8838b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -688,7 +688,6 @@ protected virtual int GetConsumedGas(JsonElement result) return result.OptionalInt32("consumed_gas") ?? 0; } - //TODO Move to Proto16 protected virtual IEnumerable ParseTicketUpdates(string property, JsonElement result) { if (!result.TryGetProperty(property, out var ticketUpdates)) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 8f9abaffd..5d8f56b71 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -1,8 +1,5 @@ -using System; -using System.Numerics; +using System.Numerics; using System.Text.Json; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; using Netezos.Contracts; using Netezos.Encoding; using Tzkt.Data.Models; @@ -200,11 +197,45 @@ public virtual async Task Revert(Block block, TransferTicketOperation operation) Cache.AppState.ReleaseOperationId(); } - //TODO Move to Proto16 protected virtual IEnumerable ParseTicketUpdates(JsonElement result) { if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; + + return ticketUpdates.RequiredArray().EnumerateArray().Select(update => + { + try + { + var ticketToken = update.Required("ticket_token"); + var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); + var value = Micheline.FromJson(ticketToken.Required("content")); + var rawContent = micheType.Optimize(value).ToBytes(); + var rawType = micheType.ToMicheline().ToBytes(); + + return new TicketUpdate + { + TicketToken = new TicketToken + { + Ticketer = ticketToken.RequiredString("ticketer"), + RawType = rawType, + RawContent = rawContent, + JsonContent = micheType.Humanize(value), + ContentTypeHash = Script.GetHash(rawType), + ContentHash = Script.GetHash(rawContent) + }, + Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update + { + Account = y.RequiredString("account"), + Amount = BigInteger.Parse(y.RequiredString("amount")) + }) + }; + } + catch (Exception ex) + { + Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); + return null; + } + }).Where(update => update != null); var res = new List(); foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) @@ -241,29 +272,6 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul } return res; - - /*return ticketUpdates.RequiredArray().EnumerateArray().Select(x => new TicketUpdate - { - - - TicketToken = x.TryGetProperty("ticket_token", out var ticketToken) - ? new TicketToken - { - Ticketer = ticketToken.RequiredString("ticketer"), - RawType = Micheline.FromJson(ticketToken.Required("content_type")).ToBytes(), - RawContent = Micheline.FromJson(ticketToken.Required("content")).ToBytes(), - ContentTypeHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content_type")).ToBytes()), - ContentHash = Script.GetHash(Micheline.FromJson(ticketToken.Required("content")).ToBytes()) - } - : null, - Updates = x.TryGetProperty("updates", out var updates) - ? updates.RequiredArray().EnumerateArray().Select(y => new Update - { - Account = y.RequiredString("account"), - Amount = y.RequiredString("amount") - }) - : null - });*/ } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupOriginationCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupOriginationCommit.cs index c24d94992..01bcc06f7 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupOriginationCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TxRollupOriginationCommit.cs @@ -45,7 +45,10 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content Type = AccountType.Rollup, ActiveTokensCount = ghost.ActiveTokensCount, TokenBalancesCount = ghost.TokenBalancesCount, - TokenTransfersCount = ghost.TokenTransfersCount + TokenTransfersCount = ghost.TokenTransfersCount, + ActiveTicketsCount = ghost.ActiveTicketsCount, + TicketBalancesCount = ghost.TicketBalancesCount, + TicketTransfersCount = ghost.TicketTransfersCount }; Db.Entry(ghost).State = EntityState.Detached; Db.Entry(rollup).State = EntityState.Modified; @@ -186,7 +189,7 @@ public virtual async Task Revert(Block block, TxRollupOriginationOperation origi sender.RollupsCount--; - if (rollup.TokenTransfersCount == 0) + if (rollup.TokenTransfersCount == 0 && rollup.TicketTransfersCount == 0) { Db.Rollups.Remove(rollup); Cache.Accounts.Remove(rollup); @@ -203,6 +206,9 @@ public virtual async Task Revert(Block block, TxRollupOriginationOperation origi ActiveTokensCount = rollup.ActiveTokensCount, TokenBalancesCount = rollup.TokenBalancesCount, TokenTransfersCount = rollup.TokenTransfersCount, + ActiveTicketsCount = rollup.ActiveTicketsCount, + TicketBalancesCount = rollup.TicketBalancesCount, + TicketTransfersCount = rollup.TicketTransfersCount, Type = AccountType.Ghost, }; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupOriginateCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupOriginateCommit.cs index e1d613c44..da9381079 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupOriginateCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupOriginateCommit.cs @@ -60,7 +60,10 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content SmartRollupBonds = 0, ActiveTokensCount = ghost.ActiveTokensCount, TokenBalancesCount = ghost.TokenBalancesCount, - TokenTransfersCount = ghost.TokenTransfersCount + TokenTransfersCount = ghost.TokenTransfersCount, + ActiveTicketsCount = ghost.ActiveTicketsCount, + TicketBalancesCount = ghost.TicketBalancesCount, + TicketTransfersCount = ghost.TicketTransfersCount }; Db.Entry(ghost).State = EntityState.Detached; Db.Entry(rollup).State = EntityState.Modified; @@ -230,7 +233,7 @@ public virtual async Task Revert(Block block, SmartRollupOriginateOperation oper sender.SmartRollupsCount--; - if (rollup.TokenTransfersCount == 0) + if (rollup.TokenTransfersCount == 0 && rollup.TicketTransfersCount == 0) { Db.SmartRollups.Remove(rollup); Cache.Accounts.Remove(rollup); @@ -247,6 +250,9 @@ public virtual async Task Revert(Block block, SmartRollupOriginateOperation oper ActiveTokensCount = rollup.ActiveTokensCount, TokenBalancesCount = rollup.TokenBalancesCount, TokenTransfersCount = rollup.TokenTransfersCount, + ActiveTicketsCount = rollup.ActiveTicketsCount, + TicketBalancesCount = rollup.TicketBalancesCount, + TicketTransfersCount = rollup.TicketTransfersCount, Type = AccountType.Ghost, }; diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index c4e490be3..8807cc623 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -88,7 +88,7 @@ public virtual async Task Apply() }); } upds.updates.AddRange(upd.Updates); - //TODO That's wrong + //TODO That's wrong, isn't it? Parent operation everywhere? upds.operation = op; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs index baa9809d0..d3ec68cae 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs @@ -11,7 +11,6 @@ public Diagnostics(ProtocolHandler handler) : base(handler) { } protected override async Task TestTicketBalance(int level, TicketBalance balance) { - //TODO Make sure that's correct var ticketer = await Cache.Accounts.GetAsync(balance.TicketerId); var ticket = Cache.Tickets.Get(balance.TicketId); var account = await Cache.Accounts.GetAsync(balance.AccountId); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs index 7bad60df8..77c2f248a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Commits/Operations/TransactionsCommit.cs @@ -1,56 +1,7 @@ -using System.Numerics; -using System.Text.Json; -using Netezos.Contracts; -using Netezos.Encoding; -using Tzkt.Data.Models; - -namespace Tzkt.Sync.Protocols.Proto17 +namespace Tzkt.Sync.Protocols.Proto17 { - //TODO Move to Proto16 class TransactionsCommit : Proto14.TransactionsCommit { public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } - - protected override IEnumerable ParseTicketUpdates(string property, JsonElement result) - { - if (!result.TryGetProperty(property, out var ticketUpdates)) - return null; - - var res = new List(); - foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) - { - try - { - var ticketToken = update.Required("ticket_token"); - var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); - var value = Micheline.FromJson(ticketToken.Required("content")); - var rawContent = micheType.Optimize(value).ToBytes(); - var rawType = micheType.ToMicheline().ToBytes(); - res.Add(new TicketUpdate - { - TicketToken = new TicketToken - { - Ticketer = ticketToken.RequiredString("ticketer"), - RawType = rawType, - RawContent = rawContent, - JsonContent = micheType.Humanize(value), - ContentTypeHash = Script.GetHash(rawType), - ContentHash = Script.GetHash(rawContent) - }, - Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update - { - Account = y.RequiredString("account"), - Amount = BigInteger.Parse(y.RequiredString("amount")) - }) - }); - } - catch (Exception ex) - { - Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); - } - } - - return res; - } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index 861038327..2459b3695 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -482,12 +482,12 @@ public override async Task Revert() if (currBlock.Operations.HasFlag(Operations.SmartRollupRefute)) operations.AddRange(await Db.SmartRollupRefuteOps.Where(x => x.Level == currBlock.Level).ToListAsync()); -if (currBlock.Events.HasFlag(BlockEvents.NewAccounts)) -{ - await Db.Entry(currBlock).Collection(x => x.CreatedAccounts).LoadAsync(); - foreach (var account in currBlock.CreatedAccounts) - Cache.Accounts.Add(account); -} + if (currBlock.Events.HasFlag(BlockEvents.NewAccounts)) + { + await Db.Entry(currBlock).Collection(x => x.CreatedAccounts).LoadAsync(); + foreach (var account in currBlock.CreatedAccounts) + Cache.Accounts.Add(account); + } #endregion await new VotingCommit(this).Revert(currBlock); diff --git a/Tzkt.Sync/Services/TezosNode/TezosNode.cs b/Tzkt.Sync/Services/TezosNode/TezosNode.cs index 1d8e5f2ae..d7e1b1684 100644 --- a/Tzkt.Sync/Services/TezosNode/TezosNode.cs +++ b/Tzkt.Sync/Services/TezosNode/TezosNode.cs @@ -1,13 +1,7 @@ -using System; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; +using Microsoft.EntityFrameworkCore; using System.Text.Json; using Tzkt.Data; using Tzkt.Data.Models; -using Tzkt.Sync.Protocols; namespace Tzkt.Sync.Services { diff --git a/Tzkt.Sync/Utils/TzktClient.cs b/Tzkt.Sync/Utils/TzktClient.cs index 9e9f085f6..350a77d78 100644 --- a/Tzkt.Sync/Utils/TzktClient.cs +++ b/Tzkt.Sync/Utils/TzktClient.cs @@ -31,7 +31,7 @@ HttpClient HttpClient _HttpClient.BaseAddress = BaseAddress; _HttpClient.DefaultRequestHeaders.Accept.Add( - new MediaTypeWithQualityHeaderValue("application/json")); + new MediaTypeWithQualityHeaderValue("application/json")); _HttpClient.DefaultRequestHeaders.UserAgent.Add( new ProductInfoHeaderValue("TzKT-Indexer", Assembly.GetExecutingAssembly().GetName().Version.ToString())); _HttpClient.Timeout = RequestTimeout; diff --git a/docker-compose.ghost.yml b/docker-compose.ghost.yml index 4f506cac1..fc36bb7fe 100644 --- a/docker-compose.ghost.yml +++ b/docker-compose.ghost.yml @@ -34,6 +34,7 @@ services: ConnectionStrings__DefaultConnection: host=ghost-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; Kestrel__Endpoints__Http__Url: http://0.0.0.0:5001 TezosNode__Endpoint: https://rpc.tzkt.io/ghostnet/ + Protocols__Diagnostics: true depends_on: - ghost-db ports: diff --git a/docker-compose.nairobi.yml b/docker-compose.nairobi.yml index 843981f1f..0d20b7b53 100644 --- a/docker-compose.nairobi.yml +++ b/docker-compose.nairobi.yml @@ -34,6 +34,7 @@ services: ConnectionStrings__DefaultConnection: host=nairobi-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; Kestrel__Endpoints__Http__Url: http://0.0.0.0:5001 TezosNode__Endpoint: https://rpc.tzkt.io/nairobinet/ + Protocols__Diagnostics: true depends_on: - nairobi-db ports: From 596356daf5ec966aee92c2b2a0a493c9fcc2d9fc Mon Sep 17 00:00:00 2001 From: dmir Date: Fri, 11 Aug 2023 14:39:07 +0300 Subject: [PATCH 24/51] Return nairobi migration --- ....cs => 20230425183139_Nairobi.Designer.cs} | 240 +------------ .../Migrations/20230425183139_Nairobi.cs | 28 ++ .../Migrations/20230809161830_tickets.cs | 338 ------------------ .../Migrations/TzktContextModelSnapshot.cs | 232 +----------- Tzkt.Sync/Utils/TzktClient.cs | 2 - 5 files changed, 34 insertions(+), 806 deletions(-) rename Tzkt.Data/Migrations/{20230809161830_tickets.Designer.cs => 20230425183139_Nairobi.Designer.cs} (96%) create mode 100644 Tzkt.Data/Migrations/20230425183139_Nairobi.cs delete mode 100644 Tzkt.Data/Migrations/20230809161830_tickets.cs diff --git a/Tzkt.Data/Migrations/20230809161830_tickets.Designer.cs b/Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs similarity index 96% rename from Tzkt.Data/Migrations/20230809161830_tickets.Designer.cs rename to Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs index 2b984129c..19dca4a2e 100644 --- a/Tzkt.Data/Migrations/20230809161830_tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230425183139_Nairobi.Designer.cs @@ -1,4 +1,4 @@ -// +// using System; using System.Text.Json; using Microsoft.EntityFrameworkCore; @@ -13,15 +13,15 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230809161830_tickets")] - partial class tickets + [Migration("20230425183139_Nairobi")] + partial class Nairobi { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("ProductVersion", "7.0.4") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -37,9 +37,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); - b.Property("ActiveTicketsCount") - .HasColumnType("integer"); - b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -132,12 +129,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -460,15 +451,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("StorageCounter") .HasColumnType("integer"); - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -594,9 +576,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, StorageCounter = 0, - TicketBalancesCount = 0, - TicketTransfersCount = 0, - TicketsCount = 0, Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TokenBalancesCount = 0, TokenTransfersCount = 0, @@ -3574,203 +3553,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("Storages"); }); - modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContentHash") - .HasColumnType("integer"); - - b.Property("ContentTypeHash") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("JsonContent") - .HasColumnType("text"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("RawContent") - .HasColumnType("bytea"); - - b.Property("RawType") - .HasColumnType("bytea"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("TicketerId"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("LastLevel"); - - b.HasIndex("TicketId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("TicketerId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "TicketId") - .IsUnique(); - - b.HasIndex("AccountId", "TicketerId"); - - b.ToTable("TicketBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("TransferTicketId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("TicketId"); - - b.HasIndex("TicketerId"); - - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.HasIndex("TransferTicketId") - .HasFilter("\"TransferTicketId\" is not null"); - - b.ToTable("TicketTransfers"); - }); - modelBuilder.Entity("Tzkt.Data.Models.Token", b => { b.Property("Id") @@ -4088,9 +3870,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -4191,15 +3970,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); - b.Property("SubIds") - .HasColumnType("integer"); - b.Property("TargetId") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("TicketerId") .HasColumnType("integer"); @@ -5063,9 +4836,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); - b.Property("TicketsCount") - .HasColumnType("integer"); - b.Property("TokensCount") .HasColumnType("integer"); @@ -6279,4 +6049,4 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) #pragma warning restore 612, 618 } } -} +} \ No newline at end of file diff --git a/Tzkt.Data/Migrations/20230425183139_Nairobi.cs b/Tzkt.Data/Migrations/20230425183139_Nairobi.cs new file mode 100644 index 000000000..cf63c2ef9 --- /dev/null +++ b/Tzkt.Data/Migrations/20230425183139_Nairobi.cs @@ -0,0 +1,28 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class Nairobi : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Protocol", + table: "InboxMessages", + type: "text", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Protocol", + table: "InboxMessages"); + } + } +} diff --git a/Tzkt.Data/Migrations/20230809161830_tickets.cs b/Tzkt.Data/Migrations/20230809161830_tickets.cs deleted file mode 100644 index 5846ed8cb..000000000 --- a/Tzkt.Data/Migrations/20230809161830_tickets.cs +++ /dev/null @@ -1,338 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; - -#nullable disable - -namespace Tzkt.Data.Migrations -{ - /// - public partial class tickets : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "SubIds", - table: "TransferTicketOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "TransferTicketOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketTransfers", - table: "TransactionOps", - type: "integer", - nullable: true); - - migrationBuilder.AddColumn( - name: "Protocol", - table: "InboxMessages", - type: "text", - nullable: true); - - migrationBuilder.AddColumn( - name: "TicketBalancesCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketTransfersCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketsCount", - table: "AppState", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "ActiveTicketsCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketBalancesCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketTransfersCount", - table: "Accounts", - type: "integer", - nullable: false, - defaultValue: 0); - - migrationBuilder.AddColumn( - name: "TicketsCount", - table: "Accounts", - type: "integer", - nullable: true); - - migrationBuilder.CreateTable( - name: "TicketBalances", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TicketerId = table.Column(type: "integer", nullable: false), - TicketId = table.Column(type: "bigint", nullable: false), - AccountId = table.Column(type: "integer", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - TransfersCount = table.Column(type: "integer", nullable: false), - Balance = table.Column(type: "text", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TicketBalances", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Tickets", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - TicketerId = table.Column(type: "integer", nullable: false), - FirstMinterId = table.Column(type: "integer", nullable: false), - FirstLevel = table.Column(type: "integer", nullable: false), - LastLevel = table.Column(type: "integer", nullable: false), - TransfersCount = table.Column(type: "integer", nullable: false), - BalancesCount = table.Column(type: "integer", nullable: false), - HoldersCount = table.Column(type: "integer", nullable: false), - TotalMinted = table.Column(type: "text", nullable: false), - TotalBurned = table.Column(type: "text", nullable: false), - TotalSupply = table.Column(type: "text", nullable: false), - ContentHash = table.Column(type: "integer", nullable: false), - ContentTypeHash = table.Column(type: "integer", nullable: false), - RawContent = table.Column(type: "bytea", nullable: true), - RawType = table.Column(type: "bytea", nullable: true), - JsonContent = table.Column(type: "text", nullable: true), - Metadata = table.Column(type: "jsonb", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_Tickets", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "TicketTransfers", - columns: table => new - { - Id = table.Column(type: "bigint", nullable: false) - .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), - Level = table.Column(type: "integer", nullable: false), - TicketerId = table.Column(type: "integer", nullable: false), - TicketId = table.Column(type: "bigint", nullable: false), - Amount = table.Column(type: "text", nullable: false), - FromId = table.Column(type: "integer", nullable: true), - ToId = table.Column(type: "integer", nullable: true), - TransferTicketId = table.Column(type: "bigint", nullable: true), - TransactionId = table.Column(type: "bigint", nullable: true), - MigrationId = table.Column(type: "bigint", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_TicketTransfers", x => x.Id); - }); - - migrationBuilder.UpdateData( - table: "AppState", - keyColumn: "Id", - keyValue: -1, - columns: new[] { "TicketBalancesCount", "TicketTransfersCount", "TicketsCount" }, - values: new object[] { 0, 0, 0 }); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_AccountId", - table: "TicketBalances", - column: "AccountId", - filter: "\"Balance\" != '0'"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_AccountId_TicketerId", - table: "TicketBalances", - columns: new[] { "AccountId", "TicketerId" }); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_AccountId_TicketId", - table: "TicketBalances", - columns: new[] { "AccountId", "TicketId" }, - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_Id", - table: "TicketBalances", - column: "Id", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_LastLevel", - table: "TicketBalances", - column: "LastLevel"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_TicketerId", - table: "TicketBalances", - column: "TicketerId", - filter: "\"Balance\" != '0'"); - - migrationBuilder.CreateIndex( - name: "IX_TicketBalances_TicketId", - table: "TicketBalances", - column: "TicketId", - filter: "\"Balance\" != '0'"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_FirstMinterId", - table: "Tickets", - column: "FirstMinterId"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_Id", - table: "Tickets", - column: "Id", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_LastLevel", - table: "Tickets", - column: "LastLevel"); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_Metadata", - table: "Tickets", - column: "Metadata") - .Annotation("Npgsql:IndexMethod", "gin") - .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); - - migrationBuilder.CreateIndex( - name: "IX_Tickets_TicketerId", - table: "Tickets", - column: "TicketerId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_FromId", - table: "TicketTransfers", - column: "FromId", - filter: "\"FromId\" is not null"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_Id", - table: "TicketTransfers", - column: "Id", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_Level", - table: "TicketTransfers", - column: "Level"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_MigrationId", - table: "TicketTransfers", - column: "MigrationId", - filter: "\"MigrationId\" is not null"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_TicketerId", - table: "TicketTransfers", - column: "TicketerId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_TicketId", - table: "TicketTransfers", - column: "TicketId"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_ToId", - table: "TicketTransfers", - column: "ToId", - filter: "\"ToId\" is not null"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_TransactionId", - table: "TicketTransfers", - column: "TransactionId", - filter: "\"TransactionId\" is not null"); - - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_TransferTicketId", - table: "TicketTransfers", - column: "TransferTicketId", - filter: "\"TransferTicketId\" is not null"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "TicketBalances"); - - migrationBuilder.DropTable( - name: "Tickets"); - - migrationBuilder.DropTable( - name: "TicketTransfers"); - - migrationBuilder.DropColumn( - name: "SubIds", - table: "TransferTicketOps"); - - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "TransferTicketOps"); - - migrationBuilder.DropColumn( - name: "TicketTransfers", - table: "TransactionOps"); - - migrationBuilder.DropColumn( - name: "Protocol", - table: "InboxMessages"); - - migrationBuilder.DropColumn( - name: "TicketBalancesCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "TicketTransfersCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "TicketsCount", - table: "AppState"); - - migrationBuilder.DropColumn( - name: "ActiveTicketsCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketBalancesCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketTransfersCount", - table: "Accounts"); - - migrationBuilder.DropColumn( - name: "TicketsCount", - table: "Accounts"); - } - } -} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 5ca456812..b849d89d1 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("ProductVersion", "7.0.4") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -34,9 +34,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); - b.Property("ActiveTicketsCount") - .HasColumnType("integer"); - b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -129,12 +126,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -457,15 +448,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageCounter") .HasColumnType("integer"); - b.Property("TicketBalancesCount") - .HasColumnType("integer"); - - b.Property("TicketTransfersCount") - .HasColumnType("integer"); - - b.Property("TicketsCount") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -591,9 +573,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, StorageCounter = 0, - TicketBalancesCount = 0, - TicketTransfersCount = 0, - TicketsCount = 0, Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TokenBalancesCount = 0, TokenTransfersCount = 0, @@ -3571,203 +3550,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Storages"); }); - modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("BalancesCount") - .HasColumnType("integer"); - - b.Property("ContentHash") - .HasColumnType("integer"); - - b.Property("ContentTypeHash") - .HasColumnType("integer"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("FirstMinterId") - .HasColumnType("integer"); - - b.Property("HoldersCount") - .HasColumnType("integer"); - - b.Property("JsonContent") - .HasColumnType("text"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("Metadata") - .HasColumnType("jsonb"); - - b.Property("RawContent") - .HasColumnType("bytea"); - - b.Property("RawType") - .HasColumnType("bytea"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TotalBurned") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalMinted") - .IsRequired() - .HasColumnType("text"); - - b.Property("TotalSupply") - .IsRequired() - .HasColumnType("text"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("FirstMinterId"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("LastLevel"); - - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - - b.HasIndex("TicketerId"); - - b.ToTable("Tickets"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountId") - .HasColumnType("integer"); - - b.Property("Balance") - .IsRequired() - .HasColumnType("text"); - - b.Property("FirstLevel") - .HasColumnType("integer"); - - b.Property("LastLevel") - .HasColumnType("integer"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("TransfersCount") - .HasColumnType("integer"); - - b.HasKey("Id"); - - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("LastLevel"); - - b.HasIndex("TicketId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("TicketerId") - .HasFilter("\"Balance\" != '0'"); - - b.HasIndex("AccountId", "TicketId") - .IsUnique(); - - b.HasIndex("AccountId", "TicketerId"); - - b.ToTable("TicketBalances"); - }); - - modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Amount") - .IsRequired() - .HasColumnType("text"); - - b.Property("FromId") - .HasColumnType("integer"); - - b.Property("Level") - .HasColumnType("integer"); - - b.Property("MigrationId") - .HasColumnType("bigint"); - - b.Property("TicketId") - .HasColumnType("bigint"); - - b.Property("TicketerId") - .HasColumnType("integer"); - - b.Property("ToId") - .HasColumnType("integer"); - - b.Property("TransactionId") - .HasColumnType("bigint"); - - b.Property("TransferTicketId") - .HasColumnType("bigint"); - - b.HasKey("Id"); - - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); - - b.HasIndex("Id") - .IsUnique(); - - b.HasIndex("Level"); - - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - - b.HasIndex("TicketId"); - - b.HasIndex("TicketerId"); - - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); - - b.HasIndex("TransactionId") - .HasFilter("\"TransactionId\" is not null"); - - b.HasIndex("TransferTicketId") - .HasFilter("\"TransferTicketId\" is not null"); - - b.ToTable("TicketTransfers"); - }); - modelBuilder.Entity("Tzkt.Data.Models.Token", b => { b.Property("Id") @@ -4085,9 +3867,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -4188,15 +3967,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); - b.Property("SubIds") - .HasColumnType("integer"); - b.Property("TargetId") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("TicketerId") .HasColumnType("integer"); @@ -5060,9 +4833,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); - b.Property("TicketsCount") - .HasColumnType("integer"); - b.Property("TokensCount") .HasColumnType("integer"); diff --git a/Tzkt.Sync/Utils/TzktClient.cs b/Tzkt.Sync/Utils/TzktClient.cs index 350a77d78..3eecb01c9 100644 --- a/Tzkt.Sync/Utils/TzktClient.cs +++ b/Tzkt.Sync/Utils/TzktClient.cs @@ -72,8 +72,6 @@ public async Task PostAsync(string path, string content) using var stream = await response.Content.ReadAsStreamAsync(); return await JsonSerializer.DeserializeAsync(stream); } - - public void Dispose() => _HttpClient?.Dispose(); } From 13c4af57b711f4c8170b89e6e982ed9930a4d44f Mon Sep 17 00:00:00 2001 From: dmir Date: Sun, 13 Aug 2023 14:40:36 +0300 Subject: [PATCH 25/51] Return tickets migration --- .../20230812082232_Tickets.Designer.cs | 6285 +++++++++++++++++ .../Migrations/20230812082232_Tickets.cs | 338 + .../Migrations/TzktContextModelSnapshot.cs | 235 +- .../Operations/Base/ContractOperation.cs | 2 +- 4 files changed, 6858 insertions(+), 2 deletions(-) create mode 100644 Tzkt.Data/Migrations/20230812082232_Tickets.Designer.cs create mode 100644 Tzkt.Data/Migrations/20230812082232_Tickets.cs diff --git a/Tzkt.Data/Migrations/20230812082232_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230812082232_Tickets.Designer.cs new file mode 100644 index 000000000..1295ff66e --- /dev/null +++ b/Tzkt.Data/Migrations/20230812082232_Tickets.Designer.cs @@ -0,0 +1,6285 @@ +// +using System; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Tzkt.Data; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + [DbContext(typeof(TzktContext))] + [Migration("20230812082232_Tickets")] + partial class Tickets + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveRefutationGamesCount") + .HasColumnType("integer"); + + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + + b.Property("ActiveTokensCount") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character varying(37)"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("ContractsCount") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegationLevel") + .HasColumnType("integer"); + + b.Property("DelegationsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageCount") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("MigrationsCount") + .HasColumnType("integer"); + + b.Property("OriginationsCount") + .HasColumnType("integer"); + + b.Property("RefutationGamesCount") + .HasColumnType("integer"); + + b.Property("RevealsCount") + .HasColumnType("integer"); + + b.Property("RollupBonds") + .HasColumnType("bigint"); + + b.Property("RollupsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesCount") + .HasColumnType("integer"); + + b.Property("SmartRollupBonds") + .HasColumnType("bigint"); + + b.Property("SmartRollupCementCount") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteCount") + .HasColumnType("integer"); + + b.Property("SmartRollupsCount") + .HasColumnType("integer"); + + b.Property("Staked") + .HasColumnType("boolean"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TransactionsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchCount") + .HasColumnType("integer"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.Property("UpdateConsensusKeyCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("DelegateId"); + + b.HasIndex("Extras"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Extras"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Extras"), new[] { "jsonb_path_ops" }); + + b.HasIndex("FirstLevel"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Staked"); + + b.HasIndex("Type"); + + b.ToTable("Accounts"); + + b.HasDiscriminator("Type").HasValue((byte)3); + + b.UseTphMappingStrategy(); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("ActivationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.AppState", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountCounter") + .HasColumnType("integer"); + + b.Property("AccountsCount") + .HasColumnType("integer"); + + b.Property("ActivationOpsCount") + .HasColumnType("integer"); + + b.Property("BallotOpsCount") + .HasColumnType("integer"); + + b.Property("BigMapCounter") + .HasColumnType("integer"); + + b.Property("BigMapKeyCounter") + .HasColumnType("integer"); + + b.Property("BigMapUpdateCounter") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Chain") + .HasColumnType("text"); + + b.Property("ChainId") + .HasColumnType("text"); + + b.Property("CommitmentsCount") + .HasColumnType("integer"); + + b.Property("ConstantsCount") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("CyclesCount") + .HasColumnType("integer"); + + b.Property("DelegationOpsCount") + .HasColumnType("integer"); + + b.Property("DomainsLevel") + .HasColumnType("integer"); + + b.Property("DomainsNameRegistry") + .HasColumnType("text"); + + b.Property("DoubleBakingOpsCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingOpsCount") + .HasColumnType("integer"); + + b.Property("DrainDelegateOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsementOpsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardOpsCount") + .HasColumnType("integer"); + + b.Property("EventCounter") + .HasColumnType("integer"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxMessageCounter") + .HasColumnType("integer"); + + b.Property("IncreasePaidStorageOpsCount") + .HasColumnType("integer"); + + b.Property("KnownHead") + .HasColumnType("integer"); + + b.Property("LastSync") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerCounter") + .HasColumnType("integer"); + + b.Property("MigrationOpsCount") + .HasColumnType("integer"); + + b.Property("NextProtocol") + .HasColumnType("text"); + + b.Property("NonceRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("OperationCounter") + .HasColumnType("bigint"); + + b.Property("OriginationOpsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalOpsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("ProtocolsCount") + .HasColumnType("integer"); + + b.Property("QuoteBtc") + .HasColumnType("double precision"); + + b.Property("QuoteCny") + .HasColumnType("double precision"); + + b.Property("QuoteEth") + .HasColumnType("double precision"); + + b.Property("QuoteEur") + .HasColumnType("double precision"); + + b.Property("QuoteGbp") + .HasColumnType("double precision"); + + b.Property("QuoteJpy") + .HasColumnType("double precision"); + + b.Property("QuoteKrw") + .HasColumnType("double precision"); + + b.Property("QuoteLevel") + .HasColumnType("integer"); + + b.Property("QuoteUsd") + .HasColumnType("double precision"); + + b.Property("RefutationGameCounter") + .HasColumnType("integer"); + + b.Property("RegisterConstantOpsCount") + .HasColumnType("integer"); + + b.Property("RevealOpsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltyOpsCount") + .HasColumnType("integer"); + + b.Property("ScriptCounter") + .HasColumnType("integer"); + + b.Property("SetDepositsLimitOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupAddMessagesOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCementOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentCounter") + .HasColumnType("integer"); + + b.Property("SmartRollupExecuteOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginateOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupPublishOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRecoverBondOpsCount") + .HasColumnType("integer"); + + b.Property("SmartRollupRefuteOpsCount") + .HasColumnType("integer"); + + b.Property("StorageCounter") + .HasColumnType("integer"); + + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenBalancesCount") + .HasColumnType("integer"); + + b.Property("TokenTransfersCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TransactionOpsCount") + .HasColumnType("integer"); + + b.Property("TransferTicketOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupCommitOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupDispatchTicketsOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupFinalizeCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupOriginationOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRejectionOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupRemoveCommitmentOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupReturnBondOpsCount") + .HasColumnType("integer"); + + b.Property("TxRollupSubmitBatchOpsCount") + .HasColumnType("integer"); + + b.Property("UpdateConsensusKeyOpsCount") + .HasColumnType("integer"); + + b.Property("VdfRevelationOpsCount") + .HasColumnType("integer"); + + b.Property("VotingEpoch") + .HasColumnType("integer"); + + b.Property("VotingPeriod") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("AppState"); + + b.HasData( + new + { + Id = -1, + AccountCounter = 0, + AccountsCount = 0, + ActivationOpsCount = 0, + BallotOpsCount = 0, + BigMapCounter = 0, + BigMapKeyCounter = 0, + BigMapUpdateCounter = 0, + BlocksCount = 0, + CommitmentsCount = 0, + ConstantsCount = 0, + Cycle = -1, + CyclesCount = 0, + DelegationOpsCount = 0, + DomainsLevel = 0, + DoubleBakingOpsCount = 0, + DoubleEndorsingOpsCount = 0, + DoublePreendorsingOpsCount = 0, + DrainDelegateOpsCount = 0, + EndorsementOpsCount = 0, + EndorsingRewardOpsCount = 0, + EventCounter = 0, + EventsCount = 0, + Hash = "", + InboxMessageCounter = 0, + IncreasePaidStorageOpsCount = 0, + KnownHead = 0, + LastSync = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + Level = -1, + ManagerCounter = 0, + MigrationOpsCount = 0, + NextProtocol = "", + NonceRevelationOpsCount = 0, + OperationCounter = 0L, + OriginationOpsCount = 0, + PreendorsementOpsCount = 0, + ProposalOpsCount = 0, + ProposalsCount = 0, + Protocol = "", + ProtocolsCount = 0, + QuoteBtc = 0.0, + QuoteCny = 0.0, + QuoteEth = 0.0, + QuoteEur = 0.0, + QuoteGbp = 0.0, + QuoteJpy = 0.0, + QuoteKrw = 0.0, + QuoteLevel = -1, + QuoteUsd = 0.0, + RefutationGameCounter = 0, + RegisterConstantOpsCount = 0, + RevealOpsCount = 0, + RevelationPenaltyOpsCount = 0, + ScriptCounter = 0, + SetDepositsLimitOpsCount = 0, + SmartRollupAddMessagesOpsCount = 0, + SmartRollupCementOpsCount = 0, + SmartRollupCommitmentCounter = 0, + SmartRollupExecuteOpsCount = 0, + SmartRollupOriginateOpsCount = 0, + SmartRollupPublishOpsCount = 0, + SmartRollupRecoverBondOpsCount = 0, + SmartRollupRefuteOpsCount = 0, + StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, + Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), + TokenBalancesCount = 0, + TokenTransfersCount = 0, + TokensCount = 0, + TransactionOpsCount = 0, + TransferTicketOpsCount = 0, + TxRollupCommitOpsCount = 0, + TxRollupDispatchTicketsOpsCount = 0, + TxRollupFinalizeCommitmentOpsCount = 0, + TxRollupOriginationOpsCount = 0, + TxRollupRejectionOpsCount = 0, + TxRollupRemoveCommitmentOpsCount = 0, + TxRollupReturnBondOpsCount = 0, + TxRollupSubmitBatchOpsCount = 0, + UpdateConsensusKeyOpsCount = 0, + VdfRevelationOpsCount = 0, + VotingEpoch = -1, + VotingPeriod = -1 + }); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakerCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStake") + .HasColumnType("bigint"); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("BlockFees") + .HasColumnType("bigint"); + + b.Property("BlockRewards") + .HasColumnType("bigint"); + + b.Property("Blocks") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleBakingRewards") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingRewards") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingLosses") + .HasColumnType("bigint"); + + b.Property("DoublePreendorsingRewards") + .HasColumnType("bigint"); + + b.Property("EndorsementRewards") + .HasColumnType("bigint"); + + b.Property("Endorsements") + .HasColumnType("integer"); + + b.Property("ExpectedBlocks") + .HasColumnType("double precision"); + + b.Property("ExpectedEndorsements") + .HasColumnType("double precision"); + + b.Property("FutureBlockRewards") + .HasColumnType("bigint"); + + b.Property("FutureBlocks") + .HasColumnType("integer"); + + b.Property("FutureEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("FutureEndorsements") + .HasColumnType("integer"); + + b.Property("MissedBlockFees") + .HasColumnType("bigint"); + + b.Property("MissedBlockRewards") + .HasColumnType("bigint"); + + b.Property("MissedBlocks") + .HasColumnType("integer"); + + b.Property("MissedEndorsementRewards") + .HasColumnType("bigint"); + + b.Property("MissedEndorsements") + .HasColumnType("integer"); + + b.Property("RevelationLosses") + .HasColumnType("bigint"); + + b.Property("RevelationRewards") + .HasColumnType("bigint"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Cycle", "BakerId") + .IsUnique(); + + b.ToTable("BakerCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BakingRight", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Round") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("Type") + .HasColumnType("smallint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("Cycle", "BakerId"); + + b.ToTable("BakingRights"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Vote") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("BallotOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMap", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("ActiveKeys") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("KeyType") + .HasColumnType("bytea"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Ptr") + .HasColumnType("integer"); + + b.Property("StoragePath") + .HasColumnType("text"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TotalKeys") + .HasColumnType("integer"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.Property("ValueType") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasAlternateKey("Ptr"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Ptr") + .IsUnique(); + + b.ToTable("BigMaps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Active") + .HasColumnType("boolean"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("JsonKey") + .HasColumnType("jsonb"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("KeyHash") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("RawKey") + .HasColumnType("bytea"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("Updates") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonKey"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonKey"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonKey"), new[] { "jsonb_path_ops" }); + + b.HasIndex("JsonValue"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonValue"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonValue"), new[] { "jsonb_path_ops" }); + + b.HasIndex("LastLevel"); + + b.HasIndex("BigMapPtr", "Active") + .HasFilter("\"Active\" = true"); + + b.HasIndex("BigMapPtr", "KeyHash"); + + b.ToTable("BigMapKeys"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BigMapUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Action") + .HasColumnType("integer"); + + b.Property("BigMapKeyId") + .HasColumnType("integer"); + + b.Property("BigMapPtr") + .HasColumnType("integer"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("BigMapKeyId") + .HasFilter("\"BigMapKeyId\" is not null"); + + b.HasIndex("BigMapPtr"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("BigMapUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlockRound") + .HasColumnType("integer"); + + b.Property("Bonus") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Events") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("Fees") + .HasColumnType("bigint"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBToggle") + .HasColumnType("boolean"); + + b.Property("LBToggleEma") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Operations") + .HasColumnType("bigint"); + + b.Property("PayloadRound") + .HasColumnType("integer"); + + b.Property("ProducerId") + .HasColumnType("integer"); + + b.Property("ProposerId") + .HasColumnType("integer"); + + b.Property("ProtoCode") + .HasColumnType("integer"); + + b.Property("ResetBakerDeactivation") + .HasColumnType("integer"); + + b.Property("ResetProposerDeactivation") + .HasColumnType("integer"); + + b.Property("RevelationId") + .HasColumnType("bigint"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Validations") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Hash") + .IsUnique(); + + b.HasIndex("Level") + .IsUnique(); + + b.HasIndex("ProducerId"); + + b.HasIndex("ProposerId"); + + b.HasIndex("ProtoCode"); + + b.HasIndex("RevelationId") + .IsUnique(); + + b.HasIndex("SoftwareId"); + + b.ToTable("Blocks"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Commitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Address") + .IsRequired() + .HasMaxLength(37) + .HasColumnType("character(37)") + .IsFixedLength(); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique(); + + b.HasIndex("Id") + .IsUnique(); + + b.ToTable("Commitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ContractEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("JsonPayload") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("RawPayload") + .HasColumnType("bytea"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("Type") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("JsonPayload"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonPayload"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonPayload"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("Tag"); + + b.HasIndex("TransactionId"); + + b.HasIndex("ContractCodeHash", "Tag"); + + b.HasIndex("ContractId", "Tag"); + + b.ToTable("Events"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Cycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Seed") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("SelectedBakers") + .HasColumnType("integer"); + + b.Property("SelectedStake") + .HasColumnType("bigint"); + + b.Property("SnapshotIndex") + .HasColumnType("integer"); + + b.Property("SnapshotLevel") + .HasColumnType("integer"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalDelegated") + .HasColumnType("bigint"); + + b.Property("TotalDelegators") + .HasColumnType("integer"); + + b.Property("TotalStaking") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("Cycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PrevDelegateId") + .HasColumnType("integer"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("PrevDelegateId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.ToTable("DelegationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegatorCycle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("DelegatorId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.HasIndex("DelegatorId"); + + b.HasIndex("Cycle", "BakerId"); + + b.HasIndex("Cycle", "DelegatorId") + .IsUnique(); + + b.ToTable("DelegatorCycles"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Domain", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("jsonb"); + + b.Property("Expiration") + .HasColumnType("timestamp with time zone"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Owner") + .HasColumnType("text"); + + b.Property("Reverse") + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("Address"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Level"); + + b.HasIndex("Name"); + + b.HasIndex("Owner"); + + b.ToTable("Domains"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleBakingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoubleEndorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccusedLevel") + .HasColumnType("integer"); + + b.Property("AccuserId") + .HasColumnType("integer"); + + b.Property("AccuserReward") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OffenderId") + .HasColumnType("integer"); + + b.Property("OffenderLoss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("AccuserId"); + + b.HasIndex("Level"); + + b.HasIndex("OffenderId"); + + b.HasIndex("OpHash"); + + b.ToTable("DoublePreendorsingOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Fee") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("TargetId"); + + b.ToTable("DrainDelegateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Deposit") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("EndorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsingRewardOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Expected") + .HasColumnType("bigint"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Received") + .HasColumnType("bigint"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("EndorsingRewardOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.FreezerUpdate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Change") + .HasColumnType("bigint"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Cycle"); + + b.ToTable("FreezerUpdates"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.InboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OperationId") + .HasColumnType("bigint"); + + b.Property("Payload") + .HasColumnType("bytea"); + + b.Property("PredecessorLevel") + .HasColumnType("integer"); + + b.Property("Protocol") + .HasColumnType("text"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OperationId"); + + b.HasIndex("Type", "Id"); + + b.ToTable("InboxMessages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("IncreasePaidStorageOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("BalanceChange") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId"); + + b.HasIndex("Level"); + + b.HasIndex("ScriptId"); + + b.HasIndex("StorageId"); + + b.ToTable("MigrationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("bytea") + .IsFixedLength(); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RevealedCycle") + .HasColumnType("integer"); + + b.Property("RevealedLevel") + .HasColumnType("integer"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasAlternateKey("RevealedLevel"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RevealedCycle"); + + b.HasIndex("SenderId"); + + b.ToTable("NonceRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("ContractCodeHash") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ScriptId") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractCodeHash") + .HasFilter("\"ContractCodeHash\" IS NOT NULL"); + + b.HasIndex("ContractId"); + + b.HasIndex("DelegateId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("Level"); + + b.HasIndex("ManagerId"); + + b.HasIndex("OpHash"); + + b.HasIndex("ScriptId"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.ToTable("OriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("Slots") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("DelegateId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("PreendorsementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Proposal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstPeriod") + .HasColumnType("integer"); + + b.Property("Hash") + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastPeriod") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Upvotes") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Hash"); + + b.ToTable("Proposals"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Duplicated") + .HasColumnType("boolean"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("ProposalId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Epoch"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("Period"); + + b.HasIndex("ProposalId"); + + b.HasIndex("SenderId"); + + b.ToTable("ProposalOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Protocol", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotQuorumMax") + .HasColumnType("integer"); + + b.Property("BallotQuorumMin") + .HasColumnType("integer"); + + b.Property("BlockDeposit") + .HasColumnType("bigint"); + + b.Property("BlockReward0") + .HasColumnType("bigint"); + + b.Property("BlockReward1") + .HasColumnType("bigint"); + + b.Property("BlocksPerCommitment") + .HasColumnType("integer"); + + b.Property("BlocksPerCycle") + .HasColumnType("integer"); + + b.Property("BlocksPerSnapshot") + .HasColumnType("integer"); + + b.Property("BlocksPerVoting") + .HasColumnType("integer"); + + b.Property("ByteCost") + .HasColumnType("integer"); + + b.Property("Code") + .HasColumnType("integer"); + + b.Property("ConsensusThreshold") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("text"); + + b.Property("DoubleBakingPunishment") + .HasColumnType("bigint"); + + b.Property("DoubleEndorsingPunishmentDenominator") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingPunishmentNumerator") + .HasColumnType("integer"); + + b.Property("EndorsementDeposit") + .HasColumnType("bigint"); + + b.Property("EndorsementReward0") + .HasColumnType("bigint"); + + b.Property("EndorsementReward1") + .HasColumnType("bigint"); + + b.Property("EndorsersPerBlock") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstCycle") + .HasColumnType("integer"); + + b.Property("FirstCycleLevel") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FrozenDepositsPercentage") + .HasColumnType("integer"); + + b.Property("HardBlockGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationGasLimit") + .HasColumnType("integer"); + + b.Property("HardOperationStorageLimit") + .HasColumnType("integer"); + + b.Property("Hash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("LBSubsidy") + .HasColumnType("integer"); + + b.Property("LBToggleThreshold") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("MaxBakingReward") + .HasColumnType("bigint"); + + b.Property("MaxEndorsingReward") + .HasColumnType("bigint"); + + b.Property("MaxSlashingPeriod") + .HasColumnType("integer"); + + b.Property("MinParticipationDenominator") + .HasColumnType("integer"); + + b.Property("MinParticipationNumerator") + .HasColumnType("integer"); + + b.Property("NoRewardCycles") + .HasColumnType("integer"); + + b.Property("OriginationSize") + .HasColumnType("integer"); + + b.Property("PreservedCycles") + .HasColumnType("integer"); + + b.Property("ProposalQuorum") + .HasColumnType("integer"); + + b.Property("RampUpCycles") + .HasColumnType("integer"); + + b.Property("RevelationReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupChallengeWindow") + .HasColumnType("integer"); + + b.Property("SmartRollupCommitmentPeriod") + .HasColumnType("integer"); + + b.Property("SmartRollupOriginationSize") + .HasColumnType("integer"); + + b.Property("SmartRollupStakeAmount") + .HasColumnType("bigint"); + + b.Property("SmartRollupTimeoutPeriod") + .HasColumnType("integer"); + + b.Property("TimeBetweenBlocks") + .HasColumnType("integer"); + + b.Property("TokensPerRoll") + .HasColumnType("bigint"); + + b.Property("TxRollupCommitmentBond") + .HasColumnType("bigint"); + + b.Property("TxRollupOriginationSize") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Protocols"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Quote", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Btc") + .HasColumnType("double precision"); + + b.Property("Cny") + .HasColumnType("double precision"); + + b.Property("Eth") + .HasColumnType("double precision"); + + b.Property("Eur") + .HasColumnType("double precision"); + + b.Property("Gbp") + .HasColumnType("double precision"); + + b.Property("Jpy") + .HasColumnType("double precision"); + + b.Property("Krw") + .HasColumnType("double precision"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Usd") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Quotes"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RefutationGame", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("InitiatorCommitmentId") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InitiatorLoss") + .HasColumnType("bigint"); + + b.Property("InitiatorReward") + .HasColumnType("bigint"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("LastMoveId") + .HasColumnType("bigint"); + + b.Property("OpponentCommitmentId") + .HasColumnType("integer"); + + b.Property("OpponentId") + .HasColumnType("integer"); + + b.Property("OpponentLoss") + .HasColumnType("bigint"); + + b.Property("OpponentReward") + .HasColumnType("bigint"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstLevel"); + + b.HasIndex("InitiatorCommitmentId"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("LastLevel"); + + b.HasIndex("OpponentCommitmentId"); + + b.HasIndex("OpponentId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("RefutationGames"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .HasMaxLength(54) + .HasColumnType("character varying(54)"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("Refs") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("Value") + .HasColumnType("bytea"); + + b.HasKey("Id"); + + b.HasIndex("Address") + .IsUnique() + .HasFilter("\"Address\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RegisterConstantOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("RevealOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("MissedLevel") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Level"); + + b.ToTable("RevelationPenaltyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Script", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CodeSchema") + .HasColumnType("bytea"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ParameterSchema") + .HasColumnType("bytea"); + + b.Property("StorageSchema") + .HasColumnType("bytea"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("Views") + .HasColumnType("bytea[]"); + + b.HasKey("Id"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Scripts"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Limit") + .HasColumnType("text"); + + b.Property("OpHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SetDepositsLimitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MessagesCount") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupAddMessagesOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("SmartRollupCementOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCommitment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Hash") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("PredecessorId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Stakers") + .HasColumnType("integer"); + + b.Property("State") + .HasColumnType("text"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Successors") + .HasColumnType("integer"); + + b.Property("Ticks") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Hash"); + + b.HasIndex("InboxLevel"); + + b.HasIndex("LastLevel"); + + b.HasIndex("PredecessorId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("Hash", "SmartRollupId"); + + b.ToTable("SmartRollupCommitments"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupExecuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("Kernel") + .HasColumnType("bytea"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("OriginationProof") + .HasColumnType("bytea"); + + b.Property("ParameterType") + .HasColumnType("bytea"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupOriginateOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("BondStatus") + .HasColumnType("integer"); + + b.Property("CommitmentId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("Flags") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitmentId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("SmartRollupId", "BondStatus", "SenderId") + .HasFilter("\"BondStatus\" IS NOT NULL"); + + b.ToTable("SmartRollupPublishOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("StakerId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.HasIndex("StakerId"); + + b.ToTable("SmartRollupRecoverBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("DissectionEnd") + .HasColumnType("bigint"); + + b.Property("DissectionStart") + .HasColumnType("bigint"); + + b.Property("DissectionSteps") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GameId") + .HasColumnType("integer"); + + b.Property("GameStatus") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Move") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("SmartRollupId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("GameId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("SmartRollupId"); + + b.ToTable("SmartRollupRefuteOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SnapshotBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .HasColumnType("bigint"); + + b.Property("DelegateId") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Level") + .HasFilter("\"DelegateId\" IS NULL"); + + b.ToTable("SnapshotBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Software", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("Extras") + .HasColumnType("jsonb"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("ShortHash") + .IsRequired() + .HasMaxLength(8) + .HasColumnType("character(8)") + .IsFixedLength(); + + b.HasKey("Id"); + + b.ToTable("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Statistics", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("TotalActivated") + .HasColumnType("bigint"); + + b.Property("TotalBanished") + .HasColumnType("bigint"); + + b.Property("TotalBootstrapped") + .HasColumnType("bigint"); + + b.Property("TotalBurned") + .HasColumnType("bigint"); + + b.Property("TotalCommitments") + .HasColumnType("bigint"); + + b.Property("TotalCreated") + .HasColumnType("bigint"); + + b.Property("TotalFrozen") + .HasColumnType("bigint"); + + b.Property("TotalRollupBonds") + .HasColumnType("bigint"); + + b.Property("TotalSmartRollupBonds") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Cycle") + .IsUnique() + .HasFilter("\"Cycle\" IS NOT NULL"); + + b.HasIndex("Date") + .IsUnique() + .HasFilter("\"Date\" IS NOT NULL"); + + b.HasIndex("Level") + .IsUnique(); + + b.ToTable("Statistics"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Storage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("Current") + .HasColumnType("boolean"); + + b.Property("JsonValue") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("RawValue") + .HasColumnType("bytea"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("ContractId", "Current") + .HasFilter("\"Current\" = true"); + + b.ToTable("Storages"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentTypeHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("TicketerId"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LastLevel"); + + b.HasIndex("TicketId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("TicketerId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "TicketId") + .IsUnique(); + + b.HasIndex("AccountId", "TicketerId"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("TransferTicketId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.HasIndex("TransferTicketId") + .HasFilter("\"TransferTicketId\" is not null"); + + b.ToTable("TicketTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Token", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("OwnerId") + .HasColumnType("integer"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TokenId") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("ContractId", "TokenId") + .IsUnique(); + + b.ToTable("Tokens"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("ContractId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("LastLevel"); + + b.HasIndex("TokenId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "ContractId"); + + b.HasIndex("AccountId", "TokenId") + .IsUnique(); + + b.ToTable("TokenBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TokenTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("ContractId") + .HasColumnType("integer"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("IndexedAt") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("OriginationId") + .HasColumnType("bigint"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TokenId") + .HasColumnType("bigint"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("ContractId"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("IndexedAt") + .HasFilter("\"IndexedAt\" is not null"); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("OriginationId") + .HasFilter("\"OriginationId\" is not null"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TokenId"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.ToTable("TokenTransfers"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("BigMapUpdates") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("InitiatorId") + .HasColumnType("integer"); + + b.Property("InternalDelegations") + .HasColumnType("smallint"); + + b.Property("InternalOperations") + .HasColumnType("smallint"); + + b.Property("InternalOriginations") + .HasColumnType("smallint"); + + b.Property("InternalTransactions") + .HasColumnType("smallint"); + + b.Property("JsonParameters") + .HasColumnType("jsonb"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Nonce") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawParameters") + .HasColumnType("bytea"); + + b.Property("ResetDeactivation") + .HasColumnType("integer"); + + b.Property("SenderCodeHash") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageId") + .HasColumnType("integer"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetCodeHash") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.Property("TokenTransfers") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InitiatorId"); + + b.HasIndex("JsonParameters"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonParameters"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonParameters"), new[] { "jsonb_path_ops" }); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderCodeHash") + .HasFilter("\"SenderCodeHash\" IS NOT NULL"); + + b.HasIndex("SenderId"); + + b.HasIndex("StorageId"); + + b.HasIndex("TargetCodeHash") + .HasFilter("\"TargetCodeHash\" IS NOT NULL"); + + b.HasIndex("TargetId"); + + b.ToTable("TransactionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Entrypoint") + .HasColumnType("text"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("SubIds") + .HasColumnType("integer"); + + b.Property("TargetId") + .HasColumnType("integer"); + + b.Property("TicketTransfers") + .HasColumnType("integer"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.HasIndex("TargetId"); + + b.HasIndex("TicketerId"); + + b.ToTable("TransferTicketOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupCommitOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupDispatchTicketsOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupFinalizeCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupOriginationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("CommitterId") + .HasColumnType("integer"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Loss") + .HasColumnType("bigint"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CommitterId"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRejectionOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupRemoveCommitmentOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Bond") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupReturnBondOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("RollupId") + .HasColumnType("integer"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("RollupId"); + + b.HasIndex("SenderId"); + + b.ToTable("TxRollupSubmitBatchOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ActivationCycle") + .HasColumnType("integer"); + + b.Property("AllocationFee") + .HasColumnType("bigint"); + + b.Property("BakerFee") + .HasColumnType("bigint"); + + b.Property("Counter") + .HasColumnType("integer"); + + b.Property("Errors") + .HasColumnType("text"); + + b.Property("GasLimit") + .HasColumnType("integer"); + + b.Property("GasUsed") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("PublicKeyHash") + .HasColumnType("text"); + + b.Property("SenderId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("smallint"); + + b.Property("StorageFee") + .HasColumnType("bigint"); + + b.Property("StorageLimit") + .HasColumnType("integer"); + + b.Property("StorageUsed") + .HasColumnType("integer"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.HasIndex("SenderId"); + + b.ToTable("UpdateConsensusKeyOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Cycle") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("OpHash") + .IsRequired() + .HasMaxLength(51) + .HasColumnType("character(51)") + .IsFixedLength(); + + b.Property("Proof") + .HasColumnType("bytea"); + + b.Property("Reward") + .HasColumnType("bigint"); + + b.Property("Solution") + .HasColumnType("bytea"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("BakerId"); + + b.HasIndex("Cycle"); + + b.HasIndex("Level"); + + b.HasIndex("OpHash"); + + b.ToTable("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingPeriod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BallotsQuorum") + .HasColumnType("integer"); + + b.Property("Dictator") + .HasColumnType("integer"); + + b.Property("Epoch") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("Index") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("NayBallots") + .HasColumnType("integer"); + + b.Property("NayVotingPower") + .HasColumnType("bigint"); + + b.Property("ParticipationEma") + .HasColumnType("integer"); + + b.Property("PassBallots") + .HasColumnType("integer"); + + b.Property("PassVotingPower") + .HasColumnType("bigint"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("SingleWinner") + .HasColumnType("boolean"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Supermajority") + .HasColumnType("integer"); + + b.Property("TopUpvotes") + .HasColumnType("integer"); + + b.Property("TopVotingPower") + .HasColumnType("bigint"); + + b.Property("TotalBakers") + .HasColumnType("integer"); + + b.Property("TotalVotingPower") + .HasColumnType("bigint"); + + b.Property("UpvotesQuorum") + .HasColumnType("integer"); + + b.Property("YayBallots") + .HasColumnType("integer"); + + b.Property("YayVotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasAlternateKey("Index"); + + b.HasIndex("Epoch"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Index") + .IsUnique(); + + b.ToTable("VotingPeriods"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VotingSnapshot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BakerId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("Period") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("VotingPower") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("Period"); + + b.HasIndex("Period", "BakerId") + .IsUnique(); + + b.ToTable("VotingSnapshots"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CodeHash") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("EventsCount") + .HasColumnType("integer"); + + b.Property("Kind") + .HasColumnType("smallint"); + + b.Property("ManagerId") + .HasColumnType("integer"); + + b.Property("Spendable") + .HasColumnType("boolean"); + + b.Property("Tags") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + + b.Property("TokensCount") + .HasColumnType("integer"); + + b.Property("TypeHash") + .HasColumnType("integer"); + + b.Property("WeirdDelegateId") + .HasColumnType("integer"); + + b.HasIndex("CodeHash"); + + b.HasIndex("CreatorId"); + + b.HasIndex("ManagerId"); + + b.HasIndex("TypeHash"); + + b.HasIndex("WeirdDelegateId"); + + b.HasIndex("Type", "Kind") + .HasFilter("\"Type\" = 2"); + + b.HasDiscriminator().HasValue((byte)2); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Rollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)4); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollup", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("ActiveStakers") + .HasColumnType("integer"); + + b.Property("CementedCommitments") + .HasColumnType("integer"); + + b.Property("CreatorId") + .ValueGeneratedOnUpdateSometimes() + .HasColumnType("integer") + .HasColumnName("CreatorId"); + + b.Property("ExecutedCommitments") + .HasColumnType("integer"); + + b.Property("GenesisCommitment") + .HasColumnType("text"); + + b.Property("InboxLevel") + .HasColumnType("integer"); + + b.Property("LastCommitment") + .HasColumnType("text"); + + b.Property("OrphanCommitments") + .HasColumnType("integer"); + + b.Property("PendingCommitments") + .HasColumnType("integer"); + + b.Property("PvmKind") + .HasColumnType("integer"); + + b.Property("RefutedCommitments") + .HasColumnType("integer"); + + b.Property("TotalStakers") + .HasColumnType("integer"); + + b.HasIndex("CreatorId"); + + b.HasDiscriminator().HasValue((byte)5); + }); + + modelBuilder.Entity("Tzkt.Data.Models.User", b => + { + b.HasBaseType("Tzkt.Data.Models.Account"); + + b.Property("Activated") + .HasColumnType("boolean"); + + b.Property("PublicKey") + .HasColumnType("text"); + + b.Property("RegisterConstantsCount") + .HasColumnType("integer"); + + b.Property("Revealed") + .HasColumnType("boolean"); + + b.Property("SetDepositsLimitsCount") + .HasColumnType("integer"); + + b.HasDiscriminator().HasValue((byte)0); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasBaseType("Tzkt.Data.Models.User"); + + b.Property("ActivationLevel") + .HasColumnType("integer"); + + b.Property("BallotsCount") + .HasColumnType("integer"); + + b.Property("BlocksCount") + .HasColumnType("integer"); + + b.Property("DeactivationLevel") + .HasColumnType("integer"); + + b.Property("DelegatedBalance") + .HasColumnType("bigint"); + + b.Property("DelegatorsCount") + .HasColumnType("integer"); + + b.Property("DoubleBakingCount") + .HasColumnType("integer"); + + b.Property("DoubleEndorsingCount") + .HasColumnType("integer"); + + b.Property("DoublePreendorsingCount") + .HasColumnType("integer"); + + b.Property("EndorsementsCount") + .HasColumnType("integer"); + + b.Property("EndorsingRewardsCount") + .HasColumnType("integer"); + + b.Property("FrozenDeposit") + .HasColumnType("bigint"); + + b.Property("FrozenDepositLimit") + .HasColumnType("bigint"); + + b.Property("NonceRevelationsCount") + .HasColumnType("integer"); + + b.Property("PreendorsementsCount") + .HasColumnType("integer"); + + b.Property("ProposalsCount") + .HasColumnType("integer"); + + b.Property("RevelationPenaltiesCount") + .HasColumnType("integer"); + + b.Property("SoftwareId") + .HasColumnType("integer"); + + b.Property("StakingBalance") + .HasColumnType("bigint"); + + b.Property("VdfRevelationsCount") + .HasColumnType("integer"); + + b.HasIndex("SoftwareId"); + + b.HasIndex("Type", "Staked") + .HasFilter("\"Type\" = 1"); + + b.HasDiscriminator().HasValue((byte)1); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Account", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany("DelegatedAccounts") + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Block", "FirstBlock") + .WithMany("CreatedAccounts") + .HasForeignKey("FirstLevel") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Delegate"); + + b.Navigation("FirstBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ActivationOperation", b => + { + b.HasOne("Tzkt.Data.Models.User", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Activations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.BallotOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Ballots") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Proposer") + .WithMany() + .HasForeignKey("ProposerId"); + + b.HasOne("Tzkt.Data.Models.Protocol", "Protocol") + .WithMany() + .HasForeignKey("ProtoCode") + .HasPrincipalKey("Code") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.NonceRevelationOperation", "Revelation") + .WithOne("RevealedBlock") + .HasForeignKey("Tzkt.Data.Models.Block", "RevelationId"); + + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Proposer"); + + b.Navigation("Protocol"); + + b.Navigation("Revelation"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DelegationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Delegations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "PrevDelegate") + .WithMany() + .HasForeignKey("PrevDelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("PrevDelegate"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleBakingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleBakings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoubleEndorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoubleEndorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DoublePreendorsingOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Accuser") + .WithMany() + .HasForeignKey("AccuserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DoublePreendorsings") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Offender") + .WithMany() + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Accuser"); + + b.Navigation("Block"); + + b.Navigation("Offender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.DrainDelegateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("DrainDelegateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.EndorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Endorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.IncreasePaidStorageOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("IncreasePaidStorageOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.MigrationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Migrations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Account"); + + b.Navigation("Block"); + + b.Navigation("Script"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Revelations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.OriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Contract", "Contract") + .WithMany() + .HasForeignKey("ContractId"); + + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId"); + + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Originations") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.Script", "Script") + .WithMany() + .HasForeignKey("ScriptId"); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.Navigation("Block"); + + b.Navigation("Contract"); + + b.Navigation("Delegate"); + + b.Navigation("Initiator"); + + b.Navigation("Manager"); + + b.Navigation("Script"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.PreendorsementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Delegate") + .WithMany() + .HasForeignKey("DelegateId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Preendorsements") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Delegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.ProposalOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Proposals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Proposal", "Proposal") + .WithMany() + .HasForeignKey("ProposalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Delegate", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Proposal"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RegisterConstantOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RegisterConstants") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevealOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Reveals") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.RevelationPenaltyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("RevelationPenalties") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SetDepositsLimitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SetDepositsLimits") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupAddMessagesOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupAddMessagesOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupCementOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupCementOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupExecuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupExecuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupOriginateOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupOriginateOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupPublishOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupPublishOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRecoverBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRecoverBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.SmartRollupRefuteOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("SmartRollupRefuteOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransactionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Initiator") + .WithMany() + .HasForeignKey("InitiatorId"); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("Transactions") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Storage", "Storage") + .WithMany() + .HasForeignKey("StorageId"); + + b.HasOne("Tzkt.Data.Models.Account", "Target") + .WithMany() + .HasForeignKey("TargetId"); + + b.Navigation("Block"); + + b.Navigation("Initiator"); + + b.Navigation("Sender"); + + b.Navigation("Storage"); + + b.Navigation("Target"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TransferTicketOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TransferTicketOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupCommitOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupCommitOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupDispatchTicketsOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupDispatchTicketsOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupFinalizeCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupFinalizeCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupOriginationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupOriginationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRejectionOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRejectionOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupRemoveCommitmentOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupRemoveCommitmentOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupReturnBondOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupReturnBondOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TxRollupSubmitBatchOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("TxRollupSubmitBatchOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.UpdateConsensusKeyOperation", b => + { + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("UpdateConsensusKeyOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Account", "Sender") + .WithMany() + .HasForeignKey("SenderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Block"); + + b.Navigation("Sender"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.VdfRevelationOperation", b => + { + b.HasOne("Tzkt.Data.Models.Delegate", "Baker") + .WithMany() + .HasForeignKey("BakerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tzkt.Data.Models.Block", "Block") + .WithMany("VdfRevelationOps") + .HasForeignKey("Level") + .HasPrincipalKey("Level") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Baker"); + + b.Navigation("Block"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Contract", b => + { + b.HasOne("Tzkt.Data.Models.Account", "Creator") + .WithMany() + .HasForeignKey("CreatorId"); + + b.HasOne("Tzkt.Data.Models.User", "Manager") + .WithMany() + .HasForeignKey("ManagerId"); + + b.HasOne("Tzkt.Data.Models.User", "WeirdDelegate") + .WithMany() + .HasForeignKey("WeirdDelegateId"); + + b.Navigation("Creator"); + + b.Navigation("Manager"); + + b.Navigation("WeirdDelegate"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.HasOne("Tzkt.Data.Models.Software", "Software") + .WithMany() + .HasForeignKey("SoftwareId"); + + b.Navigation("Software"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Block", b => + { + b.Navigation("Activations"); + + b.Navigation("Ballots"); + + b.Navigation("CreatedAccounts"); + + b.Navigation("Delegations"); + + b.Navigation("DoubleBakings"); + + b.Navigation("DoubleEndorsings"); + + b.Navigation("DoublePreendorsings"); + + b.Navigation("DrainDelegateOps"); + + b.Navigation("Endorsements"); + + b.Navigation("IncreasePaidStorageOps"); + + b.Navigation("Migrations"); + + b.Navigation("Originations"); + + b.Navigation("Preendorsements"); + + b.Navigation("Proposals"); + + b.Navigation("RegisterConstants"); + + b.Navigation("Reveals"); + + b.Navigation("RevelationPenalties"); + + b.Navigation("Revelations"); + + b.Navigation("SetDepositsLimits"); + + b.Navigation("SmartRollupAddMessagesOps"); + + b.Navigation("SmartRollupCementOps"); + + b.Navigation("SmartRollupExecuteOps"); + + b.Navigation("SmartRollupOriginateOps"); + + b.Navigation("SmartRollupPublishOps"); + + b.Navigation("SmartRollupRecoverBondOps"); + + b.Navigation("SmartRollupRefuteOps"); + + b.Navigation("Transactions"); + + b.Navigation("TransferTicketOps"); + + b.Navigation("TxRollupCommitOps"); + + b.Navigation("TxRollupDispatchTicketsOps"); + + b.Navigation("TxRollupFinalizeCommitmentOps"); + + b.Navigation("TxRollupOriginationOps"); + + b.Navigation("TxRollupRejectionOps"); + + b.Navigation("TxRollupRemoveCommitmentOps"); + + b.Navigation("TxRollupReturnBondOps"); + + b.Navigation("TxRollupSubmitBatchOps"); + + b.Navigation("UpdateConsensusKeyOps"); + + b.Navigation("VdfRevelationOps"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.NonceRevelationOperation", b => + { + b.Navigation("RevealedBlock"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.Delegate", b => + { + b.Navigation("DelegatedAccounts"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Tzkt.Data/Migrations/20230812082232_Tickets.cs b/Tzkt.Data/Migrations/20230812082232_Tickets.cs new file mode 100644 index 000000000..8d74cc7f4 --- /dev/null +++ b/Tzkt.Data/Migrations/20230812082232_Tickets.cs @@ -0,0 +1,338 @@ +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace Tzkt.Data.Migrations +{ + /// + public partial class Tickets : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "SubIds", + table: "TransferTicketOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "TransferTicketOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "TransactionOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketTransfers", + table: "MigrationOps", + type: "integer", + nullable: true); + + migrationBuilder.AddColumn( + name: "TicketBalancesCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketTransfersCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketsCount", + table: "AppState", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ActiveTicketsCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketBalancesCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketTransfersCount", + table: "Accounts", + type: "integer", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TicketsCount", + table: "Accounts", + type: "integer", + nullable: true); + + migrationBuilder.CreateTable( + name: "TicketBalances", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TicketerId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "bigint", nullable: false), + AccountId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + Balance = table.Column(type: "text", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketBalances", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Tickets", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + TicketerId = table.Column(type: "integer", nullable: false), + FirstMinterId = table.Column(type: "integer", nullable: false), + FirstLevel = table.Column(type: "integer", nullable: false), + LastLevel = table.Column(type: "integer", nullable: false), + TransfersCount = table.Column(type: "integer", nullable: false), + BalancesCount = table.Column(type: "integer", nullable: false), + HoldersCount = table.Column(type: "integer", nullable: false), + TotalMinted = table.Column(type: "text", nullable: false), + TotalBurned = table.Column(type: "text", nullable: false), + TotalSupply = table.Column(type: "text", nullable: false), + ContentHash = table.Column(type: "integer", nullable: false), + ContentTypeHash = table.Column(type: "integer", nullable: false), + RawContent = table.Column(type: "bytea", nullable: true), + RawType = table.Column(type: "bytea", nullable: true), + JsonContent = table.Column(type: "text", nullable: true), + Metadata = table.Column(type: "jsonb", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Tickets", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "TicketTransfers", + columns: table => new + { + Id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + Level = table.Column(type: "integer", nullable: false), + TicketerId = table.Column(type: "integer", nullable: false), + TicketId = table.Column(type: "bigint", nullable: false), + Amount = table.Column(type: "text", nullable: false), + FromId = table.Column(type: "integer", nullable: true), + ToId = table.Column(type: "integer", nullable: true), + TransferTicketId = table.Column(type: "bigint", nullable: true), + TransactionId = table.Column(type: "bigint", nullable: true), + MigrationId = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_TicketTransfers", x => x.Id); + }); + + migrationBuilder.UpdateData( + table: "AppState", + keyColumn: "Id", + keyValue: -1, + columns: new[] { "TicketBalancesCount", "TicketTransfersCount", "TicketsCount" }, + values: new object[] { 0, 0, 0 }); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId", + table: "TicketBalances", + column: "AccountId", + filter: "\"Balance\" != '0'"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId_TicketerId", + table: "TicketBalances", + columns: new[] { "AccountId", "TicketerId" }); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_AccountId_TicketId", + table: "TicketBalances", + columns: new[] { "AccountId", "TicketId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_Id", + table: "TicketBalances", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_LastLevel", + table: "TicketBalances", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_TicketerId", + table: "TicketBalances", + column: "TicketerId", + filter: "\"Balance\" != '0'"); + + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_TicketId", + table: "TicketBalances", + column: "TicketId", + filter: "\"Balance\" != '0'"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_FirstMinterId", + table: "Tickets", + column: "FirstMinterId"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_Id", + table: "Tickets", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_LastLevel", + table: "Tickets", + column: "LastLevel"); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_Metadata", + table: "Tickets", + column: "Metadata") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); + + migrationBuilder.CreateIndex( + name: "IX_Tickets_TicketerId", + table: "Tickets", + column: "TicketerId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_FromId", + table: "TicketTransfers", + column: "FromId", + filter: "\"FromId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_Id", + table: "TicketTransfers", + column: "Id", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_Level", + table: "TicketTransfers", + column: "Level"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_MigrationId", + table: "TicketTransfers", + column: "MigrationId", + filter: "\"MigrationId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TicketerId", + table: "TicketTransfers", + column: "TicketerId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TicketId", + table: "TicketTransfers", + column: "TicketId"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_ToId", + table: "TicketTransfers", + column: "ToId", + filter: "\"ToId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TransactionId", + table: "TicketTransfers", + column: "TransactionId", + filter: "\"TransactionId\" is not null"); + + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_TransferTicketId", + table: "TicketTransfers", + column: "TransferTicketId", + filter: "\"TransferTicketId\" is not null"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "TicketBalances"); + + migrationBuilder.DropTable( + name: "Tickets"); + + migrationBuilder.DropTable( + name: "TicketTransfers"); + + migrationBuilder.DropColumn( + name: "SubIds", + table: "TransferTicketOps"); + + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "TransferTicketOps"); + + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "TransactionOps"); + + migrationBuilder.DropColumn( + name: "TicketTransfers", + table: "MigrationOps"); + + migrationBuilder.DropColumn( + name: "TicketBalancesCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "TicketTransfersCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "TicketsCount", + table: "AppState"); + + migrationBuilder.DropColumn( + name: "ActiveTicketsCount", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketBalancesCount", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketTransfersCount", + table: "Accounts"); + + migrationBuilder.DropColumn( + name: "TicketsCount", + table: "Accounts"); + } + } +} diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index b849d89d1..5b000a642 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -18,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "7.0.4") + .HasAnnotation("ProductVersion", "7.0.5") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -34,6 +34,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ActiveRefutationGamesCount") .HasColumnType("integer"); + b.Property("ActiveTicketsCount") + .HasColumnType("integer"); + b.Property("ActiveTokensCount") .HasColumnType("integer"); @@ -126,6 +129,12 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Staked") .HasColumnType("boolean"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + b.Property("TokenBalancesCount") .HasColumnType("integer"); @@ -448,6 +457,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageCounter") .HasColumnType("integer"); + b.Property("TicketBalancesCount") + .HasColumnType("integer"); + + b.Property("TicketTransfersCount") + .HasColumnType("integer"); + + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -573,6 +591,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) SmartRollupRecoverBondOpsCount = 0, SmartRollupRefuteOpsCount = 0, StorageCounter = 0, + TicketBalancesCount = 0, + TicketTransfersCount = 0, + TicketsCount = 0, Timestamp = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc), TokenBalancesCount = 0, TokenTransfersCount = 0, @@ -1854,6 +1875,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SubIds") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3550,6 +3574,203 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Storages"); }); + modelBuilder.Entity("Tzkt.Data.Models.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BalancesCount") + .HasColumnType("integer"); + + b.Property("ContentHash") + .HasColumnType("integer"); + + b.Property("ContentTypeHash") + .HasColumnType("integer"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("FirstMinterId") + .HasColumnType("integer"); + + b.Property("HoldersCount") + .HasColumnType("integer"); + + b.Property("JsonContent") + .HasColumnType("text"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("Metadata") + .HasColumnType("jsonb"); + + b.Property("RawContent") + .HasColumnType("bytea"); + + b.Property("RawType") + .HasColumnType("bytea"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TotalBurned") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalMinted") + .IsRequired() + .HasColumnType("text"); + + b.Property("TotalSupply") + .IsRequired() + .HasColumnType("text"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("FirstMinterId"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LastLevel"); + + b.HasIndex("Metadata"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); + + b.HasIndex("TicketerId"); + + b.ToTable("Tickets"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketBalance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccountId") + .HasColumnType("integer"); + + b.Property("Balance") + .IsRequired() + .HasColumnType("text"); + + b.Property("FirstLevel") + .HasColumnType("integer"); + + b.Property("LastLevel") + .HasColumnType("integer"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("TransfersCount") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AccountId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("LastLevel"); + + b.HasIndex("TicketId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("TicketerId") + .HasFilter("\"Balance\" != '0'"); + + b.HasIndex("AccountId", "TicketId") + .IsUnique(); + + b.HasIndex("AccountId", "TicketerId"); + + b.ToTable("TicketBalances"); + }); + + modelBuilder.Entity("Tzkt.Data.Models.TicketTransfer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Amount") + .IsRequired() + .HasColumnType("text"); + + b.Property("FromId") + .HasColumnType("integer"); + + b.Property("Level") + .HasColumnType("integer"); + + b.Property("MigrationId") + .HasColumnType("bigint"); + + b.Property("TicketId") + .HasColumnType("bigint"); + + b.Property("TicketerId") + .HasColumnType("integer"); + + b.Property("ToId") + .HasColumnType("integer"); + + b.Property("TransactionId") + .HasColumnType("bigint"); + + b.Property("TransferTicketId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("FromId") + .HasFilter("\"FromId\" is not null"); + + b.HasIndex("Id") + .IsUnique(); + + b.HasIndex("Level"); + + b.HasIndex("MigrationId") + .HasFilter("\"MigrationId\" is not null"); + + b.HasIndex("TicketId"); + + b.HasIndex("TicketerId"); + + b.HasIndex("ToId") + .HasFilter("\"ToId\" is not null"); + + b.HasIndex("TransactionId") + .HasFilter("\"TransactionId\" is not null"); + + b.HasIndex("TransferTicketId") + .HasFilter("\"TransferTicketId\" is not null"); + + b.ToTable("TicketTransfers"); + }); + modelBuilder.Entity("Tzkt.Data.Models.Token", b => { b.Property("Id") @@ -3867,6 +4088,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3967,9 +4191,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + b.Property("TargetId") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("TicketerId") .HasColumnType("integer"); @@ -4833,6 +5063,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Tags") .HasColumnType("integer"); + b.Property("TicketsCount") + .HasColumnType("integer"); + b.Property("TokensCount") .HasColumnType("integer"); diff --git a/Tzkt.Data/Models/Operations/Base/ContractOperation.cs b/Tzkt.Data/Models/Operations/Base/ContractOperation.cs index 70cfcb8a5..5736507d0 100644 --- a/Tzkt.Data/Models/Operations/Base/ContractOperation.cs +++ b/Tzkt.Data/Models/Operations/Base/ContractOperation.cs @@ -5,7 +5,7 @@ public class ContractOperation : InternalOperation public int? StorageId { get; set; } public int? BigMapUpdates { get; set; } public int? TokenTransfers { get; set; } - + public int? SubIds { get; set; } } } From 04e507588aca7a4a89fa48259cda6c260490d7d3 Mon Sep 17 00:00:00 2001 From: dmir Date: Mon, 14 Aug 2023 20:10:13 +0300 Subject: [PATCH 26/51] Fix Ids --- ....cs => 20230814170139_Tickets.Designer.cs} | 8 +++- ...2_Tickets.cs => 20230814170139_Tickets.cs} | 11 +++++ .../Migrations/TzktContextModelSnapshot.cs | 6 +++ .../Operations/SmartRollupExecuteOperation.cs | 1 + Tzkt.Data/Models/Scripts/TicketTransfer.cs | 6 +++ .../Handlers/Proto16/Commits/TicketsCommit.cs | 46 +++++++++---------- .../Handlers/Proto16/Proto16Handler.cs | 12 ++--- .../Handlers/Proto17/Proto17Handler.cs | 12 ++--- Tzkt.Sync/Services/Cache/AppStateCache.cs | 7 +++ docker-compose.ghost.yml | 2 +- docker-compose.mumbai.yml | 4 +- docker-compose.nairobi.yml | 6 +-- 12 files changed, 79 insertions(+), 42 deletions(-) rename Tzkt.Data/Migrations/{20230812082232_Tickets.Designer.cs => 20230814170139_Tickets.Designer.cs} (99%) rename Tzkt.Data/Migrations/{20230812082232_Tickets.cs => 20230814170139_Tickets.cs} (96%) diff --git a/Tzkt.Data/Migrations/20230812082232_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230814170139_Tickets.Designer.cs similarity index 99% rename from Tzkt.Data/Migrations/20230812082232_Tickets.Designer.cs rename to Tzkt.Data/Migrations/20230814170139_Tickets.Designer.cs index 1295ff66e..74b49e257 100644 --- a/Tzkt.Data/Migrations/20230812082232_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230814170139_Tickets.Designer.cs @@ -13,7 +13,7 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230812082232_Tickets")] + [Migration("20230814170139_Tickets")] partial class Tickets { /// @@ -3048,6 +3048,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3730,6 +3733,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("MigrationId") .HasColumnType("bigint"); + b.Property("SmartRollupExecuteId") + .HasColumnType("bigint"); + b.Property("TicketId") .HasColumnType("bigint"); diff --git a/Tzkt.Data/Migrations/20230812082232_Tickets.cs b/Tzkt.Data/Migrations/20230814170139_Tickets.cs similarity index 96% rename from Tzkt.Data/Migrations/20230812082232_Tickets.cs rename to Tzkt.Data/Migrations/20230814170139_Tickets.cs index 8d74cc7f4..c29a77a72 100644 --- a/Tzkt.Data/Migrations/20230812082232_Tickets.cs +++ b/Tzkt.Data/Migrations/20230814170139_Tickets.cs @@ -29,6 +29,12 @@ protected override void Up(MigrationBuilder migrationBuilder) type: "integer", nullable: true); + migrationBuilder.AddColumn( + name: "SubIds", + table: "SmartRollupExecuteOps", + type: "integer", + nullable: true); + migrationBuilder.AddColumn( name: "TicketTransfers", table: "MigrationOps", @@ -144,6 +150,7 @@ protected override void Up(MigrationBuilder migrationBuilder) ToId = table.Column(type: "integer", nullable: true), TransferTicketId = table.Column(type: "bigint", nullable: true), TransactionId = table.Column(type: "bigint", nullable: true), + SmartRollupExecuteId = table.Column(type: "bigint", nullable: true), MigrationId = table.Column(type: "bigint", nullable: true) }, constraints: table => @@ -302,6 +309,10 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "TicketTransfers", table: "TransactionOps"); + migrationBuilder.DropColumn( + name: "SubIds", + table: "SmartRollupExecuteOps"); + migrationBuilder.DropColumn( name: "TicketTransfers", table: "MigrationOps"); diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 5b000a642..d0c223fe4 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3045,6 +3045,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("StorageUsed") .HasColumnType("integer"); + b.Property("SubIds") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3727,6 +3730,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("MigrationId") .HasColumnType("bigint"); + b.Property("SmartRollupExecuteId") + .HasColumnType("bigint"); + b.Property("TicketId") .HasColumnType("bigint"); diff --git a/Tzkt.Data/Models/Operations/SmartRollupExecuteOperation.cs b/Tzkt.Data/Models/Operations/SmartRollupExecuteOperation.cs index 14bc2c5af..ae0389f03 100644 --- a/Tzkt.Data/Models/Operations/SmartRollupExecuteOperation.cs +++ b/Tzkt.Data/Models/Operations/SmartRollupExecuteOperation.cs @@ -7,6 +7,7 @@ public class SmartRollupExecuteOperation : ManagerOperation { public int? SmartRollupId { get; set; } public int? CommitmentId { get; set; } + public int? SubIds { get; set; } } public static class SmartRollupExecuteOperationModel diff --git a/Tzkt.Data/Models/Scripts/TicketTransfer.cs b/Tzkt.Data/Models/Scripts/TicketTransfer.cs index 9ecb8a03d..a4c34ce19 100644 --- a/Tzkt.Data/Models/Scripts/TicketTransfer.cs +++ b/Tzkt.Data/Models/Scripts/TicketTransfer.cs @@ -17,6 +17,8 @@ public class TicketTransfer public long? TransferTicketId { get; set; } public long? TransactionId { get; set; } + public long? SmartRollupExecuteId { get; set; } + public long? MigrationId { get; set; } } @@ -54,6 +56,10 @@ public static void BuildTicketTransferModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.Level); + modelBuilder.Entity() + .HasIndex(x => x.SmartRollupExecuteId) + .HasFilter($@"""{nameof(TicketTransfer.SmartRollupExecuteId)}"" is not null"); + modelBuilder.Entity() .HasIndex(x => x.TransferTicketId) .HasFilter($@"""{nameof(TicketTransfer.TransferTicketId)}"" is not null"); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index 8807cc623..75f3d9485 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -1,6 +1,5 @@ using System.Numerics; using Microsoft.EntityFrameworkCore; -using Netezos.Encoding; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -10,15 +9,15 @@ class TicketsCommit : ProtocolCommit { public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } - readonly Dictionary> Updates = new(); + readonly Dictionary> Updates = new(); - public virtual void Append(long parentId, ManagerOperation op, IEnumerable updates) + public virtual void Append(ManagerOperation op, IEnumerable updates) { - if (!Updates.TryGetValue(parentId, out var list)) + if (!Updates.TryGetValue(op, out var list)) { - Updates.Add(parentId, list = new List<(ManagerOperation op, TicketUpdate update)>()); + Updates.Add(op, list = new()); } - list.AddRange(updates.Select(update => (op, update)).ToList()); + list.AddRange(updates); } public virtual async Task Apply() @@ -31,7 +30,7 @@ public virtual async Task Apply() var ticketsSet = new HashSet<(int, int, int)>(); var balancesSet = new HashSet<(int, long)>(); - var list = Updates.SelectMany(x => x.Value).Select(x => x.update).ToList(); + var list = Updates.SelectMany(x => x.Value).ToList(); foreach (var update in list) { @@ -70,34 +69,27 @@ public virtual async Task Apply() #endregion - foreach (var (_, opUpdates) in Updates) + foreach (var (op, opUpdates) in Updates) { - var a = new Dictionary updates)>(); + var updatesDict = new Dictionary>(); - foreach (var (op, upd) in opUpdates) + foreach (var upd in opUpdates) { var ticketer = GetOrCreateAccount(op, upd.TicketToken.Ticketer) as Contract; var ticket = GetOrCreateTicket(op, ticketer, upd.TicketToken); - if (!a.TryGetValue(ticket, out var upds)) + if (!updatesDict.TryGetValue(ticket, out var upds)) { - a.Add(ticket, upds = new() - { - updates = new List(), - operation = op - }); + updatesDict.Add(ticket, upds = new()); } - upds.updates.AddRange(upd.Updates); - //TODO That's wrong, isn't it? Parent operation everywhere? - upds.operation = op; + upds.AddRange(upd.Updates); } - foreach (var (ticket, (op, updates)) in a) + foreach (var (ticket, updates) in updatesDict) { Db.TryAttach(op.Block); op.Block.Events |= BlockEvents.Tickets; - //TODO Will we add transfers to itself? if (updates.Count == 1 || updates.BigSum(x => x.Amount) != BigInteger.Zero) { foreach (var ticketUpdate in updates) @@ -112,6 +104,7 @@ public virtual async Task Apply() var from = updates.First(x => x.Amount < BigInteger.Zero); foreach (var ticketUpdate in updates) { + //TODO Will we add transfers to oneself? For instance https://rpc.tzkt.io/sc39/chains/main/blocks/77 if (from.Account == ticketUpdate.Account) continue; TransferTickets(op, ticket, from.Account, ticketUpdate.Account, ticketUpdate.Amount); } @@ -182,6 +175,7 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic { ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, TicketerId = contract.Id, @@ -189,6 +183,7 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic { ContractOperation contractOperation => contractOperation.InitiatorId ?? contractOperation.SenderId, TransferTicketOperation transfer => transfer.SenderId, + SmartRollupExecuteOperation sr => sr.SenderId, _ => throw new ArgumentOutOfRangeException(nameof(op)) }, FirstLevel = op.Level, @@ -225,6 +220,7 @@ TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Accou { ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, AccountId = account.Id, @@ -314,6 +310,7 @@ void TransferTickets(ManagerOperation op, Ticket ticket, { ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, Amount = amount, @@ -323,7 +320,8 @@ void TransferTickets(ManagerOperation op, Ticket ticket, TicketId = ticket.Id, TicketerId = ticket.TicketerId, TransactionId = (op as TransactionOperation)?.Id, - TransferTicketId = (op as OriginationOperation)?.Id + TransferTicketId = (op as TransferTicketOperation)?.Id, + SmartRollupExecuteId = (op as SmartRollupExecuteOperation)?.Id }); } @@ -377,6 +375,7 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, { ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), + SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, Amount = amount > BigInteger.Zero ? amount : -amount, @@ -386,7 +385,8 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, TicketId = ticket.Id, TicketerId = ticket.TicketerId, TransactionId = (op as TransactionOperation)?.Id, - TransferTicketId = (op as TransferTicketOperation)?.Id + TransferTicketId = (op as TransferTicketOperation)?.Id, + SmartRollupExecuteId = (op as SmartRollupExecuteOperation)?.Id }); } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs index f542fcfd9..6c36b5221 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs @@ -171,7 +171,7 @@ public override async Task Commit(JsonElement block) if (parent.BigMapDiffs != null) bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); if (parent.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction.Id, parent.Transaction, parent.TicketUpdates); + ticketsCommit.Append(parent.Transaction, parent.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) { @@ -194,7 +194,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction.Id, internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -233,7 +233,7 @@ public override async Task Commit(JsonElement block) var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); if (parent1.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation.Id, parent1.Operation, parent1.TicketUpdates); + ticketsCommit.Append(parent1.Operation, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) @@ -246,7 +246,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation.Id, internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent1.Operation, internalTx.TicketUpdates); break; default: throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); @@ -264,7 +264,7 @@ public override async Task Commit(JsonElement block) var parent2 = new SmartRollupExecuteCommit(this); await parent2.Apply(blockCommit.Block, operation, content); if (parent2.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation.Id, parent2.Operation, parent2.TicketUpdates); + ticketsCommit.Append(parent2.Operation, parent2.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult2)) { foreach (var internalContent in internalResult2.EnumerateArray()) @@ -286,7 +286,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation.Id, internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent2.Operation, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index 2459b3695..bf884ca4c 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -171,7 +171,7 @@ public override async Task Commit(JsonElement block) if (parent.BigMapDiffs != null) bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); if (parent.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction.Id, parent.Transaction, parent.TicketUpdates); + ticketsCommit.Append(parent.Transaction, parent.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) { @@ -194,7 +194,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction.Id, internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -233,7 +233,7 @@ public override async Task Commit(JsonElement block) var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); if (parent1.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation.Id, parent1.Operation, parent1.TicketUpdates); + ticketsCommit.Append(parent1.Operation, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) @@ -246,7 +246,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation.Id, internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent1.Operation, internalTx.TicketUpdates); break; default: throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); @@ -264,7 +264,7 @@ public override async Task Commit(JsonElement block) var parent2 = new SmartRollupExecuteCommit(this); await parent2.Apply(blockCommit.Block, operation, content); if (parent2.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation.Id, parent2.Operation, parent2.TicketUpdates); + ticketsCommit.Append(parent2.Operation, parent2.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult2)) { foreach (var internalContent in internalResult2.EnumerateArray()) @@ -286,7 +286,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation.Id, internalTx.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent2.Operation, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); diff --git a/Tzkt.Sync/Services/Cache/AppStateCache.cs b/Tzkt.Sync/Services/Cache/AppStateCache.cs index b7cc718cd..a941ba961 100644 --- a/Tzkt.Sync/Services/Cache/AppStateCache.cs +++ b/Tzkt.Sync/Services/Cache/AppStateCache.cs @@ -184,6 +184,13 @@ public long NextSubId(TransferTicketOperation op) return op.Id + (int)op.SubIds; } + public long NextSubId(SmartRollupExecuteOperation op) + { + op.SubIds = (op.SubIds ?? 0) + 1; + if (op.SubIds >= 1 << AppState.SubIdBits) throw new Exception("SubId overflow"); + return op.Id + (int)op.SubIds; + } + public long NextSubId(MigrationOperation op) { op.SubIds = (op.SubIds ?? 0) + 1; diff --git a/docker-compose.ghost.yml b/docker-compose.ghost.yml index fc36bb7fe..814cdcd42 100644 --- a/docker-compose.ghost.yml +++ b/docker-compose.ghost.yml @@ -34,7 +34,7 @@ services: ConnectionStrings__DefaultConnection: host=ghost-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; Kestrel__Endpoints__Http__Url: http://0.0.0.0:5001 TezosNode__Endpoint: https://rpc.tzkt.io/ghostnet/ - Protocols__Diagnostics: true + Protocols__Diagnostics: false depends_on: - ghost-db ports: diff --git a/docker-compose.mumbai.yml b/docker-compose.mumbai.yml index 7d4f3e46f..23e5435a1 100644 --- a/docker-compose.mumbai.yml +++ b/docker-compose.mumbai.yml @@ -10,7 +10,7 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-qwerty} POSTGRES_DB: ${POSTGRES_DB:-tzkt_db} volumes: - - postgres:/var/lib/postgresql/data + - mumbai-postgres:/var/lib/postgresql/data ports: - 127.0.0.1:5435:5432 @@ -40,4 +40,4 @@ services: - 0.0.0.0:5031:5001 volumes: - postgres: + mumbai-postgres: diff --git a/docker-compose.nairobi.yml b/docker-compose.nairobi.yml index 0d20b7b53..2b4d693c7 100644 --- a/docker-compose.nairobi.yml +++ b/docker-compose.nairobi.yml @@ -10,7 +10,7 @@ services: POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-qwerty} POSTGRES_DB: ${POSTGRES_DB:-tzkt_db} volumes: - - postgres:/var/lib/postgresql/data + - nairobi-postgres:/var/lib/postgresql/data ports: - 127.0.0.1:5434:5432 @@ -34,11 +34,11 @@ services: ConnectionStrings__DefaultConnection: host=nairobi-db;port=5432;database=${POSTGRES_DB:-tzkt_db};username=${POSTGRES_USER:-tzkt};password=${POSTGRES_PASSWORD:-qwerty};command timeout=${COMMAND_TIMEOUT:-600}; Kestrel__Endpoints__Http__Url: http://0.0.0.0:5001 TezosNode__Endpoint: https://rpc.tzkt.io/nairobinet/ - Protocols__Diagnostics: true + Protocols__Diagnostics: false depends_on: - nairobi-db ports: - 0.0.0.0:5021:5001 volumes: - postgres: + nairobi-postgres: From 61a3f0bd5866e1fec0670545e1d3243f18bc9d41 Mon Sep 17 00:00:00 2001 From: dmir Date: Tue, 15 Aug 2023 13:43:28 +0300 Subject: [PATCH 27/51] WIP Tickets API --- Tzkt.Api/Controllers/TicketsController.cs | 351 ++++++ Tzkt.Api/Models/Accounts/Contract.cs | 24 + Tzkt.Api/Models/Accounts/Delegate.cs | 20 + Tzkt.Api/Models/Accounts/Ghost.cs | 20 + Tzkt.Api/Models/Accounts/Rollup.cs | 20 + Tzkt.Api/Models/Accounts/SmartRollup.cs | 20 + Tzkt.Api/Models/Accounts/User.cs | 20 + .../Models/Operations/MigrationOperation.cs | 5 + .../Models/Operations/TransactionOperation.cs | 5 + .../Operations/TransferTicketOperation.cs | 5 + Tzkt.Api/Models/Tickets/Ticket.cs | 90 ++ Tzkt.Api/Models/Tickets/TicketBalance.cs | 59 + Tzkt.Api/Models/Tickets/TicketBalanceShort.cs | 23 + Tzkt.Api/Models/Tickets/TicketInfo.cs | 32 + Tzkt.Api/Models/Tickets/TicketTransfer.cs | 63 ++ Tzkt.Api/Parameters/TicketBalanceFilter.cs | 66 ++ .../Parameters/TicketBalanceShortFilter.cs | 31 + Tzkt.Api/Parameters/TicketFilter.cs | 74 ++ Tzkt.Api/Parameters/TicketInfoFilter.cs | 39 + Tzkt.Api/Parameters/TicketTransferFilter.cs | 86 ++ Tzkt.Api/Program.cs | 3 + .../Repositories/AccountRepository.Bakers.cs | 36 + .../AccountRepository.Contracts.cs | 28 + Tzkt.Api/Repositories/AccountRepository.cs | 78 ++ .../OperationRepository.Migrations.cs | 12 + .../OperationRepository.Transactions.cs | 15 + .../OperationRepository.TransferTicket.cs | 14 + .../Repositories/SmartRollupsRepository.cs | 24 + Tzkt.Api/Repositories/TicketsRepository.cs | 1008 +++++++++++++++++ .../Cache/Accounts/Models/RawAccount.cs | 3 + .../Cache/Accounts/Models/RawContract.cs | 1 + .../Cache/State/RawModels/RawState.cs | 3 + Tzkt.Api/Swagger/Swagger.cs | 2 + Tzkt.Data/Models/Scripts/TicketBalance.cs | 2 + Tzkt.Data/Models/Scripts/TicketTransfer.cs | 2 + 35 files changed, 2284 insertions(+) create mode 100644 Tzkt.Api/Controllers/TicketsController.cs create mode 100644 Tzkt.Api/Models/Tickets/Ticket.cs create mode 100644 Tzkt.Api/Models/Tickets/TicketBalance.cs create mode 100644 Tzkt.Api/Models/Tickets/TicketBalanceShort.cs create mode 100644 Tzkt.Api/Models/Tickets/TicketInfo.cs create mode 100644 Tzkt.Api/Models/Tickets/TicketTransfer.cs create mode 100644 Tzkt.Api/Parameters/TicketBalanceFilter.cs create mode 100644 Tzkt.Api/Parameters/TicketBalanceShortFilter.cs create mode 100644 Tzkt.Api/Parameters/TicketFilter.cs create mode 100644 Tzkt.Api/Parameters/TicketInfoFilter.cs create mode 100644 Tzkt.Api/Parameters/TicketTransferFilter.cs create mode 100644 Tzkt.Api/Repositories/TicketsRepository.cs diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs new file mode 100644 index 000000000..0be07609d --- /dev/null +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -0,0 +1,351 @@ +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Tzkt.Api.Models; +using Tzkt.Api.Repositories; +using Tzkt.Api.Services; +using Tzkt.Api.Services.Cache; + +namespace Tzkt.Api.Controllers +{ + [ApiController] + [Route("v1/tickets")] + public class TicketsController : ControllerBase + { + readonly TicketsRepository Tickets; + readonly StateCache State; + readonly ResponseCacheService ResponseCache; + + public TicketsController(TicketsRepository tickets, StateCache state, ResponseCacheService responseCache) + { + Tickets = tickets; + State = state; + ResponseCache = responseCache; + } + + #region tickets + /// + /// Get tickets count + /// + /// + /// Returns a total number of tickets. + /// + /// Filter + /// + [HttpGet("count")] + public async Task> GetTicketsCount([FromQuery] TicketFilter filter) + { + if (filter.contract != null || + filter.metadata != null || + filter.firstTime != null || + filter.firstMinter != null || + filter.firstLevel != null || + filter.lastTime != null || + filter.lastLevel != null || + filter.ticketId != null || + filter.id != null || + filter.indexedAt != null) + { + var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); + + if (ResponseCache.TryGet(query, out var cached)) + return this.Bytes(cached); + + var res = await Tickets.GetTicketsCount(filter); + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); + } + + return Ok(State.Current.TicketsCount); + } + + /// + /// Get tickets + /// + /// + /// Returns a list of tickets. + /// + /// Filter + /// Pagination + /// Selection + /// + [HttpGet] + public async Task>> GetTickets( + [FromQuery] TicketFilter filter, + [FromQuery] Pagination pagination, + [FromQuery] Selection selection) + { + var query = ResponseCacheService.BuildKey(Request.Path.Value, + ("filter", filter), ("pagination", pagination), ("selection", selection)); + + if (ResponseCache.TryGet(query, out var cached)) + return this.Bytes(cached); + + object res; + if (selection.select == null) + { + res = await Tickets.GetTickets(filter, pagination); + } + else + { + res = new SelectionResponse + { + Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), + Rows = await Tickets.GetTickets(filter, pagination, selection.select.Fields ?? selection.select.Values) + }; + } + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); + } + #endregion + + #region ticket balances + /// + /// Get ticket balances count + /// + /// + /// Returns a total number of ticket balances. + /// + /// Filter + /// + [HttpGet("balances/count")] + public async Task> GetTicketBalancesCount([FromQuery] TicketBalanceFilter filter) + { + if (filter.account != null || + filter.balance != null || + filter.firstTime != null || + filter.firstLevel != null || + filter.lastTime != null || + filter.lastLevel != null || + filter.indexedAt != null || + filter.id != null || + filter.ticket.id != null || + filter.ticket.contract != null || + filter.ticket.ticketId != null || + filter.ticket.metadata != null) + { + #region optimizations + if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) + return Ok(0); + #endregion + + var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); + + if (ResponseCache.TryGet(query, out var cached)) + return this.Bytes(cached); + + var res = await Tickets.GetTicketBalancesCount(filter); + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); + } + + return Ok(State.Current.TicketBalancesCount); + } + + /// + /// Get ticket balances + /// + /// + /// Returns a list of ticket balances. + /// + /// Filter + /// Pagination + /// Selection + /// + [HttpGet("balances")] + public async Task>> GetTicketBalances( + [FromQuery] TicketBalanceFilter filter, + [FromQuery] Pagination pagination, + [FromQuery] Selection selection) + { + #region optimizations + if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) + return Ok(Enumerable.Empty()); + #endregion + + var query = ResponseCacheService.BuildKey(Request.Path.Value, + ("filter", filter), ("pagination", pagination), ("selection", selection)); + + if (ResponseCache.TryGet(query, out var cached)) + return this.Bytes(cached); + + object res; + if (selection.select == null) + { + res = await Tickets.GetTicketBalances(filter, pagination); + } + else + { + res = new SelectionResponse + { + Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), + Rows = await Tickets.GetTicketBalances(filter, pagination, selection.select.Fields ?? selection.select.Values) + }; + } + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); + } + #endregion + + #region ticket transfers + /// + /// Get ticket transfers count + /// + /// + /// Returns the total number of ticket transfers. + /// + /// Filter + /// + [HttpGet("transfers/count")] + public async Task> GetTicketTransfersCount([FromQuery] TicketTransferFilter filter) + { + if (filter.level != null || + filter.timestamp != null || + filter.from != null || + filter.to != null || + filter.anyof != null || + filter.amount != null || + filter.id != null || + filter.transactionId != null || + filter.originationId != null || + filter.migrationId != null || + filter.indexedAt != null || + filter.ticket.id != null || + filter.ticket.contract != null || + filter.ticket.ticketId != null || + filter.ticket.metadata != null) + { + #region optimizations + if (filter.from != null && (filter.from.Eq == -1 || filter.from.In?.Count == 0 && !filter.from.InHasNull)) + return Ok(0); + + if (filter.to != null && (filter.to.Eq == -1 || filter.to.In?.Count == 0 && !filter.to.InHasNull)) + return Ok(0); + + if (filter.anyof != null && (filter.anyof.Eq == -1 || filter.anyof.In?.Count == 0 && !filter.anyof.InHasNull)) + return Ok(0); + #endregion + + var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); + + if (ResponseCache.TryGet(query, out var cached)) + return this.Bytes(cached); + + var res = await Tickets.GetTicketTransfersCount(filter); + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); + } + + return Ok(State.Current.TicketTransfersCount); + } + + /// + /// Get ticket transfers + /// + /// + /// Returns a list of ticket transfers. + /// + /// Filter + /// Pagination + /// Selection + /// + [HttpGet("transfers")] + public async Task>> GetTicketTransfers( + [FromQuery] TicketTransferFilter filter, + [FromQuery] Pagination pagination, + [FromQuery] Selection selection) + { + #region optimizations + if (filter.from != null && (filter.from.Eq == -1 || filter.from.In?.Count == 0 && !filter.from.InHasNull)) + return Ok(Enumerable.Empty()); + + if (filter.to != null && (filter.to.Eq == -1 || filter.to.In?.Count == 0 && !filter.to.InHasNull)) + return Ok(Enumerable.Empty()); + + if (filter.anyof != null && (filter.anyof.Eq == -1 || filter.anyof.In?.Count == 0 && !filter.anyof.InHasNull)) + return Ok(Enumerable.Empty()); + #endregion + + var query = ResponseCacheService.BuildKey(Request.Path.Value, + ("filter", filter), ("pagination", pagination), ("selection", selection)); + + if (ResponseCache.TryGet(query, out var cached)) + return this.Bytes(cached); + + object res; + if (selection.select == null) + { + res = await Tickets.GetTicketTransfers(filter, pagination); + } + else + { + res = new SelectionResponse + { + Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), + Rows = await Tickets.GetTicketTransfers(filter, pagination, selection.select.Fields ?? selection.select.Values) + }; + } + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); + } + #endregion + + #region historical balances + /// + /// Get historical ticket balances + /// + /// + /// Returns a list of ticket balances at the end of the specified block. + /// Note, this endpoint is quite heavy, therefore at least one of the filters + /// (`account`, `ticket.id`, `ticket.contract` with `ticket.ticketId`) must be specified. + /// + /// Level of the block at the end of which historical balances must be calculated + /// Filter + /// Pagination + /// Selection + /// + [HttpGet("historical_balances/{level:int}")] + public async Task>> GetTicketBalances(int level, + [FromQuery] TicketBalanceShortFilter filter, + [FromQuery] Pagination pagination, + [FromQuery] Selection selection) + { + if (filter.account?.Eq == null && + filter.account?.In == null && + filter.ticket.id?.Eq == null && + filter.ticket.id?.In == null && + (filter.ticket.contract?.Eq == null && filter.ticket.contract?.In == null || + filter.ticket.ticketId?.Eq == null && filter.ticket.ticketId?.In == null)) + return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.contract` with `ticket.ticketId`) must be specified"); + + #region optimizations + if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) + return Ok(Enumerable.Empty()); + #endregion + + var query = ResponseCacheService.BuildKey(Request.Path.Value, + ("filter", filter), ("pagination", pagination), ("selection", selection)); + + if (ResponseCache.TryGet(query, out var cached)) + return this.Bytes(cached); + + object res; + if (selection.select == null) + { + res = await Tickets.GetHistoricalTicketBalances(level, filter, pagination); + } + else + { + res = new SelectionResponse + { + Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), + Rows = await Tickets.GetHistoricalTicketBalances(level, filter, pagination, selection.select.Fields ?? selection.select.Values) + }; + } + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); + } + #endregion + } +} diff --git a/Tzkt.Api/Models/Accounts/Contract.cs b/Tzkt.Api/Models/Accounts/Contract.cs index 1b51ac6c6..818c69dbf 100644 --- a/Tzkt.Api/Models/Accounts/Contract.cs +++ b/Tzkt.Api/Models/Accounts/Contract.cs @@ -95,6 +95,30 @@ public class Contract : Account /// public int TokenTransfersCount { get; set; } + /// + /// Number of delegation operations of the contract. + /// + + /// + /// Number of account tickets with non-zero balances. + /// + public int ActiveTicketsCount { get; set; } + + /// + /// Number of tickets minted in the contract. + /// + public int TicketsCount { get; set; } + + /// + /// Number of tickets the account ever had. + /// + public int TicketBalancesCount { get; set; } + + /// + /// Number of ticket transfers from/to the account. + /// + public int TicketTransfersCount { get; set; } + /// /// Number of delegation operations of the contract. /// diff --git a/Tzkt.Api/Models/Accounts/Delegate.cs b/Tzkt.Api/Models/Accounts/Delegate.cs index fb69d4fff..f2c1dbaee 100644 --- a/Tzkt.Api/Models/Accounts/Delegate.cs +++ b/Tzkt.Api/Models/Accounts/Delegate.cs @@ -130,6 +130,26 @@ public class Delegate : Account /// public int TokenTransfersCount { get; set; } + /// + /// Number of account tickets with non-zero balances. + /// + public int ActiveTicketsCount { get; set; } + + /// + /// Number of tickets minted in the contract. + /// + public int TicketsCount { get; set; } + + /// + /// Number of tickets the account ever had. + /// + public int TicketBalancesCount { get; set; } + + /// + /// Number of ticket transfers from/to the account. + /// + public int TicketTransfersCount { get; set; } + /// /// Number of current delegators (accounts, delegated their funds) of the delegate (baker) /// diff --git a/Tzkt.Api/Models/Accounts/Ghost.cs b/Tzkt.Api/Models/Accounts/Ghost.cs index 0f8c5559f..429636b6d 100644 --- a/Tzkt.Api/Models/Accounts/Ghost.cs +++ b/Tzkt.Api/Models/Accounts/Ghost.cs @@ -40,6 +40,26 @@ public class Ghost : Account /// public int TokenTransfersCount { get; set; } + /// + /// Number of account tickets with non-zero balances. + /// + public int ActiveTicketsCount { get; set; } + + /// + /// Number of tickets minted in the contract. + /// + public int TicketsCount { get; set; } + + /// + /// Number of tickets the account ever had. + /// + public int TicketBalancesCount { get; set; } + + /// + /// Number of ticket transfers from/to the account. + /// + public int TicketTransfersCount { get; set; } + /// /// Block height at which the ghost contract appeared first time /// diff --git a/Tzkt.Api/Models/Accounts/Rollup.cs b/Tzkt.Api/Models/Accounts/Rollup.cs index 3f31d52c1..be7b5d36d 100644 --- a/Tzkt.Api/Models/Accounts/Rollup.cs +++ b/Tzkt.Api/Models/Accounts/Rollup.cs @@ -50,6 +50,26 @@ public class Rollup : Account /// public int TokenTransfersCount { get; set; } + /// + /// Number of account tickets with non-zero balances. + /// + public int ActiveTicketsCount { get; set; } + + /// + /// Number of tickets minted in the contract. + /// + public int TicketsCount { get; set; } + + /// + /// Number of tickets the account ever had. + /// + public int TicketBalancesCount { get; set; } + + /// + /// Number of ticket transfers from/to the account. + /// + public int TicketTransfersCount { get; set; } + /// /// Number of transaction operations related to the account /// diff --git a/Tzkt.Api/Models/Accounts/SmartRollup.cs b/Tzkt.Api/Models/Accounts/SmartRollup.cs index 0090c2c7e..b4ce045ce 100644 --- a/Tzkt.Api/Models/Accounts/SmartRollup.cs +++ b/Tzkt.Api/Models/Accounts/SmartRollup.cs @@ -104,6 +104,26 @@ public class SmartRollup : Account /// public int TokenTransfersCount { get; set; } + /// + /// Number of account tickets with non-zero balances. + /// + public int ActiveTicketsCount { get; set; } + + /// + /// Number of tickets minted in the contract. + /// + public int TicketsCount { get; set; } + + /// + /// Number of tickets the account ever had. + /// + public int TicketBalancesCount { get; set; } + + /// + /// Number of ticket transfers from/to the account. + /// + public int TicketTransfersCount { get; set; } + /// /// Number of transaction operations related to the account /// diff --git a/Tzkt.Api/Models/Accounts/User.cs b/Tzkt.Api/Models/Accounts/User.cs index 7b10d81f9..8620d753e 100644 --- a/Tzkt.Api/Models/Accounts/User.cs +++ b/Tzkt.Api/Models/Accounts/User.cs @@ -98,6 +98,26 @@ public class User : Account /// public int TokenTransfersCount { get; set; } + /// + /// Number of account tickets with non-zero balances. + /// + public int ActiveTicketsCount { get; set; } + + /// + /// Number of tickets minted in the contract. + /// + public int TicketsCount { get; set; } + + /// + /// Number of tickets the account ever had. + /// + public int TicketBalancesCount { get; set; } + + /// + /// Number of ticket transfers from/to the account. + /// + public int TicketTransfersCount { get; set; } + /// /// Number of account activation operations. Are used to activate accounts that were recommended allocations of /// tezos tokens for donations to the Tezos Foundation’s fundraiser diff --git a/Tzkt.Api/Models/Operations/MigrationOperation.cs b/Tzkt.Api/Models/Operations/MigrationOperation.cs index 5cd2d6206..a0bc63b85 100644 --- a/Tzkt.Api/Models/Operations/MigrationOperation.cs +++ b/Tzkt.Api/Models/Operations/MigrationOperation.cs @@ -71,6 +71,11 @@ public class MigrationOperation : Operation /// public int? TokenTransfersCount { get; set; } + /// + /// Number of ticket transfers produced by the operation, or `null` if there are no transfers + /// + public int? TicketTransfersCount { get; set; } + #region injecting /// /// Injected historical quote at the time of operation diff --git a/Tzkt.Api/Models/Operations/TransactionOperation.cs b/Tzkt.Api/Models/Operations/TransactionOperation.cs index 0945057a2..35b31d6a1 100644 --- a/Tzkt.Api/Models/Operations/TransactionOperation.cs +++ b/Tzkt.Api/Models/Operations/TransactionOperation.cs @@ -150,6 +150,11 @@ public class TransactionOperation : Operation /// public int? TokenTransfersCount { get; set; } + /// + /// Number of ticket transfers produced by the operation, or `null` if there are no transfers + /// + public int? TicketTransfersCount { get; set; } + /// /// Number of events produced by the operation, or `null` if there are no events /// diff --git a/Tzkt.Api/Models/Operations/TransferTicketOperation.cs b/Tzkt.Api/Models/Operations/TransferTicketOperation.cs index 804db3c3c..95d544ec2 100644 --- a/Tzkt.Api/Models/Operations/TransferTicketOperation.cs +++ b/Tzkt.Api/Models/Operations/TransferTicketOperation.cs @@ -95,6 +95,11 @@ public class TransferTicketOperation : Operation /// public string Entrypoint { get; set; } + /// + /// Number of ticket transfers produced by the operation, or `null` if there are no transfers + /// + public int? TicketTransfersCount { get; set; } + /// /// Micheline type of the content /// diff --git a/Tzkt.Api/Models/Tickets/Ticket.cs b/Tzkt.Api/Models/Tickets/Ticket.cs new file mode 100644 index 000000000..3db3f0723 --- /dev/null +++ b/Tzkt.Api/Models/Tickets/Ticket.cs @@ -0,0 +1,90 @@ +using System; +using NJsonSchema.Annotations; + +namespace Tzkt.Api.Models +{ + public class Ticket + { + /// + /// Internal TzKT id. + /// **[sortable]** + /// + public long Id { get; set; } + + /// + /// Contract, created the ticket. + /// + public Alias Ticketer { get; set; } + + + /// + /// Micheline type of the content + /// + public RawJson ContentType { get; set; } + + /// + /// Ticket content + /// + public object Content { get; set; } + + /// + /// Account, minted the ticket first. + /// + public Alias FirstMinter { get; set; } + + /// + /// Level of the block where the ticket was first seen. + /// **[sortable]** + /// + public int FirstLevel { get; set; } + + /// + /// Timestamp of the block where the ticket was first seen. + /// + public DateTime FirstTime { get; set; } + + /// + /// Level of the block where the ticket was last seen. + /// **[sortable]** + /// + public int LastLevel { get; set; } + + /// + /// Timestamp of the block where the ticket was last seen. + /// + public DateTime LastTime { get; set; } + + /// + /// Total number of transfers. + /// **[sortable]** + /// + public int TransfersCount { get; set; } + + /// + /// Total number of holders ever seen. + /// **[sortable]** + /// + public int BalancesCount { get; set; } + + /// + /// Total number of current holders. + /// **[sortable]** + /// + public int HoldersCount { get; set; } + + /// + /// Total number of minted tickets (raw value, not divided by `decimals`). + /// + public string TotalMinted { get; set; } + + /// + /// Total number of burned tickets (raw value, not divided by `decimals`). + /// + public string TotalBurned { get; set; } + + /// + /// Total number of existing tickets (raw value, not divided by `decimals`). + /// + public string TotalSupply { get; set; } + } +} diff --git a/Tzkt.Api/Models/Tickets/TicketBalance.cs b/Tzkt.Api/Models/Tickets/TicketBalance.cs new file mode 100644 index 000000000..70ef1d78b --- /dev/null +++ b/Tzkt.Api/Models/Tickets/TicketBalance.cs @@ -0,0 +1,59 @@ +using System; + +namespace Tzkt.Api.Models +{ + public class TicketBalance + { + /// + /// Internal TzKT id. + /// **[sortable]** + /// + public long Id { get; set; } + + /// + /// Owner account. + /// Click on the field to expand more details. + /// + public Alias Account { get; set; } + + /// + /// Ticket info. + /// Click on the field to expand more details. + /// + public TicketInfo Ticket { get; set; } + + /// + /// Balance (raw value, not divided by `decimals`). + /// **[sortable]** + /// + public string Balance { get; set; } + + /// + /// Total number of transfers, affecting the token balance. + /// **[sortable]** + /// + public int TransfersCount { get; set; } + + /// + /// Level of the block where the token balance was first changed. + /// **[sortable]** + /// + public int FirstLevel { get; set; } + + /// + /// Timestamp of the block where the token balance was first changed. + /// + public DateTime FirstTime { get; set; } + + /// + /// Level of the block where the token balance was last changed. + /// **[sortable]** + /// + public int LastLevel { get; set; } + + /// + /// Timestamp of the block where the token balance was last changed. + /// + public DateTime LastTime { get; set; } + } +} diff --git a/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs b/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs new file mode 100644 index 000000000..4ba9af85c --- /dev/null +++ b/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs @@ -0,0 +1,23 @@ +namespace Tzkt.Api.Models +{ + public class TicketBalanceShort + { + /// + /// Owner account. + /// Click on the field to expand more details. + /// + public Alias Account { get; set; } + + /// + /// Ticket info. + /// Click on the field to expand more details. + /// + public TicketInfo Ticket { get; set; } + + /// + /// Balance (raw value, not divided by `decimals`). + /// **[sortable]** + /// + public string Balance { get; set; } + } +} diff --git a/Tzkt.Api/Models/Tickets/TicketInfo.cs b/Tzkt.Api/Models/Tickets/TicketInfo.cs new file mode 100644 index 000000000..aabb5b4ad --- /dev/null +++ b/Tzkt.Api/Models/Tickets/TicketInfo.cs @@ -0,0 +1,32 @@ +using NJsonSchema.Annotations; + +namespace Tzkt.Api.Models +{ + public class TicketInfo + { + /// + /// Internal TzKT id. + /// + public long Id { get; set; } + + /// + /// Contract, created the ticket. + /// + public Alias Ticketer { get; set; } + + /// + /// Micheline type of the content + /// + public RawJson ContentType { get; set; } + + /// + /// Ticket content + /// + public object Content { get; set; } + + /// + /// Total number of existing tickets (raw value, not divided by `decimals`). In historical ticket balances this field is omitted. + /// + public string TotalSupply { get; set; } + } +} diff --git a/Tzkt.Api/Models/Tickets/TicketTransfer.cs b/Tzkt.Api/Models/Tickets/TicketTransfer.cs new file mode 100644 index 000000000..5482873c7 --- /dev/null +++ b/Tzkt.Api/Models/Tickets/TicketTransfer.cs @@ -0,0 +1,63 @@ +using System; + +namespace Tzkt.Api.Models +{ + public class TicketTransfer + { + /// + /// Internal TzKT id. + /// **[sortable]** + /// + public long Id { get; set; } + + /// + /// Level of the block, at which the ticket transfer was made. + /// **[sortable]** + /// + public int Level { get; set; } + + /// + /// Timestamp of the block, at which the ticket transfer was made. + /// + public DateTime Timestamp { get; set; } + + /// + /// Ticket info. + /// Click on the field to expand more details. + /// + public TicketInfo Ticket { get; set; } + + /// + /// Sender account. + /// Click on the field to expand more details. + /// + public Alias From { get; set; } + + /// + /// Target account. + /// Click on the field to expand more details. + /// + public Alias To { get; set; } + + /// + /// Amount of tickets transferred (raw value, not divided by `decimals`). + /// **[sortable]** + /// + public string Amount { get; set; } + + /// + /// Internal TzKT id of the transaction operation, caused the ticket transfer. + /// + public long? TransactionId { get; set; } + + /// + /// Internal TzKT id of the transfer ticket operation, caused the ticket transfer. + /// + public long? TransferTicketId { get; set; } + + /// + /// Internal TzKT id of the smart rollup execute operation, caused the ticket transfer. + /// + public long? SmartRollupExecuteId { get; set; } + } +} diff --git a/Tzkt.Api/Parameters/TicketBalanceFilter.cs b/Tzkt.Api/Parameters/TicketBalanceFilter.cs new file mode 100644 index 000000000..92c6611a2 --- /dev/null +++ b/Tzkt.Api/Parameters/TicketBalanceFilter.cs @@ -0,0 +1,66 @@ +using System.Text.Json.Serialization; +using Tzkt.Api.Services; + +namespace Tzkt.Api +{ + public class TicketBalanceFilter : INormalizable + { + /// + /// Filter by internal TzKT id. + /// Click on the parameter to expand more details. + /// + public Int64Parameter id { get; set; } + + /// + /// Filter by account address. + /// Click on the parameter to expand more details. + /// + public AccountParameter account { get; set; } + + /// + /// Filter by ticket. + /// Click on the parameter to expand more details. + /// + public TicketInfoFilter ticket { get; set; } + + /// + /// Filter by balance. + /// Click on the parameter to expand more details. + /// + public NatParameter balance { get; set; } + + /// + /// Filter by level of the block where the balance was first changed. + /// Click on the parameter to expand more details. + /// + public Int32Parameter firstLevel { get; set; } + + /// + /// Filter by timestamp (ISO 8601) of the block where the balance was first changed. + /// Click on the parameter to expand more details. + /// + public TimestampParameter firstTime { get; set; } + + /// + /// Filter by level of the block where the balance was last seen. + /// Click on the parameter to expand more details. + /// + public Int32Parameter lastLevel { get; set; } + + /// + /// Filter by timestamp (ISO 8601) of the block where the balance was last changed. + /// Click on the parameter to expand more details. + /// + public TimestampParameter lastTime { get; set; } + + [JsonIgnore] + public Int32NullParameter indexedAt { get; set; } + + public string Normalize(string name) + { + return ResponseCacheService.BuildKey("", + ("id", id), ("account", account), ("ticket", ticket), ("balance", balance), ("firstLevel", firstLevel), + ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("indexedAt", indexedAt)); + } + } +} diff --git a/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs b/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs new file mode 100644 index 000000000..024e3a562 --- /dev/null +++ b/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs @@ -0,0 +1,31 @@ +using Tzkt.Api.Services; + +namespace Tzkt.Api +{ + public class TicketBalanceShortFilter : INormalizable + { + /// + /// Filter by account address. + /// Click on the parameter to expand more details. + /// + public AccountParameter account { get; set; } + + /// + /// Filter by ticket. + /// Click on the parameter to expand more details. + /// + public TicketInfoFilter ticket { get; set; } + + /// + /// Filter by balance. + /// Click on the parameter to expand more details. + /// + public NatParameter balance { get; set; } + + public string Normalize(string name) + { + return ResponseCacheService.BuildKey("", + ("account", account), ("ticket", ticket), ("balance", balance)); + } + } +} diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs new file mode 100644 index 000000000..113f884f3 --- /dev/null +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -0,0 +1,74 @@ +using System.Text.Json.Serialization; +using Tzkt.Api.Services; + +namespace Tzkt.Api +{ + public class TicketFilter : INormalizable + { + /// + /// Filter by internal TzKT id. Note, this is not the same as `ticketId` nat value. + /// Click on the parameter to expand more details. + /// + public Int64Parameter id { get; set; } + + /// + /// Filter by contract address. + /// Click on the parameter to expand more details. + /// + public AccountParameter contract { get; set; } + + /// + /// Filter by ticketId (for FA1.2 tickets ticketId is always `"0"`). + /// Click on the parameter to expand more details. + /// + public NatParameter ticketId { get; set; } + + /// + /// Filter by address of the first minter. + /// Click on the parameter to expand more details. + /// + public AccountParameter firstMinter { get; set; } + + /// + /// Filter by level of the block where the ticket was first seen. + /// Click on the parameter to expand more details. + /// + public Int32Parameter firstLevel { get; set; } + + /// + /// Filter by timestamp (ISO 8601) of the block where the ticket was first seen. + /// Click on the parameter to expand more details. + /// + public TimestampParameter firstTime { get; set; } + + /// + /// Filter by level of the block where the ticket was last seen. + /// Click on the parameter to expand more details. + /// + public Int32Parameter lastLevel { get; set; } + + /// + /// Filter by timestamp (ISO 8601) of the block where the ticket was last seen. + /// Click on the parameter to expand more details. + /// + public TimestampParameter lastTime { get; set; } + + /// + /// Filter by metadata. + /// Note, this parameter supports the following format: `metadata{.path?}{.mode?}=...`, + /// so you can specify a path to a particular field to filter by (for example, `?metadata.symbol.in=kUSD,uUSD`). + /// Click on the parameter to expand more details. + /// + public JsonParameter metadata { get; set; } + + [JsonIgnore] + public Int32NullParameter indexedAt { get; set; } + + public string Normalize(string name) + { + return ResponseCacheService.BuildKey("", + ("id", id), ("contract", contract), ("ticketId", ticketId), ("firstMinter", firstMinter), ("firstLevel", firstLevel), + ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("metadata", metadata), ("indexedAt", indexedAt)); + } + } +} diff --git a/Tzkt.Api/Parameters/TicketInfoFilter.cs b/Tzkt.Api/Parameters/TicketInfoFilter.cs new file mode 100644 index 000000000..f6c89fd33 --- /dev/null +++ b/Tzkt.Api/Parameters/TicketInfoFilter.cs @@ -0,0 +1,39 @@ +using Newtonsoft.Json; +using Tzkt.Api.Services; + +namespace Tzkt.Api +{ + public class TicketInfoFilter : INormalizable + { + /// + /// Filter by internal TzKT id. Note, this is not the same as `ticketId`. + /// Click on the parameter to expand more details. + /// + public Int64Parameter id { get; set; } + + /// + /// Filter by contract address. + /// Click on the parameter to expand more details. + /// + public AccountParameter contract { get; set; } + + /// + /// Filter by ticketId (for FA1.2 tickets ticketId is always `"0"`). + /// Click on the parameter to expand more details. + /// + public NatParameter ticketId { get; set; } + + /// + /// Filter by metadata. Note, this parameter supports the following format: `ticket.metadata{.path?}{.mode?}=...`, + /// so you can specify a path to a particular field to filter by, for example: `?ticket.metadata.symbol.in=kUSD,uUSD`. + /// Click on the parameter to expand more details. + /// + public JsonParameter metadata { get; set; } + + public string Normalize(string name) + { + return ResponseCacheService.BuildKey("", + ("id", id), ("contract", contract), ("ticketId", ticketId), ("metadata", metadata)); + } + } +} diff --git a/Tzkt.Api/Parameters/TicketTransferFilter.cs b/Tzkt.Api/Parameters/TicketTransferFilter.cs new file mode 100644 index 000000000..8acfdf54c --- /dev/null +++ b/Tzkt.Api/Parameters/TicketTransferFilter.cs @@ -0,0 +1,86 @@ +using System.Text.Json.Serialization; +using Tzkt.Api.Services; + +namespace Tzkt.Api +{ + public class TicketTransferFilter : INormalizable + { + /// + /// Filter by internal TzKT id. + /// Click on the parameter to expand more details. + /// + public Int64Parameter id { get; set; } + + /// + /// Filter by level of the block where the transfer was made. + /// Click on the parameter to expand more details. + /// + public Int32Parameter level { get; set; } + + /// + /// Filter by timestamp (ISO 8601) of the block where the transfer was made. + /// Click on the parameter to expand more details. + /// + public TimestampParameter timestamp { get; set; } + + /// + /// Filter by ticket. + /// Click on the parameter to expand more details. + /// + public TicketInfoFilter ticket { get; set; } + + /// + /// Filter by any of the specified fields (`from` or `to`). + /// Example: `anyof.from.to=tz1...` will return transfers where `from` OR `to` is equal to the specified value. + /// This parameter is useful when you need to get both incoming and outgoing transfers of the account at once. + /// Click on the parameter to expand more details. + /// + public AnyOfParameter anyof { get; set; } + + /// + /// Filter by sender account address. + /// Click on the parameter to expand more details. + /// + public AccountParameter from { get; set; } + + /// + /// Filter by target account address. + /// Click on the parameter to expand more details. + /// + public AccountParameter to { get; set; } + + /// + /// Filter by amount. + /// Click on the parameter to expand more details. + /// + public NatParameter amount { get; set; } + + /// + /// Filter by id of the transaction, caused the ticket transfer. + /// Click on the parameter to expand more details. + /// + public Int64NullParameter transactionId { get; set; } + + /// + /// Filter by id of the origination, caused the ticket transfer. + /// Click on the parameter to expand more details. + /// + public Int64NullParameter originationId { get; set; } + + /// + /// Filter by id of the migration, caused the ticket transfer. + /// Click on the parameter to expand more details. + /// + public Int64NullParameter migrationId { get; set; } + + [JsonIgnore] + public Int32NullParameter indexedAt { get; set; } + + public string Normalize(string name) + { + return ResponseCacheService.BuildKey("", + ("id", id), ("level", level), ("timestamp", timestamp), ("ticket", ticket), ("anyof", anyof), ("from", from), ("to", to), + ("amount", amount), ("transactionId", transactionId), ("originationId", originationId), ("migrationId", migrationId), ("indexedAt", indexedAt)); + } + } +} diff --git a/Tzkt.Api/Program.cs b/Tzkt.Api/Program.cs index 5f5d68cb7..f333c2c5c 100644 --- a/Tzkt.Api/Program.cs +++ b/Tzkt.Api/Program.cs @@ -65,6 +65,7 @@ builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); @@ -120,6 +121,8 @@ builder.Services.AddTransient>(); builder.Services.AddTransient>(); + //TODO Add Ticket Balance and Transfer processors. + builder.Services.AddTransient>(); builder.Services.AddTransient>(); diff --git a/Tzkt.Api/Repositories/AccountRepository.Bakers.cs b/Tzkt.Api/Repositories/AccountRepository.Bakers.cs index 5c4ffb947..6f6b9d048 100644 --- a/Tzkt.Api/Repositories/AccountRepository.Bakers.cs +++ b/Tzkt.Api/Repositories/AccountRepository.Bakers.cs @@ -59,6 +59,9 @@ public partial class AccountRepository : DbConnection ActiveTokensCount = delegat.ActiveTokensCount, TokenBalancesCount = delegat.TokenBalancesCount, TokenTransfersCount = delegat.TokenTransfersCount, + ActiveTicketsCount = delegat.ActiveTicketsCount, + TicketBalancesCount = delegat.TicketBalancesCount, + TicketTransfersCount = delegat.TicketTransfersCount, NumDelegators = delegat.DelegatorsCount, NumBlocks = delegat.BlocksCount, NumDelegations = delegat.DelegationsCount, @@ -171,6 +174,9 @@ public async Task GetDelegatesCount(BoolParameter active) ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, NumDelegators = row.DelegatorsCount, NumBlocks = row.BlocksCount, NumDelegations = row.DelegationsCount, @@ -245,6 +251,9 @@ public async Task GetDelegates( case "activeTokensCount": columns.Add(@"""ActiveTokensCount"""); break; case "tokenBalancesCount": columns.Add(@"""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"""TokenTransfersCount"""); break; + case "activeTicketsCount": columns.Add(@"""ActiveTicketsCount"""); break; + case "ticketBalancesCount": columns.Add(@"""TicketBalancesCount"""); break; + case "ticketTransfersCount": columns.Add(@"""TicketTransfersCount"""); break; case "numDelegators": columns.Add(@"""DelegatorsCount"""); break; case "numBlocks": columns.Add(@"""BlocksCount"""); break; case "numDelegations": columns.Add(@"""DelegationsCount"""); break; @@ -429,6 +438,18 @@ public async Task GetDelegates( foreach (var row in rows) result[j++][i] = row.TokenTransfersCount; break; + case "activeTicketsCount": + foreach (var row in rows) + result[j++][i] = row.ActiveTicketsCount; + break; + case "ticketBalancesCount": + foreach (var row in rows) + result[j++][i] = row.TicketBalancesCount; + break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++][i] = row.TicketTransfersCount; + break; case "numDelegators": foreach (var row in rows) result[j++][i] = row.DelegatorsCount; @@ -653,6 +674,9 @@ public async Task GetDelegates( case "activeTokensCount": columns.Add(@"""ActiveTokensCount"""); break; case "tokenBalancesCount": columns.Add(@"""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"""TokenTransfersCount"""); break; + case "activeTicketsCount": columns.Add(@"""ActiveTicketsCount"""); break; + case "ticketBalancesCount": columns.Add(@"""TicketBalancesCount"""); break; + case "ticketTransfersCount": columns.Add(@"""TicketTransfersCount"""); break; case "numDelegators": columns.Add(@"""DelegatorsCount"""); break; case "numBlocks": columns.Add(@"""BlocksCount"""); break; case "numDelegations": columns.Add(@"""DelegationsCount"""); break; @@ -833,6 +857,18 @@ public async Task GetDelegates( foreach (var row in rows) result[j++] = row.TokenTransfersCount; break; + case "activeTicketsCount": + foreach (var row in rows) + result[j++] = row.ActiveTicketsCount; + break; + case "ticketBalancesCount": + foreach (var row in rows) + result[j++] = row.TicketBalancesCount; + break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++] = row.TicketTransfersCount; + break; case "numDelegators": foreach (var row in rows) result[j++] = row.DelegatorsCount; diff --git a/Tzkt.Api/Repositories/AccountRepository.Contracts.cs b/Tzkt.Api/Repositories/AccountRepository.Contracts.cs index 06337a204..57106ed6e 100644 --- a/Tzkt.Api/Repositories/AccountRepository.Contracts.cs +++ b/Tzkt.Api/Repositories/AccountRepository.Contracts.cs @@ -45,6 +45,10 @@ async Task> QueryContractsAsync(bool includeStorage, Contra case "tokensCount": columns.Add(@"c.""TokensCount"""); break; case "tokenBalancesCount": columns.Add(@"c.""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"c.""TokenTransfersCount"""); break; + case "activeTicketsCount": columns.Add(@"c.""ActiveTicketsCount"""); break; + case "ticketsCount": columns.Add(@"c.""TicketsCount"""); break; + case "ticketBalancesCount": columns.Add(@"c.""TicketBalancesCount"""); break; + case "ticketTransfersCount": columns.Add(@"c.""TicketTransfersCount"""); break; case "numDelegations": columns.Add(@"c.""DelegationsCount"""); break; case "numOriginations": columns.Add(@"c.""OriginationsCount"""); break; case "numTransactions": columns.Add(@"c.""TransactionsCount"""); break; @@ -162,6 +166,10 @@ public async Task GetContract(string address, bool legacy) ActiveTokensCount = contract.ActiveTokensCount, TokenBalancesCount = contract.TokenBalancesCount, TokenTransfersCount = contract.TokenTransfersCount, + ActiveTicketsCount = contract.ActiveTicketsCount, + TicketsCount = contract.TicketsCount, + TicketBalancesCount = contract.TicketBalancesCount, + TicketTransfersCount = contract.TicketTransfersCount, NumDelegations = contract.DelegationsCount, NumOriginations = contract.OriginationsCount, NumReveals = contract.RevealsCount, @@ -251,6 +259,10 @@ public async Task> GetContracts(bool includeStorage, Contr ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, + TicketsCount = row.TicketsCount, NumDelegations = row.DelegationsCount, NumOriginations = row.OriginationsCount, NumReveals = row.RevealsCount, @@ -402,6 +414,22 @@ public async Task GetContracts(bool includeStorage, ContractFilter f foreach (var row in rows) result[j++][i] = row.TokenTransfersCount; break; + case "activeTicketsCount": + foreach (var row in rows) + result[j++][i] = row.ActiveTicketsCount; + break; + case "ticketsCount": + foreach (var row in rows) + result[j++][i] = row.TicketsCount; + break; + case "ticketBalancesCount": + foreach (var row in rows) + result[j++][i] = row.TicketBalancesCount; + break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++][i] = row.TicketTransfersCount; + break; case "numDelegations": foreach (var row in rows) result[j++][i] = row.DelegationsCount; diff --git a/Tzkt.Api/Repositories/AccountRepository.cs b/Tzkt.Api/Repositories/AccountRepository.cs index c4a1bc585..aa7f93b34 100644 --- a/Tzkt.Api/Repositories/AccountRepository.cs +++ b/Tzkt.Api/Repositories/AccountRepository.cs @@ -87,6 +87,9 @@ public async Task Get(string address, bool legacy) ActiveTokensCount = delegat.ActiveTokensCount, TokenBalancesCount = delegat.TokenBalancesCount, TokenTransfersCount = delegat.TokenTransfersCount, + ActiveTicketsCount = delegat.ActiveTicketsCount, + TicketBalancesCount = delegat.TicketBalancesCount, + TicketTransfersCount = delegat.TicketTransfersCount, NumDelegators = delegat.DelegatorsCount, NumBlocks = delegat.BlocksCount, NumDelegations = delegat.DelegationsCount, @@ -165,6 +168,9 @@ public async Task Get(string address, bool legacy) ActiveTokensCount = user.ActiveTokensCount, TokenBalancesCount = user.TokenBalancesCount, TokenTransfersCount = user.TokenTransfersCount, + ActiveTicketsCount = user.ActiveTicketsCount, + TicketBalancesCount = user.TicketBalancesCount, + TicketTransfersCount = user.TicketTransfersCount, NumDelegations = user.DelegationsCount, NumOriginations = user.OriginationsCount, NumReveals = user.RevealsCount, @@ -236,6 +242,10 @@ public async Task Get(string address, bool legacy) TokensCount = contract.TokensCount, TokenBalancesCount = contract.TokenBalancesCount, TokenTransfersCount = contract.TokenTransfersCount, + ActiveTicketsCount = contract.ActiveTicketsCount, + TicketsCount = contract.TicketsCount, + TicketBalancesCount = contract.TicketBalancesCount, + TicketTransfersCount = contract.TicketTransfersCount, NumDelegations = contract.DelegationsCount, NumOriginations = contract.OriginationsCount, NumReveals = contract.RevealsCount, @@ -273,6 +283,9 @@ public async Task Get(string address, bool legacy) ActiveTokensCount = rollup.ActiveTokensCount, TokenBalancesCount = rollup.TokenBalancesCount, TokenTransfersCount = rollup.TokenTransfersCount, + ActiveTicketsCount = rollup.ActiveTicketsCount, + TicketBalancesCount = rollup.TicketBalancesCount, + TicketTransfersCount = rollup.TicketTransfersCount, NumTransactions = rollup.TransactionsCount, Metadata = legacy ? rollup.Profile : null, Extras = legacy ? null : rollup.Extras @@ -295,6 +308,9 @@ public async Task Get(string address, bool legacy) ActiveTokensCount = rollup.ActiveTokensCount, TokenBalancesCount = rollup.TokenBalancesCount, TokenTransfersCount = rollup.TokenTransfersCount, + ActiveTicketsCount = rollup.ActiveTicketsCount, + TicketBalancesCount = rollup.TicketBalancesCount, + TicketTransfersCount = rollup.TicketTransfersCount, NumTransactions = rollup.TransactionsCount, SmartRollupCementCount = rollup.SmartRollupCementCount, SmartRollupExecuteCount = rollup.SmartRollupExecuteCount, @@ -328,6 +344,9 @@ public async Task Get(string address, bool legacy) ActiveTokensCount = ghost.ActiveTokensCount, TokenBalancesCount = ghost.TokenBalancesCount, TokenTransfersCount = ghost.TokenTransfersCount, + ActiveTicketsCount = ghost.ActiveTicketsCount, + TicketBalancesCount = ghost.TicketBalancesCount, + TicketTransfersCount = ghost.TicketTransfersCount, FirstActivity = ghost.FirstLevel, FirstActivityTime = Time[ghost.FirstLevel], LastActivity = ghost.LastLevel, @@ -439,6 +458,9 @@ public async Task> Get( ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, NumDelegations = row.DelegationsCount, NumOriginations = row.OriginationsCount, NumReveals = row.RevealsCount, @@ -505,6 +527,9 @@ public async Task> Get( ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, NumDelegators = row.DelegatorsCount, NumBlocks = row.BlocksCount, NumDelegations = row.DelegationsCount, @@ -587,6 +612,10 @@ public async Task> Get( TokensCount = row.TokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketsCount = row.TicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, NumDelegations = row.DelegationsCount, NumOriginations = row.OriginationsCount, NumReveals = row.RevealsCount, @@ -608,6 +637,9 @@ public async Task> Get( ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, FirstActivity = row.FirstLevel, FirstActivityTime = Time[row.FirstLevel], LastActivity = row.LastLevel, @@ -640,6 +672,9 @@ public async Task> Get( ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, NumTransactions = row.TransactionsCount }); break; @@ -661,6 +696,9 @@ public async Task> Get( ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, NumTransactions = row.TransactionsCount, SmartRollupCementCount = row.SmartRollupCementCount, SmartRollupExecuteCount = row.SmartRollupExecuteCount, @@ -736,6 +774,10 @@ public async Task Get( case "activeTokensCount": columns.Add(@"""ActiveTokensCount"""); break; case "tokenBalancesCount": columns.Add(@"""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"""TokenTransfersCount"""); break; + case "activeTicketsCount": columns.Add(@"""ActiveTicketsCount"""); break; + case "ticketsCount": columns.Add(@"""TicketsCount"""); break; + case "ticketBalancesCount": columns.Add(@"""TicketBalancesCount"""); break; + case "ticketTransfersCount": columns.Add(@"""TicketTransfersCount"""); break; case "numDelegators": columns.Add(@"""DelegatorsCount"""); break; case "numBlocks": columns.Add(@"""BlocksCount"""); break; case "numDelegations": columns.Add(@"""DelegationsCount"""); break; @@ -949,6 +991,22 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.TokenTransfersCount; break; + case "activeTicketsCount": + foreach (var row in rows) + result[j++][i] = row.ActiveTicketsCount; + break; + case "ticketsCount": + foreach (var row in rows) + result[j++][i] = row.TicketsCount; + break; + case "ticketBalancesCount": + foreach (var row in rows) + result[j++][i] = row.TicketBalancesCount; + break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++][i] = row.TicketTransfersCount; + break; case "numDelegators": foreach (var row in rows) result[j++][i] = row.DelegatorsCount; @@ -1282,6 +1340,10 @@ public async Task Get( case "activeTokensCount": columns.Add(@"""ActiveTokensCount"""); break; case "tokenBalancesCount": columns.Add(@"""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"""TokenTransfersCount"""); break; + case "activeTicketsCount": columns.Add(@"""ActiveTicketsCount"""); break; + case "ticketsCount": columns.Add(@"""TicketsCount"""); break; + case "ticketBalancesCount": columns.Add(@"""TicketBalancesCount"""); break; + case "ticketTransfersCount": columns.Add(@"""TicketTransfersCount"""); break; case "numDelegators": columns.Add(@"""DelegatorsCount"""); break; case "numBlocks": columns.Add(@"""BlocksCount"""); break; case "numDelegations": columns.Add(@"""DelegationsCount"""); break; @@ -1491,6 +1553,22 @@ public async Task Get( foreach (var row in rows) result[j++] = row.TokenTransfersCount; break; + case "activeTicketsCount": + foreach (var row in rows) + result[j++] = row.ActiveTicketsCount; + break; + case "ticketsCount": + foreach (var row in rows) + result[j++] = row.TicketsCount; + break; + case "ticketBalancesCount": + foreach (var row in rows) + result[j++] = row.TicketBalancesCount; + break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++] = row.TicketTransfersCount; + break; case "numDelegators": foreach (var row in rows) result[j++] = row.DelegatorsCount; diff --git a/Tzkt.Api/Repositories/OperationRepository.Migrations.cs b/Tzkt.Api/Repositories/OperationRepository.Migrations.cs index 16e08482b..e90599114 100644 --- a/Tzkt.Api/Repositories/OperationRepository.Migrations.cs +++ b/Tzkt.Api/Repositories/OperationRepository.Migrations.cs @@ -65,6 +65,7 @@ INNER JOIN ""Blocks"" as b Storage = row.StorageId == null ? null : storages?[row.StorageId], Diffs = row.BigMapUpdates == null ? null : diffs?[row.Id], TokenTransfersCount = row.TokenTransfers, + TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }).FirstOrDefault(); } @@ -129,6 +130,7 @@ public async Task> GetMigrations( Storage = row.StorageId == null ? null : storages?[row.StorageId], Diffs = row.BigMapUpdates == null ? null : diffs?[row.Id], TokenTransfersCount = row.TokenTransfers, + TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }); } @@ -170,6 +172,7 @@ public async Task GetMigrations( columns.Add(@"o.""BigMapUpdates"""); break; case "tokenTransfersCount": columns.Add(@"o.""TokenTransfers"""); break; + case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "quote": columns.Add(@"o.""Level"""); break; } } @@ -250,6 +253,10 @@ public async Task GetMigrations( foreach (var row in rows) result[j++][i] = row.TokenTransfers; break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++][i] = row.TicketTransfers; + break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); @@ -295,6 +302,7 @@ public async Task GetMigrations( columns.Add(@"o.""BigMapUpdates"""); break; case "tokenTransfersCount": columns.Add(@"o.""TokenTransfers"""); break; + case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "quote": columns.Add(@"o.""Level"""); break; } @@ -372,6 +380,10 @@ public async Task GetMigrations( foreach (var row in rows) result[j++] = row.TokenTransfers; break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++] = row.TicketTransfers; + break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); diff --git a/Tzkt.Api/Repositories/OperationRepository.Transactions.cs b/Tzkt.Api/Repositories/OperationRepository.Transactions.cs index 4c419c13c..c8d6cb002 100644 --- a/Tzkt.Api/Repositories/OperationRepository.Transactions.cs +++ b/Tzkt.Api/Repositories/OperationRepository.Transactions.cs @@ -115,6 +115,7 @@ INNER JOIN ""Blocks"" as b Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, HasInternals = row.InternalOperations > 0, TokenTransfersCount = row.TokenTransfers, + TicketTransfersCount = row.TicketTransfers, EventsCount = row.EventsCount, Quote = Quotes.Get(quote, row.Level) }); @@ -190,6 +191,7 @@ INNER JOIN ""Blocks"" as b Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, HasInternals = row.InternalOperations > 0, TokenTransfersCount = row.TokenTransfers, + TicketTransfersCount = row.TicketTransfers, EventsCount = row.EventsCount, Quote = Quotes.Get(quote, row.Level) }); @@ -265,6 +267,7 @@ INNER JOIN ""Blocks"" as b Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, HasInternals = row.InternalOperations > 0, TokenTransfersCount = row.TokenTransfers, + TicketTransfersCount = row.TicketTransfers, EventsCount = row.EventsCount, Quote = Quotes.Get(quote, row.Level) }); @@ -319,6 +322,7 @@ public async Task> GetTransactions(Block block Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, HasInternals = row.InternalOperations > 0, TokenTransfersCount = row.TokenTransfers, + TicketTransfersCount = row.TicketTransfers, EventsCount = row.EventsCount, Quote = Quotes.Get(quote, block.Level) }); @@ -448,6 +452,7 @@ INNER JOIN ""Blocks"" as b Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, HasInternals = row.InternalOperations > 0, TokenTransfersCount = row.TokenTransfers, + TicketTransfersCount = row.TicketTransfers, EventsCount = row.EventsCount, Quote = Quotes.Get(quote, row.Level) }); @@ -522,6 +527,7 @@ public async Task GetTransactions( case "errors": columns.Add(@"o.""Errors"""); break; case "hasInternals": columns.Add(@"o.""InternalOperations"""); break; case "tokenTransfersCount": columns.Add(@"o.""TokenTransfers"""); break; + case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "eventsCount": columns.Add(@"o.""EventsCount"""); break; case "block": columns.Add(@"b.""Hash"""); @@ -713,6 +719,10 @@ public async Task GetTransactions( foreach (var row in rows) result[j++][i] = row.TokenTransfers; break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++][i] = row.TicketTransfers; + break; case "eventsCount": foreach (var row in rows) result[j++][i] = row.EventsCount; @@ -799,6 +809,7 @@ public async Task GetTransactions( case "errors": columns.Add(@"o.""Errors"""); break; case "hasInternals": columns.Add(@"o.""InternalOperations"""); break; case "tokenTransfersCount": columns.Add(@"o.""TokenTransfers"""); break; + case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "eventsCount": columns.Add(@"o.""EventsCount"""); break; case "block": columns.Add(@"b.""Hash"""); @@ -987,6 +998,10 @@ public async Task GetTransactions( foreach (var row in rows) result[j++] = row.TokenTransfers; break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++] = row.TicketTransfers; + break; case "eventsCount": foreach (var row in rows) result[j++] = row.EventsCount; diff --git a/Tzkt.Api/Repositories/OperationRepository.TransferTicket.cs b/Tzkt.Api/Repositories/OperationRepository.TransferTicket.cs index 35ec97bc5..6e93e1cc3 100644 --- a/Tzkt.Api/Repositories/OperationRepository.TransferTicket.cs +++ b/Tzkt.Api/Repositories/OperationRepository.TransferTicket.cs @@ -72,6 +72,7 @@ INNER JOIN ""Blocks"" as b }, Status = OpStatuses.ToString(row.Status), Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, + TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }); } @@ -119,6 +120,7 @@ INNER JOIN ""Blocks"" as b }, Status = OpStatuses.ToString(row.Status), Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, + TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }); } @@ -164,6 +166,7 @@ SELECT o.* }, Status = OpStatuses.ToString(row.Status), Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, + TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }); } @@ -240,6 +243,7 @@ INNER JOIN ""Blocks"" as b }, Status = OpStatuses.ToString(row.Status), Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, + TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }); } @@ -299,6 +303,7 @@ public async Task GetTransferTicketOps( columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; + case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "quote": columns.Add(@"o.""Level"""); break; } } @@ -433,6 +438,10 @@ public async Task GetTransferTicketOps( foreach (var row in rows) result[j++][i] = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null; break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++][i] = row.TicketTransfers; + break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); @@ -496,6 +505,7 @@ public async Task GetTransferTicketOps( columns.Add(@"b.""Hash"""); joins.Add(@"INNER JOIN ""Blocks"" as b ON b.""Level"" = o.""Level"""); break; + case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "quote": columns.Add(@"o.""Level"""); break; } @@ -627,6 +637,10 @@ public async Task GetTransferTicketOps( foreach (var row in rows) result[j++] = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null; break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++] = row.TicketTransfers; + break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); diff --git a/Tzkt.Api/Repositories/SmartRollupsRepository.cs b/Tzkt.Api/Repositories/SmartRollupsRepository.cs index d0fcec40b..402c043c9 100644 --- a/Tzkt.Api/Repositories/SmartRollupsRepository.cs +++ b/Tzkt.Api/Repositories/SmartRollupsRepository.cs @@ -40,6 +40,9 @@ async Task> QuerySmartRollupsAsync(SrFilter filter, Paginat r."ActiveTokensCount", r."TokenBalancesCount", r."TokenTransfersCount", + r."ActiveTicketsCount", + r."TicketBalancesCount", + r."TicketTransfersCount", r."TransactionsCount", r."TransferTicketCount", r."SmartRollupCementCount", @@ -80,6 +83,9 @@ async Task> QuerySmartRollupsAsync(SrFilter filter, Paginat case "activeTokensCount": columns.Add(@"r.""ActiveTokensCount"""); break; case "tokenBalancesCount": columns.Add(@"r.""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"r.""TokenTransfersCount"""); break; + case "activeTicketsCount": columns.Add(@"r.""ActiveTicketsCount"""); break; + case "ticketBalancesCount": columns.Add(@"r.""TicketBalancesCount"""); break; + case "ticketTransfersCount": columns.Add(@"r.""TicketTransfersCount"""); break; case "numTransactions": columns.Add(@"r.""TransactionsCount"""); break; case "transferTicketCount": columns.Add(@"r.""TransferTicketCount"""); break; case "smartRollupCementCount": columns.Add(@"r.""SmartRollupCementCount"""); break; @@ -178,6 +184,9 @@ public async Task GetSmartRollup(string address) ActiveTokensCount = rollup.ActiveTokensCount, TokenBalancesCount = rollup.TokenBalancesCount, TokenTransfersCount = rollup.TokenTransfersCount, + ActiveTicketsCount = rollup.ActiveTicketsCount, + TicketBalancesCount = rollup.TicketBalancesCount, + TicketTransfersCount = rollup.TicketTransfersCount, NumTransactions = rollup.TransactionsCount, TransferTicketCount = rollup.TransferTicketCount, SmartRollupCementCount = rollup.SmartRollupCementCount, @@ -220,6 +229,9 @@ public async Task> GetSmartRollups(SrFilter filter, Pag ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + ActiveTicketsCount = row.ActiveTicketsCount, + TicketBalancesCount = row.TicketBalancesCount, + TicketTransfersCount = row.TicketTransfersCount, NumTransactions = row.TransactionsCount, TransferTicketCount = row.TransferTicketCount, SmartRollupCementCount = row.SmartRollupCementCount, @@ -334,6 +346,18 @@ public async Task GetSmartRollups(SrFilter filter, Pagination pagina foreach (var row in rows) result[j++][i] = row.TokenTransfersCount; break; + case "activeTicketsCount": + foreach (var row in rows) + result[j++][i] = row.ActiveTicketsCount; + break; + case "ticketBalancesCount": + foreach (var row in rows) + result[j++][i] = row.TicketBalancesCount; + break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++][i] = row.TicketTransfersCount; + break; case "numTransactions": foreach (var row in rows) result[j++][i] = row.TransactionsCount; diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs new file mode 100644 index 000000000..a6a665b37 --- /dev/null +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -0,0 +1,1008 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Dapper; +using Tzkt.Api.Models; +using Tzkt.Api.Services.Cache; + +namespace Tzkt.Api.Repositories +{ + public class TicketsRepository : DbConnection + { + readonly AccountsCache Accounts; + readonly TimeCache Times; + + public TicketsRepository(AccountsCache accounts, TimeCache times, IConfiguration config) : base(config) + { + Accounts = accounts; + Times = times; + } + + #region tickets + async Task> QueryTicketsAsync(TicketFilter filter, Pagination pagination, List fields = null) + { + var select = "*"; + if (fields != null) + { + var counter = 0; + var columns = new HashSet(fields.Count); + foreach (var field in fields) + { + switch (field.Field) + { + case "id": columns.Add(@"""Id"""); break; + case "contract": columns.Add(@"""ContractId"""); break; + case "balancesCount": columns.Add(@"""BalancesCount"""); break; + case "holdersCount": columns.Add(@"""HoldersCount"""); break; + case "firstMinter": columns.Add(@"""FirstMinterId"""); break; + case "firstLevel": columns.Add(@"""FirstLevel"""); break; + case "firstTime": columns.Add(@"""FirstLevel"""); break; + case "lastLevel": columns.Add(@"""LastLevel"""); break; + case "lastTime": columns.Add(@"""LastLevel"""); break; + case "standard": columns.Add(@"""Tags"""); break; + case "ticketId": columns.Add(@"""TicketId"""); break; + case "totalBurned": columns.Add(@"""TotalBurned"""); break; + case "totalMinted": columns.Add(@"""TotalMinted"""); break; + case "totalSupply": columns.Add(@"""TotalSupply"""); break; + case "transfersCount": columns.Add(@"""TransfersCount"""); break; + case "metadata": + if (field.Path == null) + { + columns.Add(@"""Metadata"""); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"""Metadata"" #> '{{{field.PathString}}}' as {field.Column}"); + } + break; + } + } + + if (columns.Count == 0) + return Enumerable.Empty(); + + select = string.Join(',', columns); + } + + static (string, string) TryMetaSort(string field) + { + if (Regex.IsMatch(field, @"^metadata(\.[\w]+)+$")) + { + var col = $@"""Metadata""#>'{{{field[9..].Replace('.', ',')}}}'"; + return (col, col); + } + return (@"""Id""", @"""Id"""); + } + + var sql = new SqlBuilder($@"SELECT {select} FROM ""Tickets""") + .Filter("Id", filter.id) + .Filter("ContractId", filter.contract) + .Filter("TicketId", filter.ticketId) + .Filter("Tags", filter.ticketId) + .Filter("FirstMinterId", filter.firstMinter) + .Filter("FirstLevel", filter.firstLevel) + .Filter("FirstLevel", filter.firstTime) + .Filter("LastLevel", filter.lastLevel) + .Filter("LastLevel", filter.lastTime) + .Filter("IndexedAt", filter.indexedAt) + .Filter("Metadata", filter.metadata) + .Take(pagination, x => x switch + { + "id" => (@"""Id""", @"""Id"""), + "ticketId" => (@"""TicketId""::numeric", @"""TicketId""::numeric"), + "transfersCount" => (@"""TransfersCount""", @"""TransfersCount"""), + "holdersCount" => (@"""HoldersCount""", @"""HoldersCount"""), + "balancesCount" => (@"""BalancesCount""", @"""BalancesCount"""), + "firstLevel" => (@"""Id""", @"""FirstLevel"""), + "lastLevel" => (@"""LastLevel""", @"""LastLevel"""), + "metadata" => (@"""Metadata""", @"""Metadata"""), + _ => TryMetaSort(x) + }); + + using var db = GetConnection(); + return await db.QueryAsync(sql.Query, sql.Params); + } + + public async Task GetTicketsCount(TicketFilter filter) + { + var sql = new SqlBuilder(@"SELECT COUNT(*) FROM ""Tickets""") + .Filter("Id", filter.id) + .Filter("ContractId", filter.contract) + .Filter("TicketId", filter.ticketId) + .Filter("Tags", filter.ticketId) + .Filter("FirstMinterId", filter.firstMinter) + .Filter("FirstLevel", filter.firstLevel) + .Filter("FirstLevel", filter.firstTime) + .Filter("LastLevel", filter.lastLevel) + .Filter("LastLevel", filter.lastTime) + .Filter("IndexedAt", filter.indexedAt) + .Filter("Metadata", filter.metadata); + + using var db = GetConnection(); + return await db.QueryFirstAsync(sql.Query, sql.Params); + } + + public async Task> GetTickets(TicketFilter filter, Pagination pagination) + { + var rows = await QueryTicketsAsync(filter, pagination); + return rows.Select(row => new Ticket + { + Contract = Accounts.GetAlias(row.ContractId), + Id = row.Id, + BalancesCount = row.BalancesCount, + FirstMinter = Accounts.GetAlias(row.FirstMinterId), + FirstLevel = row.FirstLevel, + FirstTime = Times[row.FirstLevel], + HoldersCount = row.HoldersCount, + LastLevel = row.LastLevel, + LastTime = Times[row.LastLevel], + TicketId = row.TicketId, + TotalBurned = row.TotalBurned, + TotalMinted = row.TotalMinted, + TotalSupply = row.TotalSupply, + TransfersCount = row.TransfersCount, + Metadata = row.Metadata + }); + } + + public async Task GetTickets(TicketFilter filter, Pagination pagination, List fields) + { + var rows = await QueryTicketsAsync(filter, pagination, fields); + + var result = new object[rows.Count()][]; + for (int i = 0; i < result.Length; i++) + result[i] = new object[fields.Count]; + + for (int i = 0, j = 0; i < fields.Count; j = 0, i++) + { + switch (fields[i].Full) + { + case "id": + foreach (var row in rows) + result[j++][i] = row.Id; + break; + case "contract": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.ContractId); + break; + case "contract.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.ContractId).Name; + break; + case "contract.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.ContractId).Address; + break; + case "balancesCount": + foreach (var row in rows) + result[j++][i] = row.BalancesCount; + break; + case "holdersCount": + foreach (var row in rows) + result[j++][i] = row.HoldersCount; + break; + case "firstMinter": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.FirstMinterId); + break; + case "firstMinter.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.FirstMinterId).Name; + break; + case "firstMinter.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.FirstMinterId).Address; + break; + case "firstLevel": + foreach (var row in rows) + result[j++][i] = row.FirstLevel; + break; + case "firstTime": + foreach (var row in rows) + result[j++][i] = Times[row.FirstLevel]; + break; + case "lastLevel": + foreach (var row in rows) + result[j++][i] = row.LastLevel; + break; + case "lastTime": + foreach (var row in rows) + result[j++][i] = Times[row.LastLevel]; + break; + case "ticketId": + foreach (var row in rows) + result[j++][i] = row.TicketId; + break; + case "totalBurned": + foreach (var row in rows) + result[j++][i] = row.TotalBurned; + break; + case "totalMinted": + foreach (var row in rows) + result[j++][i] = row.TotalMinted; + break; + case "totalSupply": + foreach (var row in rows) + result[j++][i] = row.TotalSupply; + break; + case "transfersCount": + foreach (var row in rows) + result[j++][i] = row.TransfersCount; + break; + case "metadata": + foreach (var row in rows) + result[j++][i] = (RawJson)row.Metadata; + break; + default: + if (fields[i].Field == "metadata") + foreach (var row in rows) + result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); + break; + } + } + + return result; + } + #endregion + + #region ticket balances + async Task> QueryTicketBalancesAsync(TicketBalanceFilter filter, Pagination pagination, List fields = null) + { + var select = @" + tb.""Id"", + tb.""AccountId"", + tb.""Balance"", + tb.""FirstLevel"", + tb.""LastLevel"", + tb.""TransfersCount"", + tb.""TicketId"" as ""tId"", + tb.""ContractId"" as ""tContractId"", + t.""TicketId"" as ""tTicketId"", + t.""Tags"" as ""tTags"", + t.""TotalSupply"" as ""tTotalSupply"", + t.""Metadata"" as ""tMetadata"""; + if (fields != null) + { + var counter = 0; + var columns = new HashSet(fields.Count); + foreach (var field in fields) + { + switch (field.Field) + { + case "id": columns.Add(@"tb.""Id"""); break; + case "account": columns.Add(@"tb.""AccountId"""); break; + case "balance": columns.Add(@"tb.""Balance"""); break; + case "firstLevel": columns.Add(@"tb.""FirstLevel"""); break; + case "firstTime": columns.Add(@"tb.""FirstLevel"""); break; + case "lastLevel": columns.Add(@"tb.""LastLevel"""); break; + case "lastTime": columns.Add(@"tb.""LastLevel"""); break; + case "transfersCount": columns.Add(@"tb.""TransfersCount"""); break; + case "ticket": + if (field.Path == null) + { + columns.Add(@"tb.""TicketId"" as ""tId"""); + columns.Add(@"tb.""ContractId"" as ""tContractId"""); + columns.Add(@"t.""TicketId"" as ""tTicketId"""); + columns.Add(@"t.""Tags"" as ""tTags"""); + columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); + columns.Add(@"t.""Metadata"" as ""tMetadata"""); + } + else + { + var subField = field.SubField(); + switch (subField.Field) + { + case "id": columns.Add(@"tb.""TicketId"" as ""tId"""); break; + case "contract": columns.Add(@"tb.""ContractId"" as ""tContractId"""); break; + case "ticketId": columns.Add(@"t.""TicketId"" as ""tTicketId"""); break; + case "standard": columns.Add(@"t.""Tags"" as ""tTags"""); break; + case "totalSupply": columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); break; + case "metadata": + if (subField.Path == null) + { + columns.Add(@"t.""Metadata"" as ""tMetadata"""); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"t.""Metadata"" #> '{{{subField.PathString}}}' as {field.Column}"); + } + break; + } + } + break; + } + } + + if (columns.Count == 0) + return Enumerable.Empty(); + + select = string.Join(',', columns); + } + + static (string, string) TryMetaSort(string field) + { + if (Regex.IsMatch(field, @"^ticket.metadata(\.[\w]+)+$")) + { + var col = $@"t.""Metadata""#>'{{{field[15..].Replace('.', ',')}}}'"; + return (col, col); + } + return (@"tb.""Id""", @"tb.""Id"""); + } + + var sql = new SqlBuilder($@" + SELECT {select} FROM ""TicketBalances"" as tb + INNER JOIN ""Tickets"" AS t ON t.""Id"" = tb.""TicketId""") + .FilterA(@"tb.""Id""", filter.id) + .FilterA(@"tb.""AccountId""", filter.account) + .FilterA(@"tb.""Balance""", filter.balance) + .FilterA(@"tb.""FirstLevel""", filter.firstLevel) + .FilterA(@"tb.""FirstLevel""", filter.firstTime) + .FilterA(@"tb.""LastLevel""", filter.lastLevel) + .FilterA(@"tb.""LastLevel""", filter.lastTime) + .FilterA(@"tb.""IndexedAt""", filter.indexedAt) + .FilterA(@"tb.""TicketId""", filter.ticket.id) + .FilterA(@"tb.""ContractId""", filter.ticket.contract) + .FilterA(@"t.""TicketId""", filter.ticket.ticketId) + .FilterA(@"t.""Metadata""", filter.ticket.metadata) + .Take(pagination, x => x switch + { + "id" => (@"tb.""Id""", @"tb.""Id"""), + "balance" => (@"tb.""Balance""::numeric", @"tb.""Balance""::numeric"), + "transfersCount" => (@"tb.""TransfersCount""", @"tb.""TransfersCount"""), + "firstLevel" => (@"tb.""Id""", @"tb.""FirstLevel"""), + "lastLevel" => (@"tb.""LastLevel""", @"tb.""LastLevel"""), + "ticket.metadata" => (@"t.""Metadata""", @"t.""Metadata"""), + _ => TryMetaSort(x) + }, @"tb.""Id"""); + + using var db = GetConnection(); + return await db.QueryAsync(sql.Query, sql.Params); + } + + public async Task GetTicketBalancesCount(TicketBalanceFilter filter) + { + var sql = new SqlBuilder(@" + SELECT COUNT(*) FROM ""TicketBalances"" as tb + INNER JOIN ""Tickets"" AS t ON t.""Id"" = tb.""TicketId""") + .FilterA(@"tb.""Id""", filter.id) + .FilterA(@"tb.""AccountId""", filter.account) + .FilterA(@"tb.""Balance""", filter.balance) + .FilterA(@"tb.""FirstLevel""", filter.firstLevel) + .FilterA(@"tb.""FirstLevel""", filter.firstTime) + .FilterA(@"tb.""LastLevel""", filter.lastLevel) + .FilterA(@"tb.""LastLevel""", filter.lastTime) + .FilterA(@"tb.""IndexedAt""", filter.indexedAt) + .FilterA(@"tb.""TicketId""", filter.ticket.id) + .FilterA(@"tb.""ContractId""", filter.ticket.contract) + .FilterA(@"t.""TicketId""", filter.ticket.ticketId) + .FilterA(@"t.""Metadata""", filter.ticket.metadata); + + using var db = GetConnection(); + return await db.QueryFirstAsync(sql.Query, sql.Params); + } + + public async Task> GetTicketBalances(TicketBalanceFilter filter, Pagination pagination) + { + var rows = await QueryTicketBalancesAsync(filter, pagination); + return rows.Select(row => new TicketBalance + { + Id = row.Id, + Account = Accounts.GetAlias(row.AccountId), + Balance = row.Balance, + FirstLevel = row.FirstLevel, + FirstTime = Times[row.FirstLevel], + LastLevel = row.LastLevel, + LastTime = Times[row.LastLevel], + TransfersCount = row.TransfersCount, + Ticket = new TicketInfo + { + Id = row.tId, + Contract = Accounts.GetAlias(row.tContractId), + TicketId = row.tTicketId, + TotalSupply = row.tTotalSupply, + Metadata = (RawJson)row.tMetadata + } + }); + } + + public async Task GetTicketBalances(TicketBalanceFilter filter, Pagination pagination, List fields) + { + var rows = await QueryTicketBalancesAsync(filter, pagination, fields); + + var result = new object[rows.Count()][]; + for (int i = 0; i < result.Length; i++) + result[i] = new object[fields.Count]; + + for (int i = 0, j = 0; i < fields.Count; j = 0, i++) + { + switch (fields[i].Full) + { + case "id": + foreach (var row in rows) + result[j++][i] = row.Id; + break; + case "account": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.AccountId); + break; + case "account.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.AccountId).Name; + break; + case "account.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.AccountId).Address; + break; + case "balance": + foreach (var row in rows) + result[j++][i] = row.Balance; + break; + case "firstLevel": + foreach (var row in rows) + result[j++][i] = row.FirstLevel; + break; + case "firstTime": + foreach (var row in rows) + result[j++][i] = Times[row.FirstLevel]; + break; + case "lastLevel": + foreach (var row in rows) + result[j++][i] = row.LastLevel; + break; + case "lastTime": + foreach (var row in rows) + result[j++][i] = Times[row.LastLevel]; + break; + case "transfersCount": + foreach (var row in rows) + result[j++][i] = row.TransfersCount; + break; + case "ticket": + foreach (var row in rows) + result[j++][i] = new TicketInfo + { + Id = row.tId, + Contract = Accounts.GetAlias(row.tContractId), + TicketId = row.tTicketId, + TotalSupply = row.tTotalSupply, + Metadata = (RawJson)row.tMetadata + }; + break; + case "ticket.id": + foreach (var row in rows) + result[j++][i] = row.tId; + break; + case "ticket.contract": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId); + break; + case "ticket.contract.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId).Alias; + break; + case "ticket.contract.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId).Address; + break; + case "ticket.ticketId": + foreach (var row in rows) + result[j++][i] = row.tTicketId; + break; + case "ticket.totalSupply": + foreach (var row in rows) + result[j++][i] = row.tTotalSupply; + break; + case "ticket.metadata": + foreach (var row in rows) + result[j++][i] = (RawJson)row.tMetadata; + break; + default: + if (fields[i].Full.StartsWith("ticket.metadata.")) + foreach (var row in rows) + result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); + break; + } + } + + return result; + } + #endregion + + #region ticket transfers + async Task> QueryTicketTransfersAsync(TicketTransferFilter filter, Pagination pagination, List fields = null) + { + var select = @" + tr.""Id"", + tr.""Level"", + tr.""FromId"", + tr.""ToId"", + tr.""Amount"", + tr.""TransactionId"", + tr.""OriginationId"", + tr.""MigrationId"", + tr.""TicketId"" as ""tId"", + tr.""ContractId"" as ""tContractId"", + t.""TicketId"" as ""tTicketId"", + t.""Tags"" as ""tTags"", + t.""TotalSupply"" as ""tTotalSupply"", + t.""Metadata"" as ""tMetadata"""; + if (fields != null) + { + var counter = 0; + var columns = new HashSet(fields.Count); + foreach (var field in fields) + { + switch (field.Field) + { + case "id": columns.Add(@"tr.""Id"""); break; + case "level": columns.Add(@"tr.""Level"""); break; + case "timestamp": columns.Add(@"tr.""Level"""); break; + case "from": columns.Add(@"tr.""FromId"""); break; + case "to": columns.Add(@"tr.""ToId"""); break; + case "amount": columns.Add(@"tr.""Amount"""); break; + case "transactionId": columns.Add(@"tr.""TransactionId"""); break; + case "originationId": columns.Add(@"tr.""OriginationId"""); break; + case "migrationId": columns.Add(@"tr.""MigrationId"""); break; + case "ticket": + if (field.Path == null) + { + columns.Add(@"tr.""TicketId"" as ""tId"""); + columns.Add(@"tr.""ContractId"" as ""tContractId"""); + columns.Add(@"t.""TicketId"" as ""tTicketId"""); + columns.Add(@"t.""Tags"" as ""tTags"""); + columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); + columns.Add(@"t.""Metadata"" as ""tMetadata"""); + } + else + { + var subField = field.SubField(); + switch (subField.Field) + { + case "id": columns.Add(@"tr.""TicketId"" as ""tId"""); break; + case "contract": columns.Add(@"tr.""ContractId"" as ""tContractId"""); break; + case "ticketId": columns.Add(@"t.""TicketId"" as ""tTicketId"""); break; + case "standard": columns.Add(@"t.""Tags"" as ""tTags"""); break; + case "totalSupply": columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); break; + case "metadata": + if (subField.Path == null) + { + columns.Add(@"t.""Metadata"" as ""tMetadata"""); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"t.""Metadata"" #> '{{{subField.PathString}}}' as {field.Column}"); + } + break; + } + } + break; + } + } + + if (columns.Count == 0) + return Enumerable.Empty(); + + select = string.Join(',', columns); + } + + static (string, string) TryMetaSort(string field) + { + if (Regex.IsMatch(field, @"^ticket.metadata(\.[\w]+)+$")) + { + var col = $@"t.""Metadata""#>'{{{field[15..].Replace('.', ',')}}}'"; + return (col, col); + } + return (@"tr.""Id""", @"tr.""Id"""); + } + + var sql = new SqlBuilder($@" + SELECT {select} FROM ""TicketTransfers"" as tr + INNER JOIN ""Tickets"" AS t ON t.""Id"" = tr.""TicketId""") + .FilterA(@"tr.""Id""", filter.id) + .FilterA(@"tr.""Level""", filter.level) + .FilterA(@"tr.""Level""", filter.timestamp) + .FilterA(@"tr.""IndexedAt""", filter.indexedAt) + .FilterA(filter.anyof, x => x == "from" ? @"tr.""FromId""" : @"tr.""ToId""") + .FilterA(@"tr.""FromId""", filter.from) + .FilterA(@"tr.""ToId""", filter.to) + .FilterA(@"tr.""Amount""", filter.amount) + .FilterA(@"tr.""TransactionId""", filter.transactionId) + .FilterA(@"tr.""OriginationId""", filter.originationId) + .FilterA(@"tr.""MigrationId""", filter.migrationId) + .FilterA(@"tr.""TicketId""", filter.ticket.id) + .FilterA(@"tr.""ContractId""", filter.ticket.contract) + .FilterA(@"t.""TicketId""", filter.ticket.ticketId) + .FilterA(@"t.""Metadata""", filter.ticket.metadata) + .Take(pagination, x => x switch + { + "id" => (@"tr.""Id""", @"tr.""Id"""), + "level" => (@"tr.""Level""", @"tr.""Level"""), + "amount" => (@"tr.""Amount""::numeric", @"tr.""Amount""::numeric"), + "ticket.metadata" => (@"t.""Metadata""", @"t.""Metadata"""), + _ => TryMetaSort(x) + }, @"tr.""Id"""); + + using var db = GetConnection(); + return await db.QueryAsync(sql.Query, sql.Params); + } + + public async Task GetTicketTransfersCount(TicketTransferFilter filter) + { + var sql = new SqlBuilder(@" + SELECT COUNT(*) FROM ""TicketTransfers"" as tr + INNER JOIN ""Tickets"" AS t ON t.""Id"" = tr.""TicketId""") + .FilterA(@"tr.""Id""", filter.id) + .FilterA(@"tr.""Level""", filter.level) + .FilterA(@"tr.""Level""", filter.timestamp) + .FilterA(@"tr.""IndexedAt""", filter.indexedAt) + .FilterA(filter.anyof, x => x == "from" ? @"tr.""FromId""" : @"tr.""ToId""") + .FilterA(@"tr.""FromId""", filter.from) + .FilterA(@"tr.""ToId""", filter.to) + .FilterA(@"tr.""Amount""", filter.amount) + .FilterA(@"tr.""TransactionId""", filter.transactionId) + .FilterA(@"tr.""OriginationId""", filter.originationId) + .FilterA(@"tr.""MigrationId""", filter.migrationId) + .FilterA(@"tr.""TicketId""", filter.ticket.id) + .FilterA(@"tr.""ContractId""", filter.ticket.contract) + .FilterA(@"t.""TicketId""", filter.ticket.ticketId) + .FilterA(@"t.""Metadata""", filter.ticket.metadata); + + using var db = GetConnection(); + return await db.QueryFirstAsync(sql.Query, sql.Params); + } + + public async Task> GetTicketTransfers(TicketTransferFilter filter, Pagination pagination) + { + var rows = await QueryTicketTransfersAsync(filter, pagination); + return rows.Select(row => new TicketTransfer + { + Id = row.Id, + Level = row.Level, + Timestamp = Times[row.Level], + From = row.FromId == null ? null : Accounts.GetAlias(row.FromId), + To = row.ToId == null ? null : Accounts.GetAlias(row.ToId), + Amount = row.Amount, + TransactionId = row.TransactionId, + OriginationId = row.OriginationId, + MigrationId = row.MigrationId, + Ticket = new TicketInfo + { + Id = row.tId, + Contract = Accounts.GetAlias(row.tContractId), + TicketId = row.tTicketId, + TotalSupply = row.tTotalSupply, + Metadata = (RawJson)row.tMetadata + } + }); + } + + public async Task GetTicketTransfers(TicketTransferFilter filter, Pagination pagination, List fields) + { + var rows = await QueryTicketTransfersAsync(filter, pagination, fields); + + var result = new object[rows.Count()][]; + for (int i = 0; i < result.Length; i++) + result[i] = new object[fields.Count]; + + for (int i = 0, j = 0; i < fields.Count; j = 0, i++) + { + switch (fields[i].Full) + { + case "id": + foreach (var row in rows) + result[j++][i] = row.Id; + break; + case "level": + foreach (var row in rows) + result[j++][i] = row.Level; + break; + case "timestamp": + foreach (var row in rows) + result[j++][i] = Times[row.Level]; + break; + case "from": + foreach (var row in rows) + result[j++][i] = row.FromId == null ? null : Accounts.GetAlias(row.FromId); + break; + case "from.alias": + foreach (var row in rows) + result[j++][i] = row.FromId == null ? null : Accounts.GetAlias(row.FromId).Name; + break; + case "from.address": + foreach (var row in rows) + result[j++][i] = row.FromId == null ? null : Accounts.GetAlias(row.FromId).Address; + break; + case "to": + foreach (var row in rows) + result[j++][i] = row.ToId == null ? null : Accounts.GetAlias(row.ToId); + break; + case "to.alias": + foreach (var row in rows) + result[j++][i] = row.ToId == null ? null : Accounts.GetAlias(row.ToId).Name; + break; + case "to.address": + foreach (var row in rows) + result[j++][i] = row.ToId == null ? null : Accounts.GetAlias(row.ToId).Address; + break; + case "amount": + foreach (var row in rows) + result[j++][i] = row.Amount; + break; + case "transactionId": + foreach (var row in rows) + result[j++][i] = row.TransactionId; + break; + case "originationId": + foreach (var row in rows) + result[j++][i] = row.OriginationId; + break; + case "migrationId": + foreach (var row in rows) + result[j++][i] = row.MigrationId; + break; + case "ticket": + foreach (var row in rows) + result[j++][i] = new TicketInfo + { + Id = row.tId, + Contract = Accounts.GetAlias(row.tContractId), + TicketId = row.tTicketId, + TotalSupply = row.tTotalSupply, + Metadata = (RawJson)row.tMetadata + }; + break; + case "ticket.id": + foreach (var row in rows) + result[j++][i] = row.tId; + break; + case "ticket.contract": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId); + break; + case "ticket.contract.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId).Alias; + break; + case "ticket.contract.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId).Address; + break; + case "ticket.ticketId": + foreach (var row in rows) + result[j++][i] = row.tTicketId; + break; + case "ticket.standard": + case "ticket.totalSupply": + foreach (var row in rows) + result[j++][i] = row.tTotalSupply; + break; + case "ticket.metadata": + foreach (var row in rows) + result[j++][i] = (RawJson)row.tMetadata; + break; + default: + if (fields[i].Full.StartsWith("ticket.metadata.")) + foreach (var row in rows) + result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); + break; + } + } + + return result; + } + #endregion + + #region historical balances + async Task> QueryHistoricalTicketBalancesAsync(int level, TicketBalanceShortFilter filter, Pagination pagination, List fields = null) + { + var select = @" + tb.""AccountId"", + tb.""Balance"", + tb.""TicketId"" as ""tId"", + t.""ContractId"" as ""tContractId"", + t.""TicketId"" as ""tTicketId"", + t.""Tags"" as ""tTags"", + t.""Metadata"" as ""tMetadata"""; + if (fields != null) + { + var counter = 0; + var columns = new HashSet(fields.Count); + foreach (var field in fields) + { + switch (field.Field) + { + case "account": columns.Add(@"tb.""AccountId"""); break; + case "balance": columns.Add(@"tb.""Balance"""); break; + case "ticket": + if (field.Path == null) + { + columns.Add(@"tb.""TicketId"" as ""tId"""); + columns.Add(@"t.""ContractId"" as ""tContractId"""); + columns.Add(@"t.""TicketId"" as ""tTicketId"""); + columns.Add(@"t.""Tags"" as ""tTags"""); + columns.Add(@"t.""Metadata"" as ""tMetadata"""); + } + else + { + var subField = field.SubField(); + switch (subField.Field) + { + case "id": columns.Add(@"tb.""TicketId"" as ""tId"""); break; + case "contract": columns.Add(@"t.""ContractId"" as ""tContractId"""); break; + case "ticketId": columns.Add(@"t.""TicketId"" as ""tTicketId"""); break; + case "standard": columns.Add(@"t.""Tags"" as ""tTags"""); break; + case "metadata": + if (subField.Path == null) + { + columns.Add(@"t.""Metadata"" as ""tMetadata"""); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"t.""Metadata"" #> '{{{subField.PathString}}}' as {field.Column}"); + } + break; + } + } + break; + } + } + + if (columns.Count == 0) + return Enumerable.Empty(); + + select = string.Join(',', columns); + } + + static (string, string) TryMetaSort(string field) + { + if (Regex.IsMatch(field, @"^ticket.metadata(\.[\w]+)+$")) + { + var col = $@"t.""Metadata""#>'{{{field[15..].Replace('.', ',')}}}'"; + return (col, col); + } + return (@"tb.""Id""", @"tb.""Id"""); + } + + var sql = new SqlBuilder() + .Append($@"SELECT {select} FROM (") + .Append(@"SELECT ROW_NUMBER() over (ORDER BY ""TicketId"", ""AccountId"") as ""Id"", ""TicketId"", ""AccountId"", SUM(""Amount"")::text AS ""Balance"" FROM (") + + .Append(@"SELECT tr.""TicketId"", tr.""FromId"" AS ""AccountId"", -tr.""Amount""::numeric AS ""Amount"" FROM ""TicketTransfers"" as tr") + .Append(@"INNER JOIN ""Tickets"" AS t ON t.""Id"" = tr.""TicketId""") + .Filter($@"tr.""Level"" <= {level}") + .Filter($@"tr.""FromId"" IS NOT NULL") + .FilterA(@"tr.""FromId""", filter.account) + .FilterA(@"tr.""TicketId""", filter.ticket.id) + .FilterA(@"t.""ContractId""", filter.ticket.contract) + .FilterA(@"t.""TicketId""", filter.ticket.ticketId) + .FilterA(@"t.""Metadata""", filter.ticket.metadata) + .ResetFilters() + + .Append("UNION ALL") + + .Append(@"SELECT tr.""TicketId"", tr.""ToId"" AS ""AccountId"", tr.""Amount""::numeric AS ""Amount"" FROM ""TicketTransfers"" as tr") + .Append(@"INNER JOIN ""Tickets"" AS t ON t.""Id"" = tr.""TicketId""") + .Filter($@"tr.""Level"" <= {level}") + .Filter($@"tr.""ToId"" IS NOT NULL") + .FilterA(@"tr.""ToId""", filter.account) + .FilterA(@"tr.""TicketId""", filter.ticket.id) + .FilterA(@"t.""ContractId""", filter.ticket.contract) + .FilterA(@"t.""TicketId""", filter.ticket.ticketId) + .FilterA(@"t.""Metadata""", filter.ticket.metadata) + .ResetFilters() + + .Append(") as tb") + .Append(@"GROUP BY tb.""TicketId"", tb.""AccountId""") + .Append(") as tb") + .Append(@"INNER JOIN ""Tickets"" AS t ON t.""Id"" = tb.""TicketId""") + .FilterA(@"tb.""Balance""", filter.balance) + .Take(pagination, x => x switch + { + "balance" => (@"""Balance""::numeric", @"""Balance""::numeric"), + "ticket.metadata" => (@"t.""Metadata""", @"t.""Metadata"""), + _ => TryMetaSort(x) + }, @"tb.""Id"""); + + using var db = GetConnection(); + return await db.QueryAsync(sql.Query, sql.Params); + } + + public async Task> GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination) + { + var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination); + return rows.Select(row => new TicketBalanceShort + { + Account = Accounts.GetAlias(row.AccountId), + Balance = row.Balance, + Ticket = new TicketInfo + { + Id = row.tId, + Contract = Accounts.GetAlias(row.tContractId), + TicketId = row.tTicketId, + Metadata = (RawJson)row.tMetadata + } + }); + } + + public async Task GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination, List fields) + { + var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination, fields); + + var result = new object[rows.Count()][]; + for (int i = 0; i < result.Length; i++) + result[i] = new object[fields.Count]; + + for (int i = 0, j = 0; i < fields.Count; j = 0, i++) + { + switch (fields[i].Full) + { + case "account": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.AccountId); + break; + case "account.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.AccountId).Name; + break; + case "account.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.AccountId).Address; + break; + case "balance": + foreach (var row in rows) + result[j++][i] = row.Balance; + break; + case "ticket": + foreach (var row in rows) + result[j++][i] = new TicketInfo + { + Id = row.tId, + Contract = Accounts.GetAlias(row.tContractId), + TicketId = row.tTicketId, + Metadata = (RawJson)row.tMetadata + }; + break; + case "ticket.id": + foreach (var row in rows) + result[j++][i] = row.tId; + break; + case "ticket.contract": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId); + break; + case "ticket.contract.alias": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId).Alias; + break; + case "ticket.contract.address": + foreach (var row in rows) + result[j++][i] = Accounts.GetAlias(row.tContractId).Address; + break; + case "ticket.ticketId": + foreach (var row in rows) + result[j++][i] = row.tTicketId; + break; + case "ticket.metadata": + foreach (var row in rows) + result[j++][i] = (RawJson)row.tMetadata; + break; + default: + if (fields[i].Full.StartsWith("ticket.metadata.")) + foreach (var row in rows) + result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); + break; + } + } + + return result; + } + #endregion + } +} diff --git a/Tzkt.Api/Services/Cache/Accounts/Models/RawAccount.cs b/Tzkt.Api/Services/Cache/Accounts/Models/RawAccount.cs index c952d3b8c..5f3fdff23 100644 --- a/Tzkt.Api/Services/Cache/Accounts/Models/RawAccount.cs +++ b/Tzkt.Api/Services/Cache/Accounts/Models/RawAccount.cs @@ -20,6 +20,9 @@ public class RawAccount public int ActiveTokensCount { get; set; } public int TokenBalancesCount { get; set; } public int TokenTransfersCount { get; set; } + public int ActiveTicketsCount { get; set; } + public int TicketBalancesCount { get; set; } + public int TicketTransfersCount { get; set; } public int DelegationsCount { get; set; } public int OriginationsCount { get; set; } diff --git a/Tzkt.Api/Services/Cache/Accounts/Models/RawContract.cs b/Tzkt.Api/Services/Cache/Accounts/Models/RawContract.cs index 0ea6a9c73..cc06a53bd 100644 --- a/Tzkt.Api/Services/Cache/Accounts/Models/RawContract.cs +++ b/Tzkt.Api/Services/Cache/Accounts/Models/RawContract.cs @@ -7,6 +7,7 @@ public class RawContract : RawAccount public int CodeHash { get; set; } public int Tags { get; set; } public int TokensCount { get; set; } + public int TicketsCount { get; set; } public int EventsCount { get; set; } public int? CreatorId { get; set; } diff --git a/Tzkt.Api/Services/Cache/State/RawModels/RawState.cs b/Tzkt.Api/Services/Cache/State/RawModels/RawState.cs index a98343d38..49e3cac44 100644 --- a/Tzkt.Api/Services/Cache/State/RawModels/RawState.cs +++ b/Tzkt.Api/Services/Cache/State/RawModels/RawState.cs @@ -76,6 +76,9 @@ public class RawState public int TokensCount { get; set; } public int TokenBalancesCount { get; set; } public int TokenTransfersCount { get; set; } + public int TicketsCount { get; set; } + public int TicketBalancesCount { get; set; } + public int TicketTransfersCount { get; set; } public int EventsCount { get; set; } #endregion diff --git a/Tzkt.Api/Swagger/Swagger.cs b/Tzkt.Api/Swagger/Swagger.cs index 8a69f39bc..0d9e00d3f 100644 --- a/Tzkt.Api/Swagger/Swagger.cs +++ b/Tzkt.Api/Swagger/Swagger.cs @@ -13,6 +13,8 @@ public static void AddOpenApiDocument(this IServiceCollection services) options.OperationProcessors.Add(new TzktExtensionProcessor()); options.OperationProcessors.Add(new AnyOfExtensionProcessor("Tokens_GetTokenTransfers", "from,to")); options.OperationProcessors.Add(new AnyOfExtensionProcessor("Tokens_GetTokenTransfersCount", "from,to")); + options.OperationProcessors.Add(new AnyOfExtensionProcessor("Tickets_GetTicketTransfers", "from,to")); + options.OperationProcessors.Add(new AnyOfExtensionProcessor("Tickets_GetTicketTransfersCount", "from,to")); options.PostProcess = document => { document.Info.Title = "TzKT API"; diff --git a/Tzkt.Data/Models/Scripts/TicketBalance.cs b/Tzkt.Data/Models/Scripts/TicketBalance.cs index d975ae576..0221fbeb8 100644 --- a/Tzkt.Data/Models/Scripts/TicketBalance.cs +++ b/Tzkt.Data/Models/Scripts/TicketBalance.cs @@ -8,6 +8,8 @@ namespace Tzkt.Data.Models public class TicketBalance { public long Id { get; set; } + + //TODO Do we need ticketer here? public int TicketerId { get; set; } public long TicketId { get; set; } public int AccountId { get; set; } diff --git a/Tzkt.Data/Models/Scripts/TicketTransfer.cs b/Tzkt.Data/Models/Scripts/TicketTransfer.cs index a4c34ce19..dcee75914 100644 --- a/Tzkt.Data/Models/Scripts/TicketTransfer.cs +++ b/Tzkt.Data/Models/Scripts/TicketTransfer.cs @@ -18,6 +18,8 @@ public class TicketTransfer public long? TransferTicketId { get; set; } public long? TransactionId { get; set; } public long? SmartRollupExecuteId { get; set; } + + //TODO Do we need to add MigrationId here? public long? MigrationId { get; set; } } From 2779407ea8195173b5c07775568f000ae04b56cd Mon Sep 17 00:00:00 2001 From: dmir Date: Tue, 15 Aug 2023 20:46:35 +0300 Subject: [PATCH 28/51] WIP API --- Tzkt.Api/Controllers/TicketsController.cs | 69 ++- Tzkt.Api/Models/Tickets/Ticket.cs | 13 + Tzkt.Api/Parameters/TicketBalanceFilter.cs | 5 +- Tzkt.Api/Parameters/TicketFilter.cs | 30 +- Tzkt.Api/Parameters/TicketInfoFilter.cs | 21 +- Tzkt.Api/Parameters/TicketTransferFilter.cs | 13 +- Tzkt.Api/Repositories/TicketsRepository.cs | 523 +++++++------------- 7 files changed, 242 insertions(+), 432 deletions(-) diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index 0be07609d..b56d454f8 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -36,16 +36,15 @@ public TicketsController(TicketsRepository tickets, StateCache state, ResponseCa [HttpGet("count")] public async Task> GetTicketsCount([FromQuery] TicketFilter filter) { - if (filter.contract != null || - filter.metadata != null || + if (filter.ticketer != null || filter.firstTime != null || filter.firstMinter != null || filter.firstLevel != null || filter.lastTime != null || filter.lastLevel != null || - filter.ticketId != null || - filter.id != null || - filter.indexedAt != null) + filter.сontentHash != null || + filter.сontentTypeHash != null || + filter.id != null ) { var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); @@ -74,10 +73,11 @@ public async Task> GetTicketsCount([FromQuery] TicketFilter fi public async Task>> GetTickets( [FromQuery] TicketFilter filter, [FromQuery] Pagination pagination, - [FromQuery] Selection selection) + [FromQuery] Selection selection, + MichelineFormat micheline = MichelineFormat.Json) { var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("filter", filter), ("pagination", pagination), ("selection", selection)); + ("filter", filter), ("pagination", pagination), ("selection", selection), ("micheline", micheline)); if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); @@ -85,14 +85,14 @@ public async Task>> GetTickets( object res; if (selection.select == null) { - res = await Tickets.GetTickets(filter, pagination); + res = await Tickets.GetTickets(filter, pagination, micheline); } else { res = new SelectionResponse { Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), - Rows = await Tickets.GetTickets(filter, pagination, selection.select.Fields ?? selection.select.Values) + Rows = await Tickets.GetTickets(filter, pagination, micheline, selection.select.Fields ?? selection.select.Values) }; } cached = ResponseCache.Set(query, res); @@ -118,12 +118,9 @@ public async Task> GetTicketBalancesCount([FromQuery] TicketBa filter.firstLevel != null || filter.lastTime != null || filter.lastLevel != null || - filter.indexedAt != null || filter.id != null || filter.ticket.id != null || - filter.ticket.contract != null || - filter.ticket.ticketId != null || - filter.ticket.metadata != null) + filter.ticket.ticketer != null) { #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) @@ -157,7 +154,8 @@ public async Task> GetTicketBalancesCount([FromQuery] TicketBa public async Task>> GetTicketBalances( [FromQuery] TicketBalanceFilter filter, [FromQuery] Pagination pagination, - [FromQuery] Selection selection) + [FromQuery] Selection selection, + MichelineFormat micheline = MichelineFormat.Json) { #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) @@ -165,7 +163,7 @@ public async Task>> GetTicketBalances( #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("filter", filter), ("pagination", pagination), ("selection", selection)); + ("filter", filter), ("pagination", pagination), ("selection", selection), ("micheline", micheline)); if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); @@ -173,14 +171,14 @@ public async Task>> GetTicketBalances( object res; if (selection.select == null) { - res = await Tickets.GetTicketBalances(filter, pagination); + res = await Tickets.GetTicketBalances(filter, pagination, micheline); } else { res = new SelectionResponse { Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), - Rows = await Tickets.GetTicketBalances(filter, pagination, selection.select.Fields ?? selection.select.Values) + Rows = await Tickets.GetTicketBalances(filter, pagination, micheline, selection.select.Fields ?? selection.select.Values) }; } cached = ResponseCache.Set(query, res); @@ -208,13 +206,10 @@ public async Task> GetTicketTransfersCount([FromQuery] TicketT filter.amount != null || filter.id != null || filter.transactionId != null || - filter.originationId != null || - filter.migrationId != null || - filter.indexedAt != null || - filter.ticket.id != null || - filter.ticket.contract != null || - filter.ticket.ticketId != null || - filter.ticket.metadata != null) + filter.transferTicketId != null || + filter.smartRollupExecuteId != null || + filter.ticket.ticketer != null || + filter.ticket.id != null) { #region optimizations if (filter.from != null && (filter.from.Eq == -1 || filter.from.In?.Count == 0 && !filter.from.InHasNull)) @@ -254,7 +249,8 @@ public async Task> GetTicketTransfersCount([FromQuery] TicketT public async Task>> GetTicketTransfers( [FromQuery] TicketTransferFilter filter, [FromQuery] Pagination pagination, - [FromQuery] Selection selection) + [FromQuery] Selection selection, + MichelineFormat micheline = MichelineFormat.Json) { #region optimizations if (filter.from != null && (filter.from.Eq == -1 || filter.from.In?.Count == 0 && !filter.from.InHasNull)) @@ -268,7 +264,7 @@ public async Task>> GetTicketTransfers( #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("filter", filter), ("pagination", pagination), ("selection", selection)); + ("filter", filter), ("pagination", pagination), ("selection", selection), ("micheline", micheline)); if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); @@ -276,14 +272,14 @@ public async Task>> GetTicketTransfers( object res; if (selection.select == null) { - res = await Tickets.GetTicketTransfers(filter, pagination); + res = await Tickets.GetTicketTransfers(filter, pagination, micheline); } else { res = new SelectionResponse { Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), - Rows = await Tickets.GetTicketTransfers(filter, pagination, selection.select.Fields ?? selection.select.Values) + Rows = await Tickets.GetTicketTransfers(filter, pagination, micheline, selection.select.Fields ?? selection.select.Values) }; } cached = ResponseCache.Set(query, res); @@ -298,7 +294,7 @@ public async Task>> GetTicketTransfers( /// /// Returns a list of ticket balances at the end of the specified block. /// Note, this endpoint is quite heavy, therefore at least one of the filters - /// (`account`, `ticket.id`, `ticket.contract` with `ticket.ticketId`) must be specified. + /// (`account`, `ticket.id`, `ticket.ticketer`) must be specified. /// /// Level of the block at the end of which historical balances must be calculated /// Filter @@ -309,15 +305,16 @@ public async Task>> GetTicketTransfers( public async Task>> GetTicketBalances(int level, [FromQuery] TicketBalanceShortFilter filter, [FromQuery] Pagination pagination, - [FromQuery] Selection selection) + [FromQuery] Selection selection, + MichelineFormat micheline = MichelineFormat.Json) { if (filter.account?.Eq == null && filter.account?.In == null && filter.ticket.id?.Eq == null && filter.ticket.id?.In == null && - (filter.ticket.contract?.Eq == null && filter.ticket.contract?.In == null || - filter.ticket.ticketId?.Eq == null && filter.ticket.ticketId?.In == null)) - return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.contract` with `ticket.ticketId`) must be specified"); + filter.ticket.ticketer?.Eq == null && + filter.ticket.ticketer?.In == null) + return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.ticketer`) must be specified"); #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) @@ -325,7 +322,7 @@ public async Task>> GetTicketBalanc #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("filter", filter), ("pagination", pagination), ("selection", selection)); + ("filter", filter), ("pagination", pagination), ("selection", selection), ("micheline", micheline)); if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); @@ -333,14 +330,14 @@ public async Task>> GetTicketBalanc object res; if (selection.select == null) { - res = await Tickets.GetHistoricalTicketBalances(level, filter, pagination); + res = await Tickets.GetHistoricalTicketBalances(level, filter, pagination, micheline); } else { res = new SelectionResponse { Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), - Rows = await Tickets.GetHistoricalTicketBalances(level, filter, pagination, selection.select.Fields ?? selection.select.Values) + Rows = await Tickets.GetHistoricalTicketBalances(level, filter, pagination, micheline, selection.select.Fields ?? selection.select.Values) }; } cached = ResponseCache.Set(query, res); diff --git a/Tzkt.Api/Models/Tickets/Ticket.cs b/Tzkt.Api/Models/Tickets/Ticket.cs index 3db3f0723..68f232888 100644 --- a/Tzkt.Api/Models/Tickets/Ticket.cs +++ b/Tzkt.Api/Models/Tickets/Ticket.cs @@ -26,6 +26,19 @@ public class Ticket /// Ticket content /// public object Content { get; set; } + + + /// + /// 32-bit hash of the ticket content type. + /// This field can be used for searching similar tickets (which have the same type). + /// + public int ContentTypeHash { get; set; } + + /// + /// 32-bit hash of the ticket content. + /// This field can be used for searching same tickets (which have the same content). + /// + public int ContentHash { get; set; } /// /// Account, minted the ticket first. diff --git a/Tzkt.Api/Parameters/TicketBalanceFilter.cs b/Tzkt.Api/Parameters/TicketBalanceFilter.cs index 92c6611a2..74f352f9a 100644 --- a/Tzkt.Api/Parameters/TicketBalanceFilter.cs +++ b/Tzkt.Api/Parameters/TicketBalanceFilter.cs @@ -53,14 +53,11 @@ public class TicketBalanceFilter : INormalizable /// public TimestampParameter lastTime { get; set; } - [JsonIgnore] - public Int32NullParameter indexedAt { get; set; } - public string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("account", account), ("ticket", ticket), ("balance", balance), ("firstLevel", firstLevel), - ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("indexedAt", indexedAt)); + ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime)); } } } diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs index 113f884f3..0902a7baf 100644 --- a/Tzkt.Api/Parameters/TicketFilter.cs +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -12,16 +12,10 @@ public class TicketFilter : INormalizable public Int64Parameter id { get; set; } /// - /// Filter by contract address. + /// Filter by ticketer address. /// Click on the parameter to expand more details. /// - public AccountParameter contract { get; set; } - - /// - /// Filter by ticketId (for FA1.2 tickets ticketId is always `"0"`). - /// Click on the parameter to expand more details. - /// - public NatParameter ticketId { get; set; } + public AccountParameter ticketer { get; set; } /// /// Filter by address of the first minter. @@ -52,23 +46,25 @@ public class TicketFilter : INormalizable /// Click on the parameter to expand more details. /// public TimestampParameter lastTime { get; set; } - + /// - /// Filter by metadata. - /// Note, this parameter supports the following format: `metadata{.path?}{.mode?}=...`, - /// so you can specify a path to a particular field to filter by (for example, `?metadata.symbol.in=kUSD,uUSD`). + /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). /// Click on the parameter to expand more details. /// - public JsonParameter metadata { get; set; } + public Int32Parameter сontentHash { get; set; } - [JsonIgnore] - public Int32NullParameter indexedAt { get; set; } + /// + /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). + /// Click on the parameter to expand more details. + /// + public Int32Parameter сontentTypeHash { get; set; } + public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("contract", contract), ("ticketId", ticketId), ("firstMinter", firstMinter), ("firstLevel", firstLevel), - ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("metadata", metadata), ("indexedAt", indexedAt)); + ("id", id), ("ticketer", ticketer), ("firstMinter", firstMinter), ("firstLevel", firstLevel), + ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("сontentHash", сontentHash), ("сontentTypeHash", сontentTypeHash)); } } } diff --git a/Tzkt.Api/Parameters/TicketInfoFilter.cs b/Tzkt.Api/Parameters/TicketInfoFilter.cs index f6c89fd33..9e15b8983 100644 --- a/Tzkt.Api/Parameters/TicketInfoFilter.cs +++ b/Tzkt.Api/Parameters/TicketInfoFilter.cs @@ -6,34 +6,21 @@ namespace Tzkt.Api public class TicketInfoFilter : INormalizable { /// - /// Filter by internal TzKT id. Note, this is not the same as `ticketId`. + /// Filter by internal TzKT id. /// Click on the parameter to expand more details. /// public Int64Parameter id { get; set; } /// - /// Filter by contract address. + /// Filter by ticketer address. /// Click on the parameter to expand more details. /// - public AccountParameter contract { get; set; } - - /// - /// Filter by ticketId (for FA1.2 tickets ticketId is always `"0"`). - /// Click on the parameter to expand more details. - /// - public NatParameter ticketId { get; set; } - - /// - /// Filter by metadata. Note, this parameter supports the following format: `ticket.metadata{.path?}{.mode?}=...`, - /// so you can specify a path to a particular field to filter by, for example: `?ticket.metadata.symbol.in=kUSD,uUSD`. - /// Click on the parameter to expand more details. - /// - public JsonParameter metadata { get; set; } + public AccountParameter ticketer { get; set; } public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("contract", contract), ("ticketId", ticketId), ("metadata", metadata)); + ("id", id), ("ticketer", ticketer)); } } } diff --git a/Tzkt.Api/Parameters/TicketTransferFilter.cs b/Tzkt.Api/Parameters/TicketTransferFilter.cs index 8acfdf54c..5f2a1fd16 100644 --- a/Tzkt.Api/Parameters/TicketTransferFilter.cs +++ b/Tzkt.Api/Parameters/TicketTransferFilter.cs @@ -62,25 +62,22 @@ public class TicketTransferFilter : INormalizable public Int64NullParameter transactionId { get; set; } /// - /// Filter by id of the origination, caused the ticket transfer. + /// Filter by id of the transfer ticket operation,, caused the ticket transfer. /// Click on the parameter to expand more details. /// - public Int64NullParameter originationId { get; set; } + public Int64NullParameter transferTicketId { get; set; } /// - /// Filter by id of the migration, caused the ticket transfer. + /// Filter by id of the smart rollup execute operation, caused the ticket transfer. /// Click on the parameter to expand more details. /// - public Int64NullParameter migrationId { get; set; } - - [JsonIgnore] - public Int32NullParameter indexedAt { get; set; } + public Int64NullParameter smartRollupExecuteId { get; set; } public string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("level", level), ("timestamp", timestamp), ("ticket", ticket), ("anyof", anyof), ("from", from), ("to", to), - ("amount", amount), ("transactionId", transactionId), ("originationId", originationId), ("migrationId", migrationId), ("indexedAt", indexedAt)); + ("amount", amount), ("transactionId", transactionId), ("transferTicketId", transferTicketId), ("smartRollupExecuteId", smartRollupExecuteId)); } } } diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index a6a665b37..25a032501 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Dapper; +using Netezos.Encoding; using Tzkt.Api.Models; using Tzkt.Api.Services.Cache; @@ -22,7 +23,7 @@ public TicketsRepository(AccountsCache accounts, TimeCache times, IConfiguration } #region tickets - async Task> QueryTicketsAsync(TicketFilter filter, Pagination pagination, List fields = null) + async Task> QueryTicketsAsync(TicketFilter filter, Pagination pagination, MichelineFormat format, List fields = null) { var select = "*"; if (fields != null) @@ -34,30 +35,30 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati switch (field.Field) { case "id": columns.Add(@"""Id"""); break; - case "contract": columns.Add(@"""ContractId"""); break; - case "balancesCount": columns.Add(@"""BalancesCount"""); break; - case "holdersCount": columns.Add(@"""HoldersCount"""); break; + case "ticketer": columns.Add(@"""TicketerId"""); break; case "firstMinter": columns.Add(@"""FirstMinterId"""); break; case "firstLevel": columns.Add(@"""FirstLevel"""); break; case "firstTime": columns.Add(@"""FirstLevel"""); break; case "lastLevel": columns.Add(@"""LastLevel"""); break; case "lastTime": columns.Add(@"""LastLevel"""); break; - case "standard": columns.Add(@"""Tags"""); break; - case "ticketId": columns.Add(@"""TicketId"""); break; - case "totalBurned": columns.Add(@"""TotalBurned"""); break; + case "transfersCount": columns.Add(@"""TransfersCount"""); break; + case "balancesCount": columns.Add(@"""BalancesCount"""); break; + case "holdersCount": columns.Add(@"""HoldersCount"""); break; case "totalMinted": columns.Add(@"""TotalMinted"""); break; + case "totalBurned": columns.Add(@"""TotalBurned"""); break; case "totalSupply": columns.Add(@"""TotalSupply"""); break; - case "transfersCount": columns.Add(@"""TransfersCount"""); break; - case "metadata": - if (field.Path == null) - { - columns.Add(@"""Metadata"""); - } - else + case "contentHash": columns.Add(@"o.""ContentHash"""); break; + case "contentTypeHash": columns.Add(@"o.""ContentTypeHash"""); break; + case "contentType": columns.Add(@"o.""RawType"""); break; + case "content": + columns.Add(format switch { - field.Column = $"c{counter++}"; - columns.Add($@"""Metadata"" #> '{{{field.PathString}}}' as {field.Column}"); - } + MichelineFormat.Json => @"o.""JsonContent""", + MichelineFormat.JsonString => @"o.""JsonContent""", + MichelineFormat.Raw => @"o.""RawContent""", + MichelineFormat.RawString => @"o.""RawContent""", + _ => throw new Exception("Invalid MichelineFormat value") + }); break; } } @@ -68,31 +69,18 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati select = string.Join(',', columns); } - static (string, string) TryMetaSort(string field) - { - if (Regex.IsMatch(field, @"^metadata(\.[\w]+)+$")) - { - var col = $@"""Metadata""#>'{{{field[9..].Replace('.', ',')}}}'"; - return (col, col); - } - return (@"""Id""", @"""Id"""); - } - var sql = new SqlBuilder($@"SELECT {select} FROM ""Tickets""") .Filter("Id", filter.id) - .Filter("ContractId", filter.contract) - .Filter("TicketId", filter.ticketId) - .Filter("Tags", filter.ticketId) + .Filter("TicketerId", filter.ticketer) .Filter("FirstMinterId", filter.firstMinter) .Filter("FirstLevel", filter.firstLevel) .Filter("FirstLevel", filter.firstTime) .Filter("LastLevel", filter.lastLevel) .Filter("LastLevel", filter.lastTime) - .Filter("IndexedAt", filter.indexedAt) - .Filter("Metadata", filter.metadata) + .Filter("ContentTypeHash", filter.сontentTypeHash) + .Filter("ContentHash", filter.сontentHash) .Take(pagination, x => x switch { - "id" => (@"""Id""", @"""Id"""), "ticketId" => (@"""TicketId""::numeric", @"""TicketId""::numeric"), "transfersCount" => (@"""TransfersCount""", @"""TransfersCount"""), "holdersCount" => (@"""HoldersCount""", @"""HoldersCount"""), @@ -100,7 +88,7 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati "firstLevel" => (@"""Id""", @"""FirstLevel"""), "lastLevel" => (@"""LastLevel""", @"""LastLevel"""), "metadata" => (@"""Metadata""", @"""Metadata"""), - _ => TryMetaSort(x) + _ => (@"""Id""", @"""Id""") }); using var db = GetConnection(); @@ -111,27 +99,25 @@ public async Task GetTicketsCount(TicketFilter filter) { var sql = new SqlBuilder(@"SELECT COUNT(*) FROM ""Tickets""") .Filter("Id", filter.id) - .Filter("ContractId", filter.contract) - .Filter("TicketId", filter.ticketId) - .Filter("Tags", filter.ticketId) + .Filter("TicketerId", filter.ticketer) .Filter("FirstMinterId", filter.firstMinter) .Filter("FirstLevel", filter.firstLevel) .Filter("FirstLevel", filter.firstTime) .Filter("LastLevel", filter.lastLevel) .Filter("LastLevel", filter.lastTime) - .Filter("IndexedAt", filter.indexedAt) - .Filter("Metadata", filter.metadata); + .Filter("ContentTypeHash", filter.сontentTypeHash) + .Filter("ContentHash", filter.сontentHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); } - public async Task> GetTickets(TicketFilter filter, Pagination pagination) + public async Task> GetTickets(TicketFilter filter, Pagination pagination, MichelineFormat format) { - var rows = await QueryTicketsAsync(filter, pagination); + var rows = await QueryTicketsAsync(filter, pagination, format); return rows.Select(row => new Ticket { - Contract = Accounts.GetAlias(row.ContractId), + Ticketer = Accounts.GetAlias(row.TicketerId), Id = row.Id, BalancesCount = row.BalancesCount, FirstMinter = Accounts.GetAlias(row.FirstMinterId), @@ -140,18 +126,27 @@ public async Task> GetTickets(TicketFilter filter, Paginatio HoldersCount = row.HoldersCount, LastLevel = row.LastLevel, LastTime = Times[row.LastLevel], - TicketId = row.TicketId, TotalBurned = row.TotalBurned, TotalMinted = row.TotalMinted, TotalSupply = row.TotalSupply, TransfersCount = row.TransfersCount, - Metadata = row.Metadata + ContentType = (RawJson)Micheline.ToJson(row.RawType), + Content = format switch + { + MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), + _ => throw new Exception("Invalid MichelineFormat value") + }, + ContentHash = row.ContentHash, + ContentTypeHash = row.ContentTypeHash }); } - public async Task GetTickets(TicketFilter filter, Pagination pagination, List fields) + public async Task GetTickets(TicketFilter filter, Pagination pagination, MichelineFormat format, List fields) { - var rows = await QueryTicketsAsync(filter, pagination, fields); + var rows = await QueryTicketsAsync(filter, pagination, format, fields); var result = new object[rows.Count()][]; for (int i = 0; i < result.Length; i++) @@ -165,25 +160,40 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat foreach (var row in rows) result[j++][i] = row.Id; break; - case "contract": + case "ticketer": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.ContractId); + result[j++][i] = Accounts.GetAlias(row.TicketerId); break; - case "contract.alias": + case "ticketer.alias": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.ContractId).Name; + result[j++][i] = Accounts.GetAlias(row.TicketerId).Name; break; - case "contract.address": + case "ticketer.address": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.ContractId).Address; + result[j++][i] = Accounts.GetAlias(row.TicketerId).Address; break; - case "balancesCount": + case "contentType": foreach (var row in rows) - result[j++][i] = row.BalancesCount; + result[j++][i] = (RawJson)Micheline.ToJson(row.RawType); break; - case "holdersCount": + case "content": foreach (var row in rows) - result[j++][i] = row.HoldersCount; + result[j++][i] = format switch + { + MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), + _ => throw new Exception("Invalid MichelineFormat value") + }; + break; + case "contentTypeHash": + foreach (var row in rows) + result[j++][i] = row.ContentTypeHash; + break; + case "contentHash": + foreach (var row in rows) + result[j++][i] = row.ContentType; break; case "firstMinter": foreach (var row in rows) @@ -213,34 +223,29 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat foreach (var row in rows) result[j++][i] = Times[row.LastLevel]; break; - case "ticketId": + case "transfersCount": foreach (var row in rows) - result[j++][i] = row.TicketId; + result[j++][i] = row.TransfersCount; break; - case "totalBurned": + case "balancesCount": foreach (var row in rows) - result[j++][i] = row.TotalBurned; + result[j++][i] = row.BalancesCount; break; - case "totalMinted": + case "holdersCount": foreach (var row in rows) - result[j++][i] = row.TotalMinted; + result[j++][i] = row.HoldersCount; break; - case "totalSupply": + case "totalMinted": foreach (var row in rows) - result[j++][i] = row.TotalSupply; + result[j++][i] = row.TotalMinted; break; - case "transfersCount": + case "totalBurned": foreach (var row in rows) - result[j++][i] = row.TransfersCount; + result[j++][i] = row.TotalBurned; break; - case "metadata": + case "totalSupply": foreach (var row in rows) - result[j++][i] = (RawJson)row.Metadata; - break; - default: - if (fields[i].Field == "metadata") - foreach (var row in rows) - result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); + result[j++][i] = row.TotalSupply; break; } } @@ -250,7 +255,7 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat #endregion #region ticket balances - async Task> QueryTicketBalancesAsync(TicketBalanceFilter filter, Pagination pagination, List fields = null) + async Task> QueryTicketBalancesAsync(TicketBalanceFilter filter, Pagination pagination, MichelineFormat format, List fields = null) { var select = @" tb.""Id"", @@ -260,11 +265,8 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi tb.""LastLevel"", tb.""TransfersCount"", tb.""TicketId"" as ""tId"", - tb.""ContractId"" as ""tContractId"", - t.""TicketId"" as ""tTicketId"", - t.""Tags"" as ""tTags"", - t.""TotalSupply"" as ""tTotalSupply"", - t.""Metadata"" as ""tMetadata"""; + tb.""TicketerId"" as ""tTicketerId"", + t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { var counter = 0; @@ -282,38 +284,19 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi case "lastTime": columns.Add(@"tb.""LastLevel"""); break; case "transfersCount": columns.Add(@"tb.""TransfersCount"""); break; case "ticket": - if (field.Path == null) - { - columns.Add(@"tb.""TicketId"" as ""tId"""); - columns.Add(@"tb.""ContractId"" as ""tContractId"""); - columns.Add(@"t.""TicketId"" as ""tTicketId"""); - columns.Add(@"t.""Tags"" as ""tTags"""); - columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); - columns.Add(@"t.""Metadata"" as ""tMetadata"""); - } - else + columns.Add(@"""Id"""); + columns.Add(@"""TicketerId"""); + columns.Add(format switch { - var subField = field.SubField(); - switch (subField.Field) - { - case "id": columns.Add(@"tb.""TicketId"" as ""tId"""); break; - case "contract": columns.Add(@"tb.""ContractId"" as ""tContractId"""); break; - case "ticketId": columns.Add(@"t.""TicketId"" as ""tTicketId"""); break; - case "standard": columns.Add(@"t.""Tags"" as ""tTags"""); break; - case "totalSupply": columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); break; - case "metadata": - if (subField.Path == null) - { - columns.Add(@"t.""Metadata"" as ""tMetadata"""); - } - else - { - field.Column = $"c{counter++}"; - columns.Add($@"t.""Metadata"" #> '{{{subField.PathString}}}' as {field.Column}"); - } - break; - } - } + MichelineFormat.Json => @"o.""JsonContent""", + MichelineFormat.JsonString => @"o.""JsonContent""", + MichelineFormat.Raw => @"o.""RawContent""", + MichelineFormat.RawString => @"o.""RawContent""", + _ => throw new Exception("Invalid MichelineFormat value") + }); + columns.Add(@"o.""ContentHash"""); + columns.Add(@"o.""ContentTypeHash"""); + columns.Add(@"o.""RawType"""); break; } } @@ -323,17 +306,7 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi select = string.Join(',', columns); } - - static (string, string) TryMetaSort(string field) - { - if (Regex.IsMatch(field, @"^ticket.metadata(\.[\w]+)+$")) - { - var col = $@"t.""Metadata""#>'{{{field[15..].Replace('.', ',')}}}'"; - return (col, col); - } - return (@"tb.""Id""", @"tb.""Id"""); - } - + var sql = new SqlBuilder($@" SELECT {select} FROM ""TicketBalances"" as tb INNER JOIN ""Tickets"" AS t ON t.""Id"" = tb.""TicketId""") @@ -344,20 +317,16 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi .FilterA(@"tb.""FirstLevel""", filter.firstTime) .FilterA(@"tb.""LastLevel""", filter.lastLevel) .FilterA(@"tb.""LastLevel""", filter.lastTime) - .FilterA(@"tb.""IndexedAt""", filter.indexedAt) .FilterA(@"tb.""TicketId""", filter.ticket.id) - .FilterA(@"tb.""ContractId""", filter.ticket.contract) - .FilterA(@"t.""TicketId""", filter.ticket.ticketId) - .FilterA(@"t.""Metadata""", filter.ticket.metadata) + .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) .Take(pagination, x => x switch { - "id" => (@"tb.""Id""", @"tb.""Id"""), "balance" => (@"tb.""Balance""::numeric", @"tb.""Balance""::numeric"), "transfersCount" => (@"tb.""TransfersCount""", @"tb.""TransfersCount"""), "firstLevel" => (@"tb.""Id""", @"tb.""FirstLevel"""), "lastLevel" => (@"tb.""LastLevel""", @"tb.""LastLevel"""), "ticket.metadata" => (@"t.""Metadata""", @"t.""Metadata"""), - _ => TryMetaSort(x) + _ => (@"tb.""Id""", @"tb.""Id""") }, @"tb.""Id"""); using var db = GetConnection(); @@ -376,19 +345,16 @@ SELECT COUNT(*) FROM ""TicketBalances"" as tb .FilterA(@"tb.""FirstLevel""", filter.firstTime) .FilterA(@"tb.""LastLevel""", filter.lastLevel) .FilterA(@"tb.""LastLevel""", filter.lastTime) - .FilterA(@"tb.""IndexedAt""", filter.indexedAt) .FilterA(@"tb.""TicketId""", filter.ticket.id) - .FilterA(@"tb.""ContractId""", filter.ticket.contract) - .FilterA(@"t.""TicketId""", filter.ticket.ticketId) - .FilterA(@"t.""Metadata""", filter.ticket.metadata); + .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); } - public async Task> GetTicketBalances(TicketBalanceFilter filter, Pagination pagination) + public async Task> GetTicketBalances(TicketBalanceFilter filter, Pagination pagination, MichelineFormat format) { - var rows = await QueryTicketBalancesAsync(filter, pagination); + var rows = await QueryTicketBalancesAsync(filter, pagination, format); return rows.Select(row => new TicketBalance { Id = row.Id, @@ -402,17 +368,15 @@ public async Task> GetTicketBalances(TicketBalanceFil Ticket = new TicketInfo { Id = row.tId, - Contract = Accounts.GetAlias(row.tContractId), - TicketId = row.tTicketId, - TotalSupply = row.tTotalSupply, - Metadata = (RawJson)row.tMetadata + Ticketer = Accounts.GetAlias(row.tTicketerId), + TotalSupply = row.tTotalSupply } }); } - public async Task GetTicketBalances(TicketBalanceFilter filter, Pagination pagination, List fields) + public async Task GetTicketBalances(TicketBalanceFilter filter, Pagination pagination, MichelineFormat format, List fields) { - var rows = await QueryTicketBalancesAsync(filter, pagination, fields); + var rows = await QueryTicketBalancesAsync(filter, pagination, format, fields); var result = new object[rows.Count()][]; for (int i = 0; i < result.Length; i++) @@ -467,45 +431,30 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi result[j++][i] = new TicketInfo { Id = row.tId, - Contract = Accounts.GetAlias(row.tContractId), - TicketId = row.tTicketId, - TotalSupply = row.tTotalSupply, - Metadata = (RawJson)row.tMetadata + Ticketer = Accounts.GetAlias(row.tTicketerId), + TotalSupply = row.tTotalSupply }; break; case "ticket.id": foreach (var row in rows) result[j++][i] = row.tId; break; - case "ticket.contract": - foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId); - break; - case "ticket.contract.alias": + case "ticket.ticketer": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId).Alias; + result[j++][i] = Accounts.GetAlias(row.tTicketerId); break; - case "ticket.contract.address": + case "ticket.ticketer.alias": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId).Address; + result[j++][i] = Accounts.GetAlias(row.tTicketerId).Alias; break; - case "ticket.ticketId": + case "ticket.ticketer.address": foreach (var row in rows) - result[j++][i] = row.tTicketId; + result[j++][i] = Accounts.GetAlias(row.tTicketerId).Address; break; case "ticket.totalSupply": foreach (var row in rows) result[j++][i] = row.tTotalSupply; break; - case "ticket.metadata": - foreach (var row in rows) - result[j++][i] = (RawJson)row.tMetadata; - break; - default: - if (fields[i].Full.StartsWith("ticket.metadata.")) - foreach (var row in rows) - result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); - break; } } @@ -514,7 +463,7 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi #endregion #region ticket transfers - async Task> QueryTicketTransfersAsync(TicketTransferFilter filter, Pagination pagination, List fields = null) + async Task> QueryTicketTransfersAsync(TicketTransferFilter filter, Pagination pagination, MichelineFormat format, List fields = null) { var select = @" tr.""Id"", @@ -523,14 +472,10 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter tr.""ToId"", tr.""Amount"", tr.""TransactionId"", - tr.""OriginationId"", - tr.""MigrationId"", - tr.""TicketId"" as ""tId"", - tr.""ContractId"" as ""tContractId"", - t.""TicketId"" as ""tTicketId"", - t.""Tags"" as ""tTags"", - t.""TotalSupply"" as ""tTotalSupply"", - t.""Metadata"" as ""tMetadata"""; + tr.""TransferTicketId"", + tr.""SmartRollupExecuteId"", + tr.""TicketerId"" as ""tTicketerId"", + t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { var counter = 0; @@ -546,41 +491,22 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter case "to": columns.Add(@"tr.""ToId"""); break; case "amount": columns.Add(@"tr.""Amount"""); break; case "transactionId": columns.Add(@"tr.""TransactionId"""); break; - case "originationId": columns.Add(@"tr.""OriginationId"""); break; - case "migrationId": columns.Add(@"tr.""MigrationId"""); break; + case "transferTicketId": columns.Add(@"tr.""TransferTicketId"""); break; + case "smartRollupExecuteId": columns.Add(@"tr.""SmartRollupExecuteId"""); break; case "ticket": - if (field.Path == null) - { - columns.Add(@"tr.""TicketId"" as ""tId"""); - columns.Add(@"tr.""ContractId"" as ""tContractId"""); - columns.Add(@"t.""TicketId"" as ""tTicketId"""); - columns.Add(@"t.""Tags"" as ""tTags"""); - columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); - columns.Add(@"t.""Metadata"" as ""tMetadata"""); - } - else + columns.Add(@"""Id"""); + columns.Add(@"""TicketerId"""); + columns.Add(format switch { - var subField = field.SubField(); - switch (subField.Field) - { - case "id": columns.Add(@"tr.""TicketId"" as ""tId"""); break; - case "contract": columns.Add(@"tr.""ContractId"" as ""tContractId"""); break; - case "ticketId": columns.Add(@"t.""TicketId"" as ""tTicketId"""); break; - case "standard": columns.Add(@"t.""Tags"" as ""tTags"""); break; - case "totalSupply": columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); break; - case "metadata": - if (subField.Path == null) - { - columns.Add(@"t.""Metadata"" as ""tMetadata"""); - } - else - { - field.Column = $"c{counter++}"; - columns.Add($@"t.""Metadata"" #> '{{{subField.PathString}}}' as {field.Column}"); - } - break; - } - } + MichelineFormat.Json => @"o.""JsonContent""", + MichelineFormat.JsonString => @"o.""JsonContent""", + MichelineFormat.Raw => @"o.""RawContent""", + MichelineFormat.RawString => @"o.""RawContent""", + _ => throw new Exception("Invalid MichelineFormat value") + }); + columns.Add(@"o.""ContentHash"""); + columns.Add(@"o.""ContentTypeHash"""); + columns.Add(@"o.""RawType"""); break; } } @@ -591,41 +517,26 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter select = string.Join(',', columns); } - static (string, string) TryMetaSort(string field) - { - if (Regex.IsMatch(field, @"^ticket.metadata(\.[\w]+)+$")) - { - var col = $@"t.""Metadata""#>'{{{field[15..].Replace('.', ',')}}}'"; - return (col, col); - } - return (@"tr.""Id""", @"tr.""Id"""); - } - var sql = new SqlBuilder($@" SELECT {select} FROM ""TicketTransfers"" as tr INNER JOIN ""Tickets"" AS t ON t.""Id"" = tr.""TicketId""") .FilterA(@"tr.""Id""", filter.id) .FilterA(@"tr.""Level""", filter.level) .FilterA(@"tr.""Level""", filter.timestamp) - .FilterA(@"tr.""IndexedAt""", filter.indexedAt) .FilterA(filter.anyof, x => x == "from" ? @"tr.""FromId""" : @"tr.""ToId""") .FilterA(@"tr.""FromId""", filter.from) .FilterA(@"tr.""ToId""", filter.to) .FilterA(@"tr.""Amount""", filter.amount) .FilterA(@"tr.""TransactionId""", filter.transactionId) - .FilterA(@"tr.""OriginationId""", filter.originationId) - .FilterA(@"tr.""MigrationId""", filter.migrationId) + .FilterA(@"tr.""TransferTicketId""", filter.transferTicketId) + .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) - .FilterA(@"tr.""ContractId""", filter.ticket.contract) - .FilterA(@"t.""TicketId""", filter.ticket.ticketId) - .FilterA(@"t.""Metadata""", filter.ticket.metadata) + .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) .Take(pagination, x => x switch { - "id" => (@"tr.""Id""", @"tr.""Id"""), "level" => (@"tr.""Level""", @"tr.""Level"""), "amount" => (@"tr.""Amount""::numeric", @"tr.""Amount""::numeric"), - "ticket.metadata" => (@"t.""Metadata""", @"t.""Metadata"""), - _ => TryMetaSort(x) + _ => (@"tr.""Id""", @"tr.""Id""") }, @"tr.""Id"""); using var db = GetConnection(); @@ -640,26 +551,23 @@ SELECT COUNT(*) FROM ""TicketTransfers"" as tr .FilterA(@"tr.""Id""", filter.id) .FilterA(@"tr.""Level""", filter.level) .FilterA(@"tr.""Level""", filter.timestamp) - .FilterA(@"tr.""IndexedAt""", filter.indexedAt) .FilterA(filter.anyof, x => x == "from" ? @"tr.""FromId""" : @"tr.""ToId""") .FilterA(@"tr.""FromId""", filter.from) .FilterA(@"tr.""ToId""", filter.to) .FilterA(@"tr.""Amount""", filter.amount) .FilterA(@"tr.""TransactionId""", filter.transactionId) - .FilterA(@"tr.""OriginationId""", filter.originationId) - .FilterA(@"tr.""MigrationId""", filter.migrationId) + .FilterA(@"tr.""TransferTicketId""", filter.transferTicketId) + .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) - .FilterA(@"tr.""ContractId""", filter.ticket.contract) - .FilterA(@"t.""TicketId""", filter.ticket.ticketId) - .FilterA(@"t.""Metadata""", filter.ticket.metadata); + .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); } - public async Task> GetTicketTransfers(TicketTransferFilter filter, Pagination pagination) + public async Task> GetTicketTransfers(TicketTransferFilter filter, Pagination pagination, MichelineFormat format) { - var rows = await QueryTicketTransfersAsync(filter, pagination); + var rows = await QueryTicketTransfersAsync(filter, pagination, format); return rows.Select(row => new TicketTransfer { Id = row.Id, @@ -669,22 +577,20 @@ public async Task> GetTicketTransfers(TicketTransfer To = row.ToId == null ? null : Accounts.GetAlias(row.ToId), Amount = row.Amount, TransactionId = row.TransactionId, - OriginationId = row.OriginationId, - MigrationId = row.MigrationId, + TransferTicketId = row.TransferTicketId, + SmartRollupExecuteId = row.SmartRollupExecuteId, Ticket = new TicketInfo { Id = row.tId, - Contract = Accounts.GetAlias(row.tContractId), - TicketId = row.tTicketId, + Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - Metadata = (RawJson)row.tMetadata } }); } - public async Task GetTicketTransfers(TicketTransferFilter filter, Pagination pagination, List fields) + public async Task GetTicketTransfers(TicketTransferFilter filter, Pagination pagination, MichelineFormat format, List fields) { - var rows = await QueryTicketTransfersAsync(filter, pagination, fields); + var rows = await QueryTicketTransfersAsync(filter, pagination, format, fields); var result = new object[rows.Count()][]; for (int i = 0; i < result.Length; i++) @@ -738,11 +644,11 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa foreach (var row in rows) result[j++][i] = row.TransactionId; break; - case "originationId": + case "transferTicketId": foreach (var row in rows) result[j++][i] = row.OriginationId; break; - case "migrationId": + case "smartRollupExecuteId": foreach (var row in rows) result[j++][i] = row.MigrationId; break; @@ -751,46 +657,30 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa result[j++][i] = new TicketInfo { Id = row.tId, - Contract = Accounts.GetAlias(row.tContractId), - TicketId = row.tTicketId, - TotalSupply = row.tTotalSupply, - Metadata = (RawJson)row.tMetadata + Ticketer = Accounts.GetAlias(row.tTicketerId), + TotalSupply = row.tTotalSupply }; break; case "ticket.id": foreach (var row in rows) result[j++][i] = row.tId; break; - case "ticket.contract": + case "ticket.ticketer": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId); + result[j++][i] = Accounts.GetAlias(row.tTicketerId); break; - case "ticket.contract.alias": + case "ticket.ticketer.alias": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId).Alias; + result[j++][i] = Accounts.GetAlias(row.tTicketerId).Alias; break; - case "ticket.contract.address": + case "ticket.ticketer.address": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId).Address; + result[j++][i] = Accounts.GetAlias(row.tTicketerId).Address; break; - case "ticket.ticketId": - foreach (var row in rows) - result[j++][i] = row.tTicketId; - break; - case "ticket.standard": case "ticket.totalSupply": foreach (var row in rows) result[j++][i] = row.tTotalSupply; break; - case "ticket.metadata": - foreach (var row in rows) - result[j++][i] = (RawJson)row.tMetadata; - break; - default: - if (fields[i].Full.StartsWith("ticket.metadata.")) - foreach (var row in rows) - result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); - break; } } @@ -799,16 +689,13 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa #endregion #region historical balances - async Task> QueryHistoricalTicketBalancesAsync(int level, TicketBalanceShortFilter filter, Pagination pagination, List fields = null) + async Task> QueryHistoricalTicketBalancesAsync(int level, TicketBalanceShortFilter filter, Pagination pagination, MichelineFormat format, List fields = null) { var select = @" tb.""AccountId"", tb.""Balance"", tb.""TicketId"" as ""tId"", - t.""ContractId"" as ""tContractId"", - t.""TicketId"" as ""tTicketId"", - t.""Tags"" as ""tTags"", - t.""Metadata"" as ""tMetadata"""; + t.""TicketerId"" as ""tTicketerId"""; if (fields != null) { var counter = 0; @@ -820,36 +707,8 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T case "account": columns.Add(@"tb.""AccountId"""); break; case "balance": columns.Add(@"tb.""Balance"""); break; case "ticket": - if (field.Path == null) - { - columns.Add(@"tb.""TicketId"" as ""tId"""); - columns.Add(@"t.""ContractId"" as ""tContractId"""); - columns.Add(@"t.""TicketId"" as ""tTicketId"""); - columns.Add(@"t.""Tags"" as ""tTags"""); - columns.Add(@"t.""Metadata"" as ""tMetadata"""); - } - else - { - var subField = field.SubField(); - switch (subField.Field) - { - case "id": columns.Add(@"tb.""TicketId"" as ""tId"""); break; - case "contract": columns.Add(@"t.""ContractId"" as ""tContractId"""); break; - case "ticketId": columns.Add(@"t.""TicketId"" as ""tTicketId"""); break; - case "standard": columns.Add(@"t.""Tags"" as ""tTags"""); break; - case "metadata": - if (subField.Path == null) - { - columns.Add(@"t.""Metadata"" as ""tMetadata"""); - } - else - { - field.Column = $"c{counter++}"; - columns.Add($@"t.""Metadata"" #> '{{{subField.PathString}}}' as {field.Column}"); - } - break; - } - } + columns.Add(@"tb.""TicketId"" as ""tId"""); + columns.Add(@"t.""TicketerId"" as ""tTicketerId"""); break; } } @@ -860,16 +719,6 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T select = string.Join(',', columns); } - static (string, string) TryMetaSort(string field) - { - if (Regex.IsMatch(field, @"^ticket.metadata(\.[\w]+)+$")) - { - var col = $@"t.""Metadata""#>'{{{field[15..].Replace('.', ',')}}}'"; - return (col, col); - } - return (@"tb.""Id""", @"tb.""Id"""); - } - var sql = new SqlBuilder() .Append($@"SELECT {select} FROM (") .Append(@"SELECT ROW_NUMBER() over (ORDER BY ""TicketId"", ""AccountId"") as ""Id"", ""TicketId"", ""AccountId"", SUM(""Amount"")::text AS ""Balance"" FROM (") @@ -880,9 +729,7 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T .Filter($@"tr.""FromId"" IS NOT NULL") .FilterA(@"tr.""FromId""", filter.account) .FilterA(@"tr.""TicketId""", filter.ticket.id) - .FilterA(@"t.""ContractId""", filter.ticket.contract) - .FilterA(@"t.""TicketId""", filter.ticket.ticketId) - .FilterA(@"t.""Metadata""", filter.ticket.metadata) + .FilterA(@"t.""TicketerId""", filter.ticket.ticketer) .ResetFilters() .Append("UNION ALL") @@ -893,9 +740,7 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T .Filter($@"tr.""ToId"" IS NOT NULL") .FilterA(@"tr.""ToId""", filter.account) .FilterA(@"tr.""TicketId""", filter.ticket.id) - .FilterA(@"t.""ContractId""", filter.ticket.contract) - .FilterA(@"t.""TicketId""", filter.ticket.ticketId) - .FilterA(@"t.""Metadata""", filter.ticket.metadata) + .FilterA(@"t.""TicketerId""", filter.ticket.ticketer) .ResetFilters() .Append(") as tb") @@ -903,20 +748,15 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T .Append(") as tb") .Append(@"INNER JOIN ""Tickets"" AS t ON t.""Id"" = tb.""TicketId""") .FilterA(@"tb.""Balance""", filter.balance) - .Take(pagination, x => x switch - { - "balance" => (@"""Balance""::numeric", @"""Balance""::numeric"), - "ticket.metadata" => (@"t.""Metadata""", @"t.""Metadata"""), - _ => TryMetaSort(x) - }, @"tb.""Id"""); + .Take(pagination, _ => (@"""Balance""::numeric", @"""Balance""::numeric"), @"tb.""Id"""); using var db = GetConnection(); return await db.QueryAsync(sql.Query, sql.Params); } - public async Task> GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination) + public async Task> GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination, MichelineFormat format) { - var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination); + var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination, format); return rows.Select(row => new TicketBalanceShort { Account = Accounts.GetAlias(row.AccountId), @@ -924,16 +764,14 @@ public async Task> GetHistoricalTicketBalances(i Ticket = new TicketInfo { Id = row.tId, - Contract = Accounts.GetAlias(row.tContractId), - TicketId = row.tTicketId, - Metadata = (RawJson)row.tMetadata + Ticketer = Accounts.GetAlias(row.tContractId) } }); } - public async Task GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination, List fields) + public async Task GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination, MichelineFormat format, List fields) { - var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination, fields); + var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination, format, fields); var result = new object[rows.Count()][]; for (int i = 0; i < result.Length; i++) @@ -964,39 +802,24 @@ public async Task GetHistoricalTicketBalances(int level, TicketBalan result[j++][i] = new TicketInfo { Id = row.tId, - Contract = Accounts.GetAlias(row.tContractId), - TicketId = row.tTicketId, - Metadata = (RawJson)row.tMetadata + Ticketer = Accounts.GetAlias(row.tTicketerId) }; break; case "ticket.id": foreach (var row in rows) result[j++][i] = row.tId; break; - case "ticket.contract": + case "ticket.ticketer": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId); + result[j++][i] = Accounts.GetAlias(row.tTicketerId); break; - case "ticket.contract.alias": + case "ticket.ticketer.alias": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId).Alias; + result[j++][i] = Accounts.GetAlias(row.tTicketerId).Alias; break; - case "ticket.contract.address": + case "ticket.ticketer.address": foreach (var row in rows) - result[j++][i] = Accounts.GetAlias(row.tContractId).Address; - break; - case "ticket.ticketId": - foreach (var row in rows) - result[j++][i] = row.tTicketId; - break; - case "ticket.metadata": - foreach (var row in rows) - result[j++][i] = (RawJson)row.tMetadata; - break; - default: - if (fields[i].Full.StartsWith("ticket.metadata.")) - foreach (var row in rows) - result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); + result[j++][i] = Accounts.GetAlias(row.tTicketerId).Address; break; } } From 6564cd9bfc4375f9302463f0e85f4b50aef85299 Mon Sep 17 00:00:00 2001 From: dmir Date: Fri, 18 Aug 2023 17:44:09 +0300 Subject: [PATCH 29/51] WIP Filters --- Tzkt.Api/Controllers/TicketsController.cs | 6 +- Tzkt.Api/Models/Tickets/TicketInfo.cs | 12 + Tzkt.Api/Parameters/TicketFilter.cs | 18 +- Tzkt.Api/Parameters/TicketInfoFilter.cs | 15 +- Tzkt.Api/Repositories/TicketsRepository.cs | 207 +++++++++++++++--- ....cs => 20230818112210_Tickets.Designer.cs} | 10 +- ...9_Tickets.cs => 20230818112210_Tickets.cs} | 9 +- .../Migrations/TzktContextModelSnapshot.cs | 8 +- Tzkt.Data/Models/Scripts/TIcket.cs | 9 + .../Commits/Operations/TransactionsCommit.cs | 1 + .../Operations/TransferTicketCommit.cs | 37 +--- .../Operations/SmartRollupExecuteCommit.cs | 2 + .../Handlers/Proto16/Commits/TicketsCommit.cs | 1 + Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs | 1 + 14 files changed, 260 insertions(+), 76 deletions(-) rename Tzkt.Data/Migrations/{20230814170139_Tickets.Designer.cs => 20230818112210_Tickets.Designer.cs} (99%) rename Tzkt.Data/Migrations/{20230814170139_Tickets.cs => 20230818112210_Tickets.cs} (96%) diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index b56d454f8..0eb914a25 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -44,6 +44,8 @@ public async Task> GetTicketsCount([FromQuery] TicketFilter fi filter.lastLevel != null || filter.сontentHash != null || filter.сontentTypeHash != null || + filter.content != null || + filter.contentType != null || filter.id != null ) { var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); @@ -120,7 +122,9 @@ public async Task> GetTicketBalancesCount([FromQuery] TicketBa filter.lastLevel != null || filter.id != null || filter.ticket.id != null || - filter.ticket.ticketer != null) + filter.ticket.ticketer != null || + filter.ticket.сontentHash != null || + filter.ticket.сontentTypeHash != null) { #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) diff --git a/Tzkt.Api/Models/Tickets/TicketInfo.cs b/Tzkt.Api/Models/Tickets/TicketInfo.cs index aabb5b4ad..da283e631 100644 --- a/Tzkt.Api/Models/Tickets/TicketInfo.cs +++ b/Tzkt.Api/Models/Tickets/TicketInfo.cs @@ -23,6 +23,18 @@ public class TicketInfo /// Ticket content /// public object Content { get; set; } + + /// + /// 32-bit hash of the ticket content type. + /// This field can be used for searching similar tickets (which have the same type). + /// + public int ContentTypeHash { get; set; } + + /// + /// 32-bit hash of the ticket content. + /// This field can be used for searching same tickets (which have the same content). + /// + public int ContentHash { get; set; } /// /// Total number of existing tickets (raw value, not divided by `decimals`). In historical ticket balances this field is omitted. diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs index 0902a7baf..539b9bc52 100644 --- a/Tzkt.Api/Parameters/TicketFilter.cs +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -58,13 +58,29 @@ public class TicketFilter : INormalizable /// Click on the parameter to expand more details. /// public Int32Parameter сontentTypeHash { get; set; } + + /// + /// Filter by content. + /// Note, this parameter supports the following format: `content{.path?}{.mode?}=...`, + /// so you can specify a path to a particular field to filter by (for example, `?content.foo.in=Token`). + /// Click on the parameter to expand more details. + /// + public JsonParameter content { get; set; } + /// + /// Filter by content type. + /// Note, this parameter supports the following format: `contentType{.path?}{.mode?}=...`, + /// so you can specify a path to a particular field to filter by (for example, `?contentType.prim.in=string,int`). + /// Click on the parameter to expand more details. + /// + public JsonParameter contentType { get; set; } public string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("ticketer", ticketer), ("firstMinter", firstMinter), ("firstLevel", firstLevel), - ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("сontentHash", сontentHash), ("сontentTypeHash", сontentTypeHash)); + ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("сontentHash", сontentHash), + ("сontentTypeHash", сontentTypeHash), ("content", content), ("contentType", contentType)); } } } diff --git a/Tzkt.Api/Parameters/TicketInfoFilter.cs b/Tzkt.Api/Parameters/TicketInfoFilter.cs index 9e15b8983..52df759d6 100644 --- a/Tzkt.Api/Parameters/TicketInfoFilter.cs +++ b/Tzkt.Api/Parameters/TicketInfoFilter.cs @@ -16,11 +16,24 @@ public class TicketInfoFilter : INormalizable /// Click on the parameter to expand more details. /// public AccountParameter ticketer { get; set; } + + //TODO Add that everywhere + /// + /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). + /// Click on the parameter to expand more details. + /// + public Int32Parameter сontentHash { get; set; } + + /// + /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). + /// Click on the parameter to expand more details. + /// + public Int32Parameter сontentTypeHash { get; set; } public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("ticketer", ticketer)); + ("id", id), ("ticketer", ticketer), ("сontentHash", сontentHash), ("сontentTypeHash", сontentTypeHash)); } } } diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index 25a032501..0f7154ecf 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -49,16 +49,37 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati case "totalSupply": columns.Add(@"""TotalSupply"""); break; case "contentHash": columns.Add(@"o.""ContentHash"""); break; case "contentTypeHash": columns.Add(@"o.""ContentTypeHash"""); break; - case "contentType": columns.Add(@"o.""RawType"""); break; + case "contentType": + if (field.Path == null) + { + columns.Add(format <= MichelineFormat.JsonString ? @"""JsonType""" : @"""RawType"""); + } + else if (format <= MichelineFormat.JsonString) + { + field.Column = $"c{counter++}"; + columns.Add($@"""JsonType"" #> '{{{field.PathString}}}' as {field.Column}"); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"NULL as {field.Column}"); + } + break; case "content": - columns.Add(format switch + if (field.Path == null) { - MichelineFormat.Json => @"o.""JsonContent""", - MichelineFormat.JsonString => @"o.""JsonContent""", - MichelineFormat.Raw => @"o.""RawContent""", - MichelineFormat.RawString => @"o.""RawContent""", - _ => throw new Exception("Invalid MichelineFormat value") - }); + columns.Add(format <= MichelineFormat.JsonString ? @"""JsonContent""" : @"""RawContent"""); + } + else if (format <= MichelineFormat.JsonString) + { + field.Column = $"c{counter++}"; + columns.Add($@"""JsonContent"" #> '{{{field.PathString}}}' as {field.Column}"); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"NULL as {field.Column}"); + } break; } } @@ -79,6 +100,8 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati .Filter("LastLevel", filter.lastTime) .Filter("ContentTypeHash", filter.сontentTypeHash) .Filter("ContentHash", filter.сontentHash) + .Filter("JsonType", filter.contentType) + .Filter("JsonContent", filter.content) .Take(pagination, x => x switch { "ticketId" => (@"""TicketId""::numeric", @"""TicketId""::numeric"), @@ -88,6 +111,8 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati "firstLevel" => (@"""Id""", @"""FirstLevel"""), "lastLevel" => (@"""LastLevel""", @"""LastLevel"""), "metadata" => (@"""Metadata""", @"""Metadata"""), + "content" => (@"""JsonContent""", @"""JsonContent"""), + "contentType" => (@"""JsonType""", @"""JsonType"""), _ => (@"""Id""", @"""Id""") }); @@ -106,7 +131,9 @@ public async Task GetTicketsCount(TicketFilter filter) .Filter("LastLevel", filter.lastLevel) .Filter("LastLevel", filter.lastTime) .Filter("ContentTypeHash", filter.сontentTypeHash) - .Filter("ContentHash", filter.сontentHash); + .Filter("ContentHash", filter.сontentHash) + .Filter("JsonType", filter.contentType) + .Filter("JsonContent", filter.content); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -174,7 +201,14 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat break; case "contentType": foreach (var row in rows) - result[j++][i] = (RawJson)Micheline.ToJson(row.RawType); + result[j++][i] = format switch + { + MichelineFormat.Json => row.JsonType == null ? null : (RawJson)row.JsonType, + MichelineFormat.JsonString => row.JsonType, + MichelineFormat.Raw => row.RawType == null ? null : (RawJson)Micheline.ToJson(row.RawType), + MichelineFormat.RawString => row.RawType == null ? null : Micheline.ToJson(row.RawType), + _ => throw new Exception("Invalid MichelineFormat value") + }; break; case "content": foreach (var row in rows) @@ -266,6 +300,11 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi tb.""TransfersCount"", tb.""TicketId"" as ""tId"", tb.""TicketerId"" as ""tTicketerId"", + t.""JsonContent"" as ""JsonContent"", + t.""RawContent"" as ""RawContent"", + t.""ContentHash"" as ""ContentHash"", + t.""ContentTypeHash"" as ""ContentTypeHash"", + t.""RawType"" as ""RawType"", t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { @@ -284,19 +323,20 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi case "lastTime": columns.Add(@"tb.""LastLevel"""); break; case "transfersCount": columns.Add(@"tb.""TransfersCount"""); break; case "ticket": - columns.Add(@"""Id"""); - columns.Add(@"""TicketerId"""); + columns.Add(@"tb.""TicketId"" as ""tId"""); + columns.Add(@"tb.""TicketerId"" as ""tTicketerId"""); + columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); columns.Add(format switch { - MichelineFormat.Json => @"o.""JsonContent""", - MichelineFormat.JsonString => @"o.""JsonContent""", - MichelineFormat.Raw => @"o.""RawContent""", - MichelineFormat.RawString => @"o.""RawContent""", + MichelineFormat.Json => @"t.""JsonContent"" as ""JsonContent""", + MichelineFormat.JsonString => @"t.""JsonContent"" as ""JsonContent""", + MichelineFormat.Raw => @"t.""RawContent"" as ""RawContent""", + MichelineFormat.RawString => @"t.""RawContent"" as ""RawContent""", _ => throw new Exception("Invalid MichelineFormat value") }); - columns.Add(@"o.""ContentHash"""); - columns.Add(@"o.""ContentTypeHash"""); - columns.Add(@"o.""RawType"""); + columns.Add(@"t.""ContentHash"" as ""ContentHash"""); + columns.Add(@"t.""ContentTypeHash"" as ""ContentTypeHash"""); + columns.Add(@"t.""RawType"" as ""RawType"""); break; } } @@ -319,13 +359,14 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi .FilterA(@"tb.""LastLevel""", filter.lastTime) .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash) .Take(pagination, x => x switch { "balance" => (@"tb.""Balance""::numeric", @"tb.""Balance""::numeric"), "transfersCount" => (@"tb.""TransfersCount""", @"tb.""TransfersCount"""), "firstLevel" => (@"tb.""Id""", @"tb.""FirstLevel"""), "lastLevel" => (@"tb.""LastLevel""", @"tb.""LastLevel"""), - "ticket.metadata" => (@"t.""Metadata""", @"t.""Metadata"""), _ => (@"tb.""Id""", @"tb.""Id""") }, @"tb.""Id"""); @@ -345,8 +386,9 @@ SELECT COUNT(*) FROM ""TicketBalances"" as tb .FilterA(@"tb.""FirstLevel""", filter.firstTime) .FilterA(@"tb.""LastLevel""", filter.lastLevel) .FilterA(@"tb.""LastLevel""", filter.lastTime) - .FilterA(@"tb.""TicketId""", filter.ticket.id) - .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer); + .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -369,7 +411,18 @@ public async Task> GetTicketBalances(TicketBalanceFil { Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), - TotalSupply = row.tTotalSupply + TotalSupply = row.tTotalSupply, + ContentType = (RawJson)Micheline.ToJson(row.RawType), + Content = format switch + { + MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), + _ => throw new Exception("Invalid MichelineFormat value") + }, + ContentHash = row.ContentHash, + ContentTypeHash = row.ContentTypeHash } }); } @@ -432,7 +485,18 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi { Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), - TotalSupply = row.tTotalSupply + TotalSupply = row.tTotalSupply, + ContentType = (RawJson)Micheline.ToJson(row.RawType), + Content = format switch + { + MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), + _ => throw new Exception("Invalid MichelineFormat value") + }, + ContentHash = row.ContentHash, + ContentTypeHash = row.ContentTypeHash }; break; case "ticket.id": @@ -455,6 +519,29 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi foreach (var row in rows) result[j++][i] = row.tTotalSupply; break; + case "ticket.content": + foreach (var row in rows) + result[j++][i] = format switch + { + MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), + _ => throw new Exception("Invalid MichelineFormat value") + }; + break; + case "ticket.contentType": + foreach (var row in rows) + result[j++][i] = (RawJson)Micheline.ToJson(row.RawType); + break; + case "ticket.contentHash": + foreach (var row in rows) + result[j++][i] = row.ContentHash; + break; + case "ticket.contentTypeHash": + foreach (var row in rows) + result[j++][i] = row.ContentTypeHash; + break; } } @@ -475,6 +562,11 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter tr.""TransferTicketId"", tr.""SmartRollupExecuteId"", tr.""TicketerId"" as ""tTicketerId"", + t.""JsonContent"" as ""JsonContent"", + t.""RawContent"" as ""RawContent"", + t.""ContentHash"" as ""ContentHash"", + t.""ContentTypeHash"" as ""ContentTypeHash"", + t.""RawType"" as ""RawType"", t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { @@ -498,15 +590,15 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter columns.Add(@"""TicketerId"""); columns.Add(format switch { - MichelineFormat.Json => @"o.""JsonContent""", - MichelineFormat.JsonString => @"o.""JsonContent""", - MichelineFormat.Raw => @"o.""RawContent""", - MichelineFormat.RawString => @"o.""RawContent""", + MichelineFormat.Json => @"t.""JsonContent"" as ""JsonContent""", + MichelineFormat.JsonString => @"t.""JsonContent"" as ""JsonContent""", + MichelineFormat.Raw => @"t.""RawContent"" as ""RawContent""", + MichelineFormat.RawString => @"t.""RawContent"" as ""RawContent""", _ => throw new Exception("Invalid MichelineFormat value") }); - columns.Add(@"o.""ContentHash"""); - columns.Add(@"o.""ContentTypeHash"""); - columns.Add(@"o.""RawType"""); + columns.Add(@"t.""ContentHash"" as ""ContentHash"""); + columns.Add(@"t.""ContentTypeHash"" as ""ContentTypeHash"""); + columns.Add(@"t.""RawType"" as ""RawType"""); break; } } @@ -532,6 +624,8 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash) .Take(pagination, x => x switch { "level" => (@"tr.""Level""", @"tr.""Level"""), @@ -559,7 +653,9 @@ SELECT COUNT(*) FROM ""TicketTransfers"" as tr .FilterA(@"tr.""TransferTicketId""", filter.transferTicketId) .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) - .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer); + .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -584,6 +680,17 @@ public async Task> GetTicketTransfers(TicketTransfer Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, + ContentType = (RawJson)Micheline.ToJson(row.RawType), + Content = format switch + { + MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), + _ => throw new Exception("Invalid MichelineFormat value") + }, + ContentHash = row.ContentHash, + ContentTypeHash = row.ContentTypeHash } }); } @@ -658,7 +765,18 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa { Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), - TotalSupply = row.tTotalSupply + TotalSupply = row.tTotalSupply, + ContentType = (RawJson)Micheline.ToJson(row.RawType), + Content = format switch + { + MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), + _ => throw new Exception("Invalid MichelineFormat value") + }, + ContentHash = row.ContentHash, + ContentTypeHash = row.ContentTypeHash }; break; case "ticket.id": @@ -681,6 +799,29 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa foreach (var row in rows) result[j++][i] = row.tTotalSupply; break; + case "ticket.content": + foreach (var row in rows) + result[j++][i] = format switch + { + MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), + _ => throw new Exception("Invalid MichelineFormat value") + }; + break; + case "ticket.contentType": + foreach (var row in rows) + result[j++][i] = (RawJson)Micheline.ToJson(row.RawType); + break; + case "ticket.contentHash": + foreach (var row in rows) + result[j++][i] = row.ContentHash; + break; + case "ticket.contentTypeHash": + foreach (var row in rows) + result[j++][i] = row.ContentTypeHash; + break; } } diff --git a/Tzkt.Data/Migrations/20230814170139_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230818112210_Tickets.Designer.cs similarity index 99% rename from Tzkt.Data/Migrations/20230814170139_Tickets.Designer.cs rename to Tzkt.Data/Migrations/20230818112210_Tickets.Designer.cs index 74b49e257..c5b65f8bc 100644 --- a/Tzkt.Data/Migrations/20230814170139_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230818112210_Tickets.Designer.cs @@ -13,7 +13,7 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230814170139_Tickets")] + [Migration("20230818112210_Tickets")] partial class Tickets { /// @@ -3607,7 +3607,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("integer"); b.Property("JsonContent") - .HasColumnType("text"); + .HasColumnType("jsonb"); + + b.Property("JsonType") + .HasColumnType("jsonb"); b.Property("LastLevel") .HasColumnType("integer"); @@ -3764,6 +3767,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("MigrationId") .HasFilter("\"MigrationId\" is not null"); + b.HasIndex("SmartRollupExecuteId") + .HasFilter("\"SmartRollupExecuteId\" is not null"); + b.HasIndex("TicketId"); b.HasIndex("TicketerId"); diff --git a/Tzkt.Data/Migrations/20230814170139_Tickets.cs b/Tzkt.Data/Migrations/20230818112210_Tickets.cs similarity index 96% rename from Tzkt.Data/Migrations/20230814170139_Tickets.cs rename to Tzkt.Data/Migrations/20230818112210_Tickets.cs index c29a77a72..a7af6364e 100644 --- a/Tzkt.Data/Migrations/20230814170139_Tickets.cs +++ b/Tzkt.Data/Migrations/20230818112210_Tickets.cs @@ -128,7 +128,8 @@ protected override void Up(MigrationBuilder migrationBuilder) ContentTypeHash = table.Column(type: "integer", nullable: false), RawContent = table.Column(type: "bytea", nullable: true), RawType = table.Column(type: "bytea", nullable: true), - JsonContent = table.Column(type: "text", nullable: true), + JsonContent = table.Column(type: "jsonb", nullable: true), + JsonType = table.Column(type: "jsonb", nullable: true), Metadata = table.Column(type: "jsonb", nullable: true) }, constraints: table => @@ -256,6 +257,12 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "MigrationId", filter: "\"MigrationId\" is not null"); + migrationBuilder.CreateIndex( + name: "IX_TicketTransfers_SmartRollupExecuteId", + table: "TicketTransfers", + column: "SmartRollupExecuteId", + filter: "\"SmartRollupExecuteId\" is not null"); + migrationBuilder.CreateIndex( name: "IX_TicketTransfers_TicketerId", table: "TicketTransfers", diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index d0c223fe4..e07f8ff69 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3604,7 +3604,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("integer"); b.Property("JsonContent") - .HasColumnType("text"); + .HasColumnType("jsonb"); + + b.Property("JsonType") + .HasColumnType("jsonb"); b.Property("LastLevel") .HasColumnType("integer"); @@ -3761,6 +3764,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("MigrationId") .HasFilter("\"MigrationId\" is not null"); + b.HasIndex("SmartRollupExecuteId") + .HasFilter("\"SmartRollupExecuteId\" is not null"); + b.HasIndex("TicketId"); b.HasIndex("TicketerId"); diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/TIcket.cs index 630e8f2c7..053af8bbd 100644 --- a/Tzkt.Data/Models/Scripts/TIcket.cs +++ b/Tzkt.Data/Models/Scripts/TIcket.cs @@ -27,6 +27,7 @@ public class Ticket public byte[] RawContent { get; set; } public byte[] RawType { get; set; } public string JsonContent { get; set; } + public string JsonType { get; set; } } public static class TicketModel @@ -43,6 +44,14 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .Property("Metadata") .HasColumnType("jsonb"); + + modelBuilder.Entity() + .Property(x => x.JsonContent) + .HasColumnType("jsonb"); + + modelBuilder.Entity() + .Property(x => x.JsonType) + .HasColumnType("jsonb"); // TODO: switch to `numeric` type after migration to .NET 6 var converter = new ValueConverter( diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index 2f0d8838b..9b7a67f20 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -711,6 +711,7 @@ protected virtual IEnumerable ParseTicketUpdates(string property, RawType = rawType, RawContent = rawContent, JsonContent = micheType.Humanize(value), + JsonType = micheType.ToMicheline().ToJson(), ContentTypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 5d8f56b71..8c09d8d95 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -220,6 +220,7 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul RawType = rawType, RawContent = rawContent, JsonContent = micheType.Humanize(value), + JsonType = micheType.ToMicheline().ToJson(), ContentTypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, @@ -236,42 +237,6 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul return null; } }).Where(update => update != null); - - var res = new List(); - foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) - { - try - { - var ticketToken = update.Required("ticket_token"); - var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); - var value = Micheline.FromJson(ticketToken.Required("content")); - var rawContent = micheType.Optimize(value).ToBytes(); - var rawType = micheType.ToMicheline().ToBytes(); - res.Add(new TicketUpdate - { - TicketToken = new TicketToken - { - Ticketer = ticketToken.RequiredString("ticketer"), - RawType = rawType, - RawContent = rawContent, - JsonContent = micheType.Humanize(value), - ContentTypeHash = Script.GetHash(rawType), - ContentHash = Script.GetHash(rawContent) - }, - Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update - { - Account = y.RequiredString("account"), - Amount = BigInteger.Parse(y.RequiredString("amount")) - }) - }); - } - catch (Exception ex) - { - Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); - } - } - - return res; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index ac8342ec3..3955ad282 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -215,6 +215,8 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, RawContent = rawContent, + JsonContent = micheType.Humanize(value), + JsonType = micheType.ToMicheline().ToJson(), ContentTypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index 75f3d9485..cc806cd03 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -194,6 +194,7 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic RawContent = ticketToken.RawContent, RawType = ticketToken.RawType, JsonContent = ticketToken.JsonContent, + JsonType = ticketToken.JsonType, ContentHash = ticketToken.ContentHash, ContentTypeHash = ticketToken.ContentTypeHash, }; diff --git a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs index d0e5f6c62..10404fb95 100644 --- a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs +++ b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs @@ -14,6 +14,7 @@ public class TicketToken public byte[] RawType { get; set; } public byte[] RawContent { get; set; } public string JsonContent { get; set; } + public string JsonType { get; set; } public int ContentTypeHash { get; set; } public int ContentHash { get; set; } From 9957dafd0637522cf3bc14ed1ba40f78192a69f4 Mon Sep 17 00:00:00 2001 From: dmir Date: Sat, 19 Aug 2023 15:09:56 +0300 Subject: [PATCH 30/51] Fix --- Tzkt.Api/Repositories/TicketsRepository.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index 0f7154ecf..e1a5ec445 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -386,6 +386,7 @@ SELECT COUNT(*) FROM ""TicketBalances"" as tb .FilterA(@"tb.""FirstLevel""", filter.firstTime) .FilterA(@"tb.""LastLevel""", filter.lastLevel) .FilterA(@"tb.""LastLevel""", filter.lastTime) + .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash); @@ -561,6 +562,7 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter tr.""TransactionId"", tr.""TransferTicketId"", tr.""SmartRollupExecuteId"", + tr.""TicketId"" as ""tId"", tr.""TicketerId"" as ""tTicketerId"", t.""JsonContent"" as ""JsonContent"", t.""RawContent"" as ""RawContent"", @@ -586,8 +588,9 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter case "transferTicketId": columns.Add(@"tr.""TransferTicketId"""); break; case "smartRollupExecuteId": columns.Add(@"tr.""SmartRollupExecuteId"""); break; case "ticket": - columns.Add(@"""Id"""); - columns.Add(@"""TicketerId"""); + columns.Add(@"tr.""TicketId"" as ""tId"""); + columns.Add(@"tr.""TicketerId"" as ""tTicketerId"""); + columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); columns.Add(format switch { MichelineFormat.Json => @"t.""JsonContent"" as ""JsonContent""", From 752c2359968b86063803848fea6fcb245525dcec Mon Sep 17 00:00:00 2001 From: dmir Date: Sat, 19 Aug 2023 16:30:22 +0300 Subject: [PATCH 31/51] Fix --- Tzkt.Api/Controllers/TicketsController.cs | 12 ++++++--- Tzkt.Api/Parameters/TicketFilter.cs | 8 +++--- Tzkt.Api/Parameters/TicketInfoFilter.cs | 6 ++--- Tzkt.Api/Repositories/TicketsRepository.cs | 30 ++++++++++++---------- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index 0eb914a25..cbd8725fc 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -42,8 +42,8 @@ public async Task> GetTicketsCount([FromQuery] TicketFilter fi filter.firstLevel != null || filter.lastTime != null || filter.lastLevel != null || - filter.сontentHash != null || - filter.сontentTypeHash != null || + filter.contentHash != null || + filter.contentTypeHash != null || filter.content != null || filter.contentType != null || filter.id != null ) @@ -123,8 +123,8 @@ public async Task> GetTicketBalancesCount([FromQuery] TicketBa filter.id != null || filter.ticket.id != null || filter.ticket.ticketer != null || - filter.ticket.сontentHash != null || - filter.ticket.сontentTypeHash != null) + filter.ticket.contentHash != null || + filter.ticket.contentTypeHash != null) { #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) @@ -213,6 +213,8 @@ public async Task> GetTicketTransfersCount([FromQuery] TicketT filter.transferTicketId != null || filter.smartRollupExecuteId != null || filter.ticket.ticketer != null || + filter.ticket.contentHash != null || + filter.ticket.contentTypeHash != null || filter.ticket.id != null) { #region optimizations @@ -312,10 +314,12 @@ public async Task>> GetTicketBalanc [FromQuery] Selection selection, MichelineFormat micheline = MichelineFormat.Json) { + if (filter.account?.Eq == null && filter.account?.In == null && filter.ticket.id?.Eq == null && filter.ticket.id?.In == null && + //TODO Make contentHash, contentTypeHash required filter.ticket.ticketer?.Eq == null && filter.ticket.ticketer?.In == null) return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.ticketer`) must be specified"); diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs index 539b9bc52..37b0b110e 100644 --- a/Tzkt.Api/Parameters/TicketFilter.cs +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -51,13 +51,13 @@ public class TicketFilter : INormalizable /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). /// Click on the parameter to expand more details. /// - public Int32Parameter сontentHash { get; set; } + public Int32Parameter contentHash { get; set; } /// /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). /// Click on the parameter to expand more details. /// - public Int32Parameter сontentTypeHash { get; set; } + public Int32Parameter contentTypeHash { get; set; } /// /// Filter by content. @@ -79,8 +79,8 @@ public string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("ticketer", ticketer), ("firstMinter", firstMinter), ("firstLevel", firstLevel), - ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("сontentHash", сontentHash), - ("сontentTypeHash", сontentTypeHash), ("content", content), ("contentType", contentType)); + ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("contentHash", contentHash), + ("contentTypeHash", contentTypeHash), ("content", content), ("contentType", contentType)); } } } diff --git a/Tzkt.Api/Parameters/TicketInfoFilter.cs b/Tzkt.Api/Parameters/TicketInfoFilter.cs index 52df759d6..ff2d954be 100644 --- a/Tzkt.Api/Parameters/TicketInfoFilter.cs +++ b/Tzkt.Api/Parameters/TicketInfoFilter.cs @@ -22,18 +22,18 @@ public class TicketInfoFilter : INormalizable /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). /// Click on the parameter to expand more details. /// - public Int32Parameter сontentHash { get; set; } + public Int32Parameter contentHash { get; set; } /// /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). /// Click on the parameter to expand more details. /// - public Int32Parameter сontentTypeHash { get; set; } + public Int32Parameter contentTypeHash { get; set; } public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("ticketer", ticketer), ("сontentHash", сontentHash), ("сontentTypeHash", сontentTypeHash)); + ("id", id), ("ticketer", ticketer), ("contentHash", contentHash), ("contentTypeHash", contentTypeHash)); } } } diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index e1a5ec445..4dc6ade65 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -98,8 +98,8 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati .Filter("FirstLevel", filter.firstTime) .Filter("LastLevel", filter.lastLevel) .Filter("LastLevel", filter.lastTime) - .Filter("ContentTypeHash", filter.сontentTypeHash) - .Filter("ContentHash", filter.сontentHash) + .Filter("ContentTypeHash", filter.contentTypeHash) + .Filter("ContentHash", filter.contentHash) .Filter("JsonType", filter.contentType) .Filter("JsonContent", filter.content) .Take(pagination, x => x switch @@ -130,8 +130,8 @@ public async Task GetTicketsCount(TicketFilter filter) .Filter("FirstLevel", filter.firstTime) .Filter("LastLevel", filter.lastLevel) .Filter("LastLevel", filter.lastTime) - .Filter("ContentTypeHash", filter.сontentTypeHash) - .Filter("ContentHash", filter.сontentHash) + .Filter("ContentTypeHash", filter.contentTypeHash) + .Filter("ContentHash", filter.contentHash) .Filter("JsonType", filter.contentType) .Filter("JsonContent", filter.content); @@ -359,8 +359,8 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi .FilterA(@"tb.""LastLevel""", filter.lastTime) .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash) + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash) .Take(pagination, x => x switch { "balance" => (@"tb.""Balance""::numeric", @"tb.""Balance""::numeric"), @@ -388,8 +388,8 @@ SELECT COUNT(*) FROM ""TicketBalances"" as tb .FilterA(@"tb.""LastLevel""", filter.lastTime) .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash); + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -627,8 +627,8 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash) + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash) .Take(pagination, x => x switch { "level" => (@"tr.""Level""", @"tr.""Level"""), @@ -657,8 +657,8 @@ SELECT COUNT(*) FROM ""TicketTransfers"" as tr .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.сontentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.сontentTypeHash); + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -874,7 +874,9 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T .FilterA(@"tr.""FromId""", filter.account) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"t.""TicketerId""", filter.ticket.ticketer) - .ResetFilters() + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash) + .ResetFilters() .Append("UNION ALL") @@ -885,6 +887,8 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T .FilterA(@"tr.""ToId""", filter.account) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"t.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) + .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash) .ResetFilters() .Append(") as tb") From 4cf4671578482ca76116ee782bc2bb8a1527a722 Mon Sep 17 00:00:00 2001 From: dmir Date: Sun, 20 Aug 2023 15:39:37 +0300 Subject: [PATCH 32/51] Fix --- Tzkt.Api/Controllers/TicketsController.cs | 8 ++++---- Tzkt.Api/Repositories/TicketsRepository.cs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index cbd8725fc..0b717f2e4 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -319,10 +319,10 @@ public async Task>> GetTicketBalanc filter.account?.In == null && filter.ticket.id?.Eq == null && filter.ticket.id?.In == null && - //TODO Make contentHash, contentTypeHash required - filter.ticket.ticketer?.Eq == null && - filter.ticket.ticketer?.In == null) - return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.ticketer`) must be specified"); + (filter.ticket.ticketer?.Eq == null && filter.ticket.ticketer?.In == null || + filter.ticket.contentHash?.Eq == null && filter.ticket.contentHash?.In == null || + filter.ticket.contentTypeHash?.Eq == null && filter.ticket.contentTypeHash?.In == null)) + return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.ticketer` with `ticket.contentHash` and `ticket.contentTypeHash`) must be specified"); #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index 4dc6ade65..025d257b1 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -912,7 +912,7 @@ public async Task> GetHistoricalTicketBalances(i Ticket = new TicketInfo { Id = row.tId, - Ticketer = Accounts.GetAlias(row.tContractId) + Ticketer = Accounts.GetAlias(row.tTicketerId) } }); } From e4eb5b28742c792c66661565c0f0a35afe8a25cf Mon Sep 17 00:00:00 2001 From: dmir Date: Sun, 20 Aug 2023 19:20:28 +0300 Subject: [PATCH 33/51] Clean up --- Tzkt.Api/Controllers/TicketsController.cs | 2 +- Tzkt.Api/Models/Accounts/Contract.cs | 4 ---- Tzkt.Api/Models/Accounts/Delegate.cs | 5 ----- Tzkt.Api/Models/Accounts/Ghost.cs | 7 +------ Tzkt.Api/Models/Accounts/Rollup.cs | 5 ----- Tzkt.Api/Models/Accounts/SmartRollup.cs | 5 ----- Tzkt.Api/Models/Accounts/User.cs | 5 ----- Tzkt.Api/Models/Tickets/TicketBalance.cs | 10 +++++----- Tzkt.Api/Parameters/TicketFilter.cs | 2 +- Tzkt.Api/Parameters/TicketInfoFilter.cs | 1 - Tzkt.Api/Parameters/TicketTransferFilter.cs | 2 +- Tzkt.Api/Repositories/TicketsRepository.cs | 1 + Tzkt.Data/Models/Operations/TransactionOperation.cs | 2 ++ Tzkt.Data/Models/Scripts/{TIcket.cs => Ticket.cs} | 0 .../Handlers/Proto16/Commits/TicketsCommit.cs | 5 +++-- 15 files changed, 15 insertions(+), 41 deletions(-) rename Tzkt.Data/Models/Scripts/{TIcket.cs => Ticket.cs} (100%) diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index 0b717f2e4..080920b5c 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -300,7 +300,7 @@ public async Task>> GetTicketTransfers( /// /// Returns a list of ticket balances at the end of the specified block. /// Note, this endpoint is quite heavy, therefore at least one of the filters - /// (`account`, `ticket.id`, `ticket.ticketer`) must be specified. + /// (`account`, `ticket.id`, `ticket.ticketer` with `ticket.contentHash` and `ticket.contentTypeHash`) must be specified. /// /// Level of the block at the end of which historical balances must be calculated /// Filter diff --git a/Tzkt.Api/Models/Accounts/Contract.cs b/Tzkt.Api/Models/Accounts/Contract.cs index 818c69dbf..df93c05bc 100644 --- a/Tzkt.Api/Models/Accounts/Contract.cs +++ b/Tzkt.Api/Models/Accounts/Contract.cs @@ -95,10 +95,6 @@ public class Contract : Account /// public int TokenTransfersCount { get; set; } - /// - /// Number of delegation operations of the contract. - /// - /// /// Number of account tickets with non-zero balances. /// diff --git a/Tzkt.Api/Models/Accounts/Delegate.cs b/Tzkt.Api/Models/Accounts/Delegate.cs index f2c1dbaee..183a45683 100644 --- a/Tzkt.Api/Models/Accounts/Delegate.cs +++ b/Tzkt.Api/Models/Accounts/Delegate.cs @@ -135,11 +135,6 @@ public class Delegate : Account /// public int ActiveTicketsCount { get; set; } - /// - /// Number of tickets minted in the contract. - /// - public int TicketsCount { get; set; } - /// /// Number of tickets the account ever had. /// diff --git a/Tzkt.Api/Models/Accounts/Ghost.cs b/Tzkt.Api/Models/Accounts/Ghost.cs index 429636b6d..4b78c9647 100644 --- a/Tzkt.Api/Models/Accounts/Ghost.cs +++ b/Tzkt.Api/Models/Accounts/Ghost.cs @@ -44,12 +44,7 @@ public class Ghost : Account /// Number of account tickets with non-zero balances. /// public int ActiveTicketsCount { get; set; } - - /// - /// Number of tickets minted in the contract. - /// - public int TicketsCount { get; set; } - + /// /// Number of tickets the account ever had. /// diff --git a/Tzkt.Api/Models/Accounts/Rollup.cs b/Tzkt.Api/Models/Accounts/Rollup.cs index be7b5d36d..44ec7a50e 100644 --- a/Tzkt.Api/Models/Accounts/Rollup.cs +++ b/Tzkt.Api/Models/Accounts/Rollup.cs @@ -55,11 +55,6 @@ public class Rollup : Account /// public int ActiveTicketsCount { get; set; } - /// - /// Number of tickets minted in the contract. - /// - public int TicketsCount { get; set; } - /// /// Number of tickets the account ever had. /// diff --git a/Tzkt.Api/Models/Accounts/SmartRollup.cs b/Tzkt.Api/Models/Accounts/SmartRollup.cs index b4ce045ce..e3b9d4122 100644 --- a/Tzkt.Api/Models/Accounts/SmartRollup.cs +++ b/Tzkt.Api/Models/Accounts/SmartRollup.cs @@ -109,11 +109,6 @@ public class SmartRollup : Account /// public int ActiveTicketsCount { get; set; } - /// - /// Number of tickets minted in the contract. - /// - public int TicketsCount { get; set; } - /// /// Number of tickets the account ever had. /// diff --git a/Tzkt.Api/Models/Accounts/User.cs b/Tzkt.Api/Models/Accounts/User.cs index 8620d753e..56565693f 100644 --- a/Tzkt.Api/Models/Accounts/User.cs +++ b/Tzkt.Api/Models/Accounts/User.cs @@ -103,11 +103,6 @@ public class User : Account /// public int ActiveTicketsCount { get; set; } - /// - /// Number of tickets minted in the contract. - /// - public int TicketsCount { get; set; } - /// /// Number of tickets the account ever had. /// diff --git a/Tzkt.Api/Models/Tickets/TicketBalance.cs b/Tzkt.Api/Models/Tickets/TicketBalance.cs index 70ef1d78b..3feabd519 100644 --- a/Tzkt.Api/Models/Tickets/TicketBalance.cs +++ b/Tzkt.Api/Models/Tickets/TicketBalance.cs @@ -29,30 +29,30 @@ public class TicketBalance public string Balance { get; set; } /// - /// Total number of transfers, affecting the token balance. + /// Total number of transfers, affecting the ticket balance. /// **[sortable]** /// public int TransfersCount { get; set; } /// - /// Level of the block where the token balance was first changed. + /// Level of the block where the ticket balance was first changed. /// **[sortable]** /// public int FirstLevel { get; set; } /// - /// Timestamp of the block where the token balance was first changed. + /// Timestamp of the block where the ticket balance was first changed. /// public DateTime FirstTime { get; set; } /// - /// Level of the block where the token balance was last changed. + /// Level of the block where the ticket balance was last changed. /// **[sortable]** /// public int LastLevel { get; set; } /// - /// Timestamp of the block where the token balance was last changed. + /// Timestamp of the block where the ticket balance was last changed. /// public DateTime LastTime { get; set; } } diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs index 37b0b110e..0583d89b3 100644 --- a/Tzkt.Api/Parameters/TicketFilter.cs +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -62,7 +62,7 @@ public class TicketFilter : INormalizable /// /// Filter by content. /// Note, this parameter supports the following format: `content{.path?}{.mode?}=...`, - /// so you can specify a path to a particular field to filter by (for example, `?content.foo.in=Token`). + /// so you can specify a path to a particular field to filter by (for example, `?content.in=red,green`). /// Click on the parameter to expand more details. /// public JsonParameter content { get; set; } diff --git a/Tzkt.Api/Parameters/TicketInfoFilter.cs b/Tzkt.Api/Parameters/TicketInfoFilter.cs index ff2d954be..906ef26d9 100644 --- a/Tzkt.Api/Parameters/TicketInfoFilter.cs +++ b/Tzkt.Api/Parameters/TicketInfoFilter.cs @@ -17,7 +17,6 @@ public class TicketInfoFilter : INormalizable /// public AccountParameter ticketer { get; set; } - //TODO Add that everywhere /// /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). /// Click on the parameter to expand more details. diff --git a/Tzkt.Api/Parameters/TicketTransferFilter.cs b/Tzkt.Api/Parameters/TicketTransferFilter.cs index 5f2a1fd16..f7e9f2d48 100644 --- a/Tzkt.Api/Parameters/TicketTransferFilter.cs +++ b/Tzkt.Api/Parameters/TicketTransferFilter.cs @@ -62,7 +62,7 @@ public class TicketTransferFilter : INormalizable public Int64NullParameter transactionId { get; set; } /// - /// Filter by id of the transfer ticket operation,, caused the ticket transfer. + /// Filter by id of the transfer ticket operation, caused the ticket transfer. /// Click on the parameter to expand more details. /// public Int64NullParameter transferTicketId { get; set; } diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index 025d257b1..ca9dd7129 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -601,6 +601,7 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter }); columns.Add(@"t.""ContentHash"" as ""ContentHash"""); columns.Add(@"t.""ContentTypeHash"" as ""ContentTypeHash"""); + //TODO Should we do format switch here? columns.Add(@"t.""RawType"" as ""RawType"""); break; } diff --git a/Tzkt.Data/Models/Operations/TransactionOperation.cs b/Tzkt.Data/Models/Operations/TransactionOperation.cs index 801d7c0af..08dec3ea9 100644 --- a/Tzkt.Data/Models/Operations/TransactionOperation.cs +++ b/Tzkt.Data/Models/Operations/TransactionOperation.cs @@ -23,6 +23,8 @@ public class TransactionOperation : ContractOperation public short? InternalTransactions { get; set; } public int? EventsCount { get; set; } + + //TODO Make sure we don't need to put it to ContractOperation. public int? TicketTransfers { get; set; } #region relations diff --git a/Tzkt.Data/Models/Scripts/TIcket.cs b/Tzkt.Data/Models/Scripts/Ticket.cs similarity index 100% rename from Tzkt.Data/Models/Scripts/TIcket.cs rename to Tzkt.Data/Models/Scripts/Ticket.cs diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index cc806cd03..e80b527b4 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -256,10 +256,11 @@ void TransferTickets(ManagerOperation op, Ticket ticket, var to = GetOrCreateAccount(op, toAddress); var toBalance = GetOrCreateTicketBalance(op, ticket, to); + //TODO Something wrong here, sometimes ticketTransfersCount is null. switch (op) { - case TransferTicketOperation transfer1: - transfer1.TicketTransfers = (transfer1.TicketTransfers ?? 0) + 1; + case TransferTicketOperation transferTicket: + transferTicket.TicketTransfers = (transferTicket.TicketTransfers ?? 0) + 1; break; case TransactionOperation tx: tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; From ca37de7e6a7f91e700c5a06b300150082b3245b2 Mon Sep 17 00:00:00 2001 From: dmir Date: Tue, 22 Aug 2023 19:38:17 +0300 Subject: [PATCH 34/51] Fixes --- Tzkt.Api/Program.cs | 8 +- Tzkt.Api/Repositories/TicketsRepository.cs | 175 +++---- Tzkt.Api/Websocket/Hubs/DefaultHub.cs | 42 +- .../Parameters/TicketTransfersParameter.cs | 24 + .../Processors/TicketBalancesProcessor.cs | 433 +++++++++++++++++ .../Processors/TicketTransfersProcessor.cs | 457 ++++++++++++++++++ Tzkt.Api/Websocket/WebsocketConfig.cs | 2 + Tzkt.Api/appsettings.json | 4 +- ....cs => 20230822151754_Tickets.Designer.cs} | 8 +- ...0_Tickets.cs => 20230822151754_Tickets.cs} | 9 +- .../Migrations/TzktContextModelSnapshot.cs | 6 - .../Models/Operations/TransactionOperation.cs | 2 - Tzkt.Data/Models/Scripts/TicketBalance.cs | 4 +- Tzkt.Data/Models/Scripts/TicketTransfer.cs | 8 - .../Handlers/Proto16/Commits/TicketsCommit.cs | 31 +- 15 files changed, 1037 insertions(+), 176 deletions(-) create mode 100644 Tzkt.Api/Websocket/Parameters/TicketTransfersParameter.cs create mode 100644 Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs create mode 100644 Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs rename Tzkt.Data/Migrations/{20230818112210_Tickets.Designer.cs => 20230822151754_Tickets.Designer.cs} (99%) rename Tzkt.Data/Migrations/{20230818112210_Tickets.cs => 20230822151754_Tickets.cs} (97%) diff --git a/Tzkt.Api/Program.cs b/Tzkt.Api/Program.cs index f333c2c5c..9c7877c96 100644 --- a/Tzkt.Api/Program.cs +++ b/Tzkt.Api/Program.cs @@ -121,8 +121,12 @@ builder.Services.AddTransient>(); builder.Services.AddTransient>(); - //TODO Add Ticket Balance and Transfer processors. - + builder.Services.AddTransient>(); + builder.Services.AddTransient>(); + + builder.Services.AddTransient>(); + builder.Services.AddTransient>(); + builder.Services.AddTransient>(); builder.Services.AddTransient>(); diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index ca9dd7129..73315c254 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -1,10 +1,4 @@ -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Dapper; +using Dapper; using Netezos.Encoding; using Tzkt.Api.Models; using Tzkt.Api.Services.Cache; @@ -104,15 +98,14 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati .Filter("JsonContent", filter.content) .Take(pagination, x => x switch { - "ticketId" => (@"""TicketId""::numeric", @"""TicketId""::numeric"), + "ticketerId" => (@"""TicketerId""::numeric", @"""TicketerId""::numeric"), "transfersCount" => (@"""TransfersCount""", @"""TransfersCount"""), "holdersCount" => (@"""HoldersCount""", @"""HoldersCount"""), "balancesCount" => (@"""BalancesCount""", @"""BalancesCount"""), "firstLevel" => (@"""Id""", @"""FirstLevel"""), "lastLevel" => (@"""LastLevel""", @"""LastLevel"""), - "metadata" => (@"""Metadata""", @"""Metadata"""), - "content" => (@"""JsonContent""", @"""JsonContent"""), - "contentType" => (@"""JsonType""", @"""JsonType"""), + "contentHash" => (@"""ContentHash""", @"""ContentHash"""), + "contentTypeHash" => (@"""ContentTypeHash""", @"""ContentTypeHash"""), _ => (@"""Id""", @"""Id""") }); @@ -157,15 +150,8 @@ public async Task> GetTickets(TicketFilter filter, Paginatio TotalMinted = row.TotalMinted, TotalSupply = row.TotalSupply, TransfersCount = row.TransfersCount, - ContentType = (RawJson)Micheline.ToJson(row.RawType), - Content = format switch - { - MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), - _ => throw new Exception("Invalid MichelineFormat value") - }, + ContentType = FormatType(row, format), + Content = FormatContent(row, format), ContentHash = row.ContentHash, ContentTypeHash = row.ContentTypeHash }); @@ -201,25 +187,11 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat break; case "contentType": foreach (var row in rows) - result[j++][i] = format switch - { - MichelineFormat.Json => row.JsonType == null ? null : (RawJson)row.JsonType, - MichelineFormat.JsonString => row.JsonType, - MichelineFormat.Raw => row.RawType == null ? null : (RawJson)Micheline.ToJson(row.RawType), - MichelineFormat.RawString => row.RawType == null ? null : Micheline.ToJson(row.RawType), - _ => throw new Exception("Invalid MichelineFormat value") - }; + result[j++][i] = FormatType(row, format); break; case "content": foreach (var row in rows) - result[j++][i] = format switch - { - MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), - _ => throw new Exception("Invalid MichelineFormat value") - }; + result[j++][i] = FormatContent(row, format); break; case "contentTypeHash": foreach (var row in rows) @@ -302,9 +274,10 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi tb.""TicketerId"" as ""tTicketerId"", t.""JsonContent"" as ""JsonContent"", t.""RawContent"" as ""RawContent"", + t.""JsonType"" as ""JsonType"", + t.""RawType"" as ""RawType"", t.""ContentHash"" as ""ContentHash"", t.""ContentTypeHash"" as ""ContentTypeHash"", - t.""RawType"" as ""RawType"", t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { @@ -326,17 +299,10 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi columns.Add(@"tb.""TicketId"" as ""tId"""); columns.Add(@"tb.""TicketerId"" as ""tTicketerId"""); columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); - columns.Add(format switch - { - MichelineFormat.Json => @"t.""JsonContent"" as ""JsonContent""", - MichelineFormat.JsonString => @"t.""JsonContent"" as ""JsonContent""", - MichelineFormat.Raw => @"t.""RawContent"" as ""RawContent""", - MichelineFormat.RawString => @"t.""RawContent"" as ""RawContent""", - _ => throw new Exception("Invalid MichelineFormat value") - }); + columns.Add(FormatContentQuery(format)); + columns.Add(FormatTypeQuery(format)); columns.Add(@"t.""ContentHash"" as ""ContentHash"""); columns.Add(@"t.""ContentTypeHash"" as ""ContentTypeHash"""); - columns.Add(@"t.""RawType"" as ""RawType"""); break; } } @@ -413,15 +379,8 @@ public async Task> GetTicketBalances(TicketBalanceFil Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - ContentType = (RawJson)Micheline.ToJson(row.RawType), - Content = format switch - { - MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), - _ => throw new Exception("Invalid MichelineFormat value") - }, + ContentType = FormatType(row, format), + Content = FormatContent(row, format), ContentHash = row.ContentHash, ContentTypeHash = row.ContentTypeHash } @@ -487,15 +446,8 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - ContentType = (RawJson)Micheline.ToJson(row.RawType), - Content = format switch - { - MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), - _ => throw new Exception("Invalid MichelineFormat value") - }, + ContentType = FormatType(row, format), + Content = FormatContent(row, format), ContentHash = row.ContentHash, ContentTypeHash = row.ContentTypeHash }; @@ -522,18 +474,11 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi break; case "ticket.content": foreach (var row in rows) - result[j++][i] = format switch - { - MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), - _ => throw new Exception("Invalid MichelineFormat value") - }; + result[j++][i] = FormatContent(row, format); break; case "ticket.contentType": foreach (var row in rows) - result[j++][i] = (RawJson)Micheline.ToJson(row.RawType); + result[j++][i] = FormatType(row, format); break; case "ticket.contentHash": foreach (var row in rows) @@ -566,9 +511,10 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter tr.""TicketerId"" as ""tTicketerId"", t.""JsonContent"" as ""JsonContent"", t.""RawContent"" as ""RawContent"", + t.""JsonType"" as ""JsonType"", + t.""RawType"" as ""RawType"", t.""ContentHash"" as ""ContentHash"", t.""ContentTypeHash"" as ""ContentTypeHash"", - t.""RawType"" as ""RawType"", t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { @@ -591,18 +537,10 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter columns.Add(@"tr.""TicketId"" as ""tId"""); columns.Add(@"tr.""TicketerId"" as ""tTicketerId"""); columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); - columns.Add(format switch - { - MichelineFormat.Json => @"t.""JsonContent"" as ""JsonContent""", - MichelineFormat.JsonString => @"t.""JsonContent"" as ""JsonContent""", - MichelineFormat.Raw => @"t.""RawContent"" as ""RawContent""", - MichelineFormat.RawString => @"t.""RawContent"" as ""RawContent""", - _ => throw new Exception("Invalid MichelineFormat value") - }); + columns.Add(FormatContentQuery(format)); + columns.Add(FormatTypeQuery(format)); columns.Add(@"t.""ContentHash"" as ""ContentHash"""); columns.Add(@"t.""ContentTypeHash"" as ""ContentTypeHash"""); - //TODO Should we do format switch here? - columns.Add(@"t.""RawType"" as ""RawType"""); break; } } @@ -684,15 +622,8 @@ public async Task> GetTicketTransfers(TicketTransfer Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - ContentType = (RawJson)Micheline.ToJson(row.RawType), - Content = format switch - { - MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), - _ => throw new Exception("Invalid MichelineFormat value") - }, + ContentType = FormatType(row, format), + Content = FormatContent(row, format), ContentHash = row.ContentHash, ContentTypeHash = row.ContentTypeHash } @@ -770,15 +701,8 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - ContentType = (RawJson)Micheline.ToJson(row.RawType), - Content = format switch - { - MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), - _ => throw new Exception("Invalid MichelineFormat value") - }, + ContentType = FormatType(row, format), + Content = FormatContent(row, format), ContentHash = row.ContentHash, ContentTypeHash = row.ContentTypeHash }; @@ -805,18 +729,11 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa break; case "ticket.content": foreach (var row in rows) - result[j++][i] = format switch - { - MichelineFormat.Json => row.JsonContent == null ? null : (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => row.RawContent == null ? null : (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => row.RawContent == null ? null : Micheline.ToJson(row.RawContent), - _ => throw new Exception("Invalid MichelineFormat value") - }; + result[j++][i] = FormatContent(row, format); break; case "ticket.contentType": foreach (var row in rows) - result[j++][i] = (RawJson)Micheline.ToJson(row.RawType); + result[j++][i] = FormatType(row, format); break; case "ticket.contentHash": foreach (var row in rows) @@ -976,5 +893,41 @@ public async Task GetHistoricalTicketBalances(int level, TicketBalan return result; } #endregion + + static object FormatContent(dynamic row, MichelineFormat format) => format switch + { + MichelineFormat.Json => (RawJson)row.JsonContent, + MichelineFormat.JsonString => row.JsonContent, + MichelineFormat.Raw => (RawJson)Micheline.ToJson(row.RawContent), + MichelineFormat.RawString => Micheline.ToJson(row.RawContent), + _ => null + }; + + static object FormatType(dynamic row, MichelineFormat format) => format switch + { + MichelineFormat.Json => (RawJson)row.JsonType, + MichelineFormat.JsonString => row.JsonType, + MichelineFormat.Raw => (RawJson)Micheline.ToJson(row.RawType), + MichelineFormat.RawString => Micheline.ToJson(row.RawType), + _ => null + }; + + static string FormatContentQuery(MichelineFormat format) => format switch + { + MichelineFormat.Json => @"t.""JsonContent"" as ""JsonContent""", + MichelineFormat.JsonString => @"t.""JsonContent"" as ""JsonContent""", + MichelineFormat.Raw => @"t.""RawContent"" as ""RawContent""", + MichelineFormat.RawString => @"t.""RawContent"" as ""RawContent""", + _ => throw new Exception("Invalid MichelineFormat value") + }; + + static string FormatTypeQuery(MichelineFormat format) => format switch + { + MichelineFormat.Json => @"t.""JsonType"" as ""JsonType""", + MichelineFormat.JsonString => @"t.""JsonType"" as ""JsonType""", + MichelineFormat.Raw => @"t.""RawType"" as ""RawType""", + MichelineFormat.RawString => @"t.""RawType"" as ""RawType""", + _ => throw new Exception("Invalid MichelineFormat value") + }; } } diff --git a/Tzkt.Api/Websocket/Hubs/DefaultHub.cs b/Tzkt.Api/Websocket/Hubs/DefaultHub.cs index d80c24494..6dc013ce8 100644 --- a/Tzkt.Api/Websocket/Hubs/DefaultHub.cs +++ b/Tzkt.Api/Websocket/Hubs/DefaultHub.cs @@ -15,8 +15,10 @@ public class DefaultHub : BaseHub readonly OperationsProcessor Operations; readonly BigMapsProcessor BigMaps; readonly EventsProcessor Events; - readonly TokenBalancesProcessor Balances; - readonly TokenTransfersProcessor Transfers; + readonly TokenBalancesProcessor TokenBalances; + readonly TokenTransfersProcessor TokenTransfers; + readonly TicketBalancesProcessor TicketBalances; + readonly TicketTransfersProcessor TicketTransfers; readonly AccountsProcessor Accounts; public DefaultHub( @@ -26,8 +28,10 @@ public DefaultHub( OperationsProcessor operations, BigMapsProcessor bigMaps, EventsProcessor events, - TokenBalancesProcessor balances, - TokenTransfersProcessor transfers, + TokenBalancesProcessor tokenBalances, + TokenTransfersProcessor tokenTransfers, + TicketBalancesProcessor ticketBalances, + TicketTransfersProcessor ticketTransfers, AccountsProcessor accounts, ILogger logger, IMetrics metrics, @@ -39,8 +43,10 @@ public DefaultHub( Operations = operations; BigMaps = bigMaps; Events = events; - Balances = balances; - Transfers = transfers; + TokenBalances = tokenBalances; + TokenTransfers = tokenTransfers; + TicketBalances = ticketBalances; + TicketTransfers = ticketTransfers; Accounts = accounts; } @@ -86,14 +92,28 @@ public Task SubscribeToTokenBalances(TokenTransfersParameter parameters) { parameters ??= new(); parameters.EnsureValid(); - return Balances.Subscribe(Clients.Caller, Context.ConnectionId, parameters); + return TokenBalances.Subscribe(Clients.Caller, Context.ConnectionId, parameters); } public Task SubscribeToTokenTransfers(TokenTransfersParameter parameters) { parameters ??= new(); parameters.EnsureValid(); - return Transfers.Subscribe(Clients.Caller, Context.ConnectionId, parameters); + return TokenTransfers.Subscribe(Clients.Caller, Context.ConnectionId, parameters); + } + + public Task SubscribeToTicketBalances(TicketTransfersParameter parameters) + { + parameters ??= new(); + parameters.EnsureValid(); + return TicketBalances.Subscribe(Clients.Caller, Context.ConnectionId, parameters); + } + + public Task SubscribeToTicketTransfers(TicketTransfersParameter parameters) + { + parameters ??= new(); + parameters.EnsureValid(); + return TicketTransfers.Subscribe(Clients.Caller, Context.ConnectionId, parameters); } public Task SubscribeToAccounts(AccountsParameter parameters) @@ -109,8 +129,10 @@ public override Task OnDisconnectedAsync(Exception exception) Operations.Unsubscribe(Context.ConnectionId); BigMaps.Unsubscribe(Context.ConnectionId); Events.Unsubscribe(Context.ConnectionId); - Balances.Unsubscribe(Context.ConnectionId); - Transfers.Unsubscribe(Context.ConnectionId); + TokenBalances.Unsubscribe(Context.ConnectionId); + TokenTransfers.Unsubscribe(Context.ConnectionId); + TicketBalances.Unsubscribe(Context.ConnectionId); + TicketTransfers.Unsubscribe(Context.ConnectionId); Accounts.Unsubscribe(Context.ConnectionId); return base.OnDisconnectedAsync(exception); } diff --git a/Tzkt.Api/Websocket/Parameters/TicketTransfersParameter.cs b/Tzkt.Api/Websocket/Parameters/TicketTransfersParameter.cs new file mode 100644 index 000000000..a23fa9732 --- /dev/null +++ b/Tzkt.Api/Websocket/Parameters/TicketTransfersParameter.cs @@ -0,0 +1,24 @@ +using System.Text.RegularExpressions; +using Microsoft.AspNetCore.SignalR; + +namespace Tzkt.Api.Websocket +{ + public class TicketTransfersParameter + { + public string Account { get; set; } + public string Ticketer { get; set; } + public long? TicketId { get; set; } + + public void EnsureValid() + { + if (Account != null && !Regex.IsMatch(Account, "^[0-9A-Za-z]{36,37}$")) + throw new HubException("Invalid account address"); + + if (Ticketer != null && !Regex.IsMatch(Ticketer, "^KT1[0-9A-Za-z]{33}$")) + throw new HubException("Invalid contract address"); + + if (TicketId is < 0) + throw new HubException("Invalid ticketId"); + } + } +} \ No newline at end of file diff --git a/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs b/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs new file mode 100644 index 000000000..56e5c95d4 --- /dev/null +++ b/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs @@ -0,0 +1,433 @@ +using Microsoft.AspNetCore.SignalR; +using Tzkt.Api.Models; +using Tzkt.Api.Repositories; +using Tzkt.Api.Services.Cache; + +namespace Tzkt.Api.Websocket.Processors +{ + public class TicketBalancesProcessor : IHubProcessor where T : Hub + { + #region static + const string Group = "ticket_balances"; + const string Channel = "ticket_balances"; + static readonly SemaphoreSlim Sema = new(1, 1); + + static readonly HashSet AllSubs = new(); + static readonly Dictionary AccountSubs = new(); + static readonly Dictionary TicketerSubs = new(); + + static readonly Dictionary Limits = new(); + + class AccountSub + { + public HashSet All { get; set; } + public Dictionary Ticketers { get; set; } + + public bool Empty => All == null && Ticketers == null; + } + class TicketerSub + { + public HashSet All { get; set; } + public Dictionary> Tickets { get; set; } + + public bool Empty => All == null && Tickets == null; + } + #endregion + + readonly StateCache State; + readonly TicketsRepository Repo; + readonly IHubContext Context; + readonly WebsocketConfig Config; + readonly ILogger Logger; + + public TicketBalancesProcessor(StateCache state, TicketsRepository tickets, + IHubContext hubContext, IConfiguration config, ILogger> logger) + { + State = state; + Repo = tickets; + Context = hubContext; + Config = config.GetWebsocketConfig(); + Logger = logger; + } + + public async Task OnStateChanged() + { + var sendings = new List(); + try + { + await Sema.WaitAsync(); + + if (Limits.Count == 0) + { + Logger.LogDebug("No ticket balances subs"); + return; + } + + #region check reorg + if (State.Reorganized) + { + Logger.LogDebug("Sending reorg message with state {state}", State.ValidLevel); + sendings.Add(Context.Clients + .Group(Group) + .SendReorg(Channel, State.ValidLevel)); + } + #endregion + + if (State.ValidLevel == State.Current.Level) + { + Logger.LogDebug("No ticket balances to send"); + return; + } + + #region load ticket balances + Logger.LogDebug("Fetching ticket balances from {valid} to {current}", State.ValidLevel, State.Current.Level); + + var params1 = new TicketBalanceFilter + { + lastLevel = State.Current.Level == State.ValidLevel + 1 + ? new Int32Parameter + { + Eq = State.Current.Level + } + : new Int32Parameter + { + Gt = State.ValidLevel, + Le = State.Current.Level + }, + account = new(), + ticket = new() + }; + var limit = 1_000_000; + var format = MichelineFormat.Json; + + var balances = await Repo.GetTicketBalances(params1, new() { limit = limit }, format); + var count = balances.Count(); + + Logger.LogDebug("{cnt} ticket balances fetched", count); + #endregion + + #region prepare to send + var toSend = new Dictionary>(); + + void Add(HashSet subs, TicketBalance balance) + { + foreach (var clientId in subs) + { + if (!toSend.TryGetValue(clientId, out var list)) + { + list = new(); + toSend.Add(clientId, list); + } + list.Add(balance); + } + } + + foreach (var balance in balances) + { + #region all subs + Add(AllSubs, balance); + #endregion + + #region account subs + if (AccountSubs.TryGetValue(balance.Account.Address, out var accountSubs)) + { + if (accountSubs.All != null) + Add(accountSubs.All, balance); + + if (accountSubs.Ticketers != null) + { + if (accountSubs.Ticketers.TryGetValue(balance.Ticket.Ticketer.Address, out var accountTicketerSubs)) + { + if (accountTicketerSubs.All != null) + Add(accountTicketerSubs.All, balance); + + if (accountTicketerSubs.Tickets != null) + if (accountTicketerSubs.Tickets.TryGetValue(balance.Ticket.Id, out var ticketerTicketSubs)) + Add(ticketerTicketSubs, balance); + } + } + } + #endregion + + #region ticketer subs + if (TicketerSubs.TryGetValue(balance.Ticket.Ticketer.Address, out var ticketerSubs)) + { + if (ticketerSubs.All != null) + Add(ticketerSubs.All, balance); + + if (ticketerSubs.Tickets != null) + if (ticketerSubs.Tickets.TryGetValue(balance.Ticket.Id, out var ticketerTicketSubs)) + Add(ticketerTicketSubs, balance); + } + #endregion + } + #endregion + + #region send + foreach (var (connectionId, balancesList) in toSend.Where(x => x.Value.Count > 0)) + { + var data = balancesList.Count > 1 + ? Distinct(balancesList).OrderBy(x => x.Id) + : (IEnumerable)balancesList; + + sendings.Add(Context.Clients + .Client(connectionId) + .SendData(Channel, data, State.Current.Level)); + + Logger.LogDebug("{cnt} ticket balances sent to {id}", balancesList.Count, connectionId); + } + + Logger.LogDebug("{cnt} ticket balances sent", count); + #endregion + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to process state change"); + } + finally + { + Sema.Release(); + #region await sendings + try + { + await Task.WhenAll(sendings); + } + catch (Exception ex) + { + // should never get here + Logger.LogCritical(ex, "Sendings failed"); + } + #endregion + } + } + + public async Task Subscribe(IClientProxy client, string connectionId, TicketTransfersParameter parameter) + { + Task sending = Task.CompletedTask; + try + { + await Sema.WaitAsync(); + Logger.LogDebug("New subscription..."); + + #region check limits + if (Limits.TryGetValue(connectionId, out var cnt) && cnt >= Config.MaxTicketBalancesSubscriptions) + throw new HubException($"Subscriptions limit exceeded"); + + if (cnt > 0) // reuse already allocated string + connectionId = Limits.Keys.First(x => x == connectionId); + #endregion + + #region add to subs + if (parameter.Account != null) + { + if (!AccountSubs.TryGetValue(parameter.Account, out var accountSub)) + { + accountSub = new(); + AccountSubs.Add(parameter.Account, accountSub); + } + if (parameter.Ticketer != null) + { + accountSub.Ticketers ??= new(4); + if (!accountSub.Ticketers.TryGetValue(parameter.Ticketer, out var ticketerSub)) + { + ticketerSub = new(); + accountSub.Ticketers.Add(parameter.Ticketer, ticketerSub); + } + if (parameter.TicketId is long ticketId) + { + ticketerSub.Tickets ??= new(4); + TryAdd(ticketerSub.Tickets, ticketId, connectionId); + } + else + { + ticketerSub.All ??= new(4); + TryAdd(ticketerSub.All, connectionId); + } + } + else + { + accountSub.All ??= new(4); + TryAdd(accountSub.All, connectionId); + } + } + else if (parameter.Ticketer != null) + { + if (!TicketerSubs.TryGetValue(parameter.Ticketer, out var ticketerSub)) + { + ticketerSub = new(); + TicketerSubs.Add(parameter.Ticketer, ticketerSub); + } + if (parameter.TicketId is long ticketId) + { + ticketerSub.Tickets ??= new(4); + TryAdd(ticketerSub.Tickets, ticketId, connectionId); + } + else + { + ticketerSub.All ??= new(); + TryAdd(ticketerSub.All, connectionId); + } + } + else + { + TryAdd(AllSubs, connectionId); + } + #endregion + + #region add to group + await Context.Groups.AddToGroupAsync(connectionId, Group); + #endregion + + sending = client.SendState(Channel, State.Current.Level); + + Logger.LogDebug("Client {id} subscribed with state {state}", connectionId, State.Current.Level); + return State.Current.Level; + } + catch (HubException) + { + throw; + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to add subscription"); + return 0; + } + finally + { + Sema.Release(); + try + { + await sending; + } + catch (Exception ex) + { + // should never get here + Logger.LogCritical(ex, "Sending failed"); + } + } + } + + public void Unsubscribe(string connectionId) + { + try + { + Sema.Wait(); + if (!Limits.ContainsKey(connectionId)) return; + Logger.LogDebug("Remove subscription..."); + + #region all subs + TryRemove(AllSubs, connectionId); + #endregion + + #region account subs + var emptyAccountSubs = new List(); + foreach (var (account, accountSub) in AccountSubs) + { + accountSub.All = TryRemove(accountSub.All, connectionId); + if (accountSub.Ticketers != null) + { + var emptyAccountTicketerSubs = new List(); + foreach (var (ticketer, ticketerSub) in accountSub.Ticketers) + { + ticketerSub.All = TryRemove(ticketerSub.All, connectionId); + ticketerSub.Tickets = TryRemove(ticketerSub.Tickets, connectionId); + + if (ticketerSub.Empty) + emptyAccountTicketerSubs.Add(ticketer); + } + foreach (var ticketer in emptyAccountTicketerSubs) + accountSub.Ticketers.Remove(ticketer); + + if (accountSub.Ticketers.Count == 0) + accountSub.Ticketers = null; + } + if (accountSub.Empty) + emptyAccountSubs.Add(account); + } + foreach (var account in emptyAccountSubs) + AccountSubs.Remove(account); + #endregion + + #region ticketer subs + var emptyTicketerSubs = new List(); + foreach (var (ticketer, ticketerSub) in TicketerSubs) + { + ticketerSub.All = TryRemove(ticketerSub.All, connectionId); + ticketerSub.Tickets = TryRemove(ticketerSub.Tickets, connectionId); + + if (ticketerSub.Empty) + emptyTicketerSubs.Add(ticketer); + } + foreach (var ticketer in emptyTicketerSubs) + TicketerSubs.Remove(ticketer); + #endregion + + if (Limits[connectionId] != 0) + Logger.LogCritical("Failed to unsibscribe {id}: {cnt} subs left", connectionId, Limits[connectionId]); + Limits.Remove(connectionId); + + Logger.LogDebug("Client {id} unsubscribed", connectionId); + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to remove subscription"); + } + finally + { + Sema.Release(); + } + } + + private static void TryAdd(Dictionary> subs, TSubKey key, string connectionId) + { + if (!subs.TryGetValue(key, out var set)) + { + set = new(4); + subs.Add(key, set); + } + + if (set.Add(connectionId)) + Limits[connectionId] = Limits.GetValueOrDefault(connectionId) + 1; + } + + private static void TryAdd(HashSet set, string connectionId) + { + if (set.Add(connectionId)) + Limits[connectionId] = Limits.GetValueOrDefault(connectionId) + 1; + } + + private static Dictionary> TryRemove(Dictionary> subs, string connectionId) + { + if (subs == null) return null; + foreach (var (key, value) in subs) + { + if (value.Remove(connectionId)) + Limits[connectionId]--; + + if (value.Count == 0) + subs.Remove(key); + } + if (subs.Count == 0) return null; + return subs; + } + + private static HashSet TryRemove(HashSet set, string connectionId) + { + if (set == null) return null; + if (set.Remove(connectionId)) + { + Limits[connectionId]--; + if (set.Count == 0) return null; + } + return set; + } + + private static IEnumerable Distinct(List items) + { + var set = new HashSet(items.Count); + foreach (var item in items) + if (set.Add(item.Id)) + yield return item; + } + } +} diff --git a/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs b/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs new file mode 100644 index 000000000..1a257356e --- /dev/null +++ b/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs @@ -0,0 +1,457 @@ +using Microsoft.AspNetCore.SignalR; +using Tzkt.Api.Models; +using Tzkt.Api.Repositories; +using Tzkt.Api.Services.Cache; + +namespace Tzkt.Api.Websocket.Processors +{ + public class TicketTransfersProcessor : IHubProcessor where T : Hub + { + #region static + const string TicketTransfersGroup = "ticket_transfers"; + const string TicketTransfersChannel = "ticket_transfers"; + static readonly SemaphoreSlim Sema = new(1, 1); + + static readonly HashSet AllSubs = new(); + static readonly Dictionary AccountSubs = new(); + static readonly Dictionary TicketerSubs = new(); + + static readonly Dictionary Limits = new(); + + class AccountSub + { + public HashSet All { get; set; } + public Dictionary Ticketers { get; set; } + + public bool Empty => All == null && Ticketers == null; + } + class TicketerSub + { + public HashSet All { get; set; } + public Dictionary> Tickets { get; set; } + + public bool Empty => All == null && Tickets == null; + } + #endregion + + readonly StateCache State; + readonly TicketsRepository Repo; + readonly IHubContext Context; + readonly WebsocketConfig Config; + readonly ILogger Logger; + + public TicketTransfersProcessor(StateCache state, TicketsRepository tickets, + IHubContext hubContext, IConfiguration config, ILogger> logger) + { + State = state; + Repo = tickets; + Context = hubContext; + Config = config.GetWebsocketConfig(); + Logger = logger; + } + + public async Task OnStateChanged() + { + var sendings = new List(); + try + { + await Sema.WaitAsync(); + + if (Limits.Count == 0) + { + Logger.LogDebug("No ticket transfers subs"); + return; + } + + #region check reorg + if (State.Reorganized) + { + Logger.LogDebug("Sending reorg message with state {state}", State.ValidLevel); + sendings.Add(Context.Clients + .Group(TicketTransfersGroup) + .SendReorg(TicketTransfersChannel, State.ValidLevel)); + } + #endregion + + if (State.ValidLevel == State.Current.Level) + { + Logger.LogDebug("No ticket transfers to send"); + return; + } + + #region load ticket transfers + Logger.LogDebug("Fetching ticket transfers from block {valid} to block {current}", State.ValidLevel, State.Current.Level); + + var params1 = new TicketTransferFilter + { + level = State.Current.Level == State.ValidLevel + 1 + ? new Int32Parameter + { + Eq = State.Current.Level + } + : new Int32Parameter + { + Gt = State.ValidLevel, + Le = State.Current.Level + }, + ticket = new() + }; + var limit = 1_000_000; + var format = MichelineFormat.Json; + + + var transfers = (await Repo.GetTicketTransfers(params1, new() { limit = limit }, format)); + var count = transfers.Count(); + + Logger.LogDebug("{cnt} ticket transfers fetched", count); + #endregion + + #region prepare to send + var toSend = new Dictionary>(); + + void Add(HashSet subs, TicketTransfer transfer) + { + foreach (var clientId in subs) + { + if (!toSend.TryGetValue(clientId, out var list)) + { + list = new(); + toSend.Add(clientId, list); + } + list.Add(transfer); + } + } + + foreach (var transfer in transfers) + { + #region all subs + Add(AllSubs, transfer); + #endregion + + #region account subs + if (transfer.From != null) + { + if (AccountSubs.TryGetValue(transfer.From.Address, out var accountSubs)) + { + if (accountSubs.All != null) + Add(accountSubs.All, transfer); + + if (accountSubs.Ticketers != null) + { + if (accountSubs.Ticketers.TryGetValue(transfer.Ticket.Ticketer.Address, out var accountTicketerSubs)) + { + if (accountTicketerSubs.All != null) + Add(accountTicketerSubs.All, transfer); + + if (accountTicketerSubs.Tickets != null) + if (accountTicketerSubs.Tickets.TryGetValue(transfer.Ticket.Id, out var ticketerTicketSubs)) + Add(ticketerTicketSubs, transfer); + } + } + } + } + if (transfer.To != null) + { + if (AccountSubs.TryGetValue(transfer.To.Address, out var accountSubs)) + { + if (accountSubs.All != null) + Add(accountSubs.All, transfer); + + if (accountSubs.Ticketers != null) + { + if (accountSubs.Ticketers.TryGetValue(transfer.Ticket.Ticketer.Address, out var accountTicketerSubs)) + { + if (accountTicketerSubs.All != null) + Add(accountTicketerSubs.All, transfer); + + if (accountTicketerSubs.Tickets != null) + if (accountTicketerSubs.Tickets.TryGetValue(transfer.Ticket.Id, out var ticketerTicketSubs)) + Add(ticketerTicketSubs, transfer); + } + } + } + } + #endregion + + #region ticketer subs + if (TicketerSubs.TryGetValue(transfer.Ticket.Ticketer.Address, out var ticketerSubs)) + { + if (ticketerSubs.All != null) + Add(ticketerSubs.All, transfer); + + if (ticketerSubs.Tickets != null) + if (ticketerSubs.Tickets.TryGetValue(transfer.Ticket.Id, out var ticketerTicketSubs)) + Add(ticketerTicketSubs, transfer); + } + #endregion + } + #endregion + + #region send + foreach (var (connectionId, transfersList) in toSend.Where(x => x.Value.Count > 0)) + { + var data = transfersList.Count > 1 + ? Distinct(transfersList).OrderBy(x => x.Id) + : (IEnumerable)transfersList; + + sendings.Add(Context.Clients + .Client(connectionId) + .SendData(TicketTransfersChannel, data, State.Current.Level)); + + Logger.LogDebug("{cnt} ticket transfers sent to {id}", transfersList.Count, connectionId); + } + + Logger.LogDebug("{cnt} ticket transfers sent", count); + #endregion + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to process state change"); + } + finally + { + Sema.Release(); + #region await sendings + try + { + await Task.WhenAll(sendings); + } + catch (Exception ex) + { + // should never get here + Logger.LogCritical(ex, "Sendings failed"); + } + #endregion + } + } + + public async Task Subscribe(IClientProxy client, string connectionId, TicketTransfersParameter parameter) + { + Task sending = Task.CompletedTask; + try + { + await Sema.WaitAsync(); + Logger.LogDebug("New subscription..."); + + #region check limits + if (Limits.TryGetValue(connectionId, out var cnt) && cnt >= Config.MaxTicketTransfersSubscriptions) + throw new HubException($"Subscriptions limit exceeded"); + + if (cnt > 0) // reuse already allocated string + connectionId = Limits.Keys.First(x => x == connectionId); + #endregion + + #region add to subs + if (parameter.Account != null) + { + if (!AccountSubs.TryGetValue(parameter.Account, out var accountSub)) + { + accountSub = new(); + AccountSubs.Add(parameter.Account, accountSub); + } + if (parameter.Ticketer != null) + { + accountSub.Ticketers ??= new(4); + if (!accountSub.Ticketers.TryGetValue(parameter.Ticketer, out var ticketerSub)) + { + ticketerSub = new(); + accountSub.Ticketers.Add(parameter.Ticketer, ticketerSub); + } + if (parameter.TicketId is long ticketId) + { + ticketerSub.Tickets ??= new(4); + TryAdd(ticketerSub.Tickets, ticketId, connectionId); + } + else + { + ticketerSub.All ??= new(4); + TryAdd(ticketerSub.All, connectionId); + } + } + else + { + accountSub.All ??= new(4); + TryAdd(accountSub.All, connectionId); + } + } + else if (parameter.Ticketer != null) + { + if (!TicketerSubs.TryGetValue(parameter.Ticketer, out var ticketerSub)) + { + ticketerSub = new(); + TicketerSubs.Add(parameter.Ticketer, ticketerSub); + } + if (parameter.TicketId is long ticketId) + { + ticketerSub.Tickets ??= new(4); + TryAdd(ticketerSub.Tickets, ticketId, connectionId); + } + else + { + ticketerSub.All ??= new(); + TryAdd(ticketerSub.All, connectionId); + } + } + else + { + TryAdd(AllSubs, connectionId); + } + #endregion + + #region add to group + await Context.Groups.AddToGroupAsync(connectionId, TicketTransfersGroup); + #endregion + + sending = client.SendState(TicketTransfersChannel, State.Current.Level); + + Logger.LogDebug("Client {id} subscribed with state {state}", connectionId, State.Current.Level); + return State.Current.Level; + } + catch (HubException) + { + throw; + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to add subscription"); + return 0; + } + finally + { + Sema.Release(); + try + { + await sending; + } + catch (Exception ex) + { + // should never get here + Logger.LogCritical(ex, "Sending failed"); + } + } + } + + public void Unsubscribe(string connectionId) + { + try + { + Sema.Wait(); + if (!Limits.ContainsKey(connectionId)) return; + Logger.LogDebug("Remove subscription..."); + + #region all subs + TryRemove(AllSubs, connectionId); + #endregion + + #region account subs + var emptyAccountSubs = new List(); + foreach (var (account, accountSub) in AccountSubs) + { + accountSub.All = TryRemove(accountSub.All, connectionId); + if (accountSub.Ticketers != null) + { + var emptyAccountTicketerSubs = new List(); + foreach (var (ticketer, ticketerSub) in accountSub.Ticketers) + { + ticketerSub.All = TryRemove(ticketerSub.All, connectionId); + ticketerSub.Tickets = TryRemove(ticketerSub.Tickets, connectionId); + + if (ticketerSub.Empty) + emptyAccountTicketerSubs.Add(ticketer); + } + foreach (var ticketer in emptyAccountTicketerSubs) + accountSub.Ticketers.Remove(ticketer); + + if (accountSub.Ticketers.Count == 0) + accountSub.Ticketers = null; + } + if (accountSub.Empty) + emptyAccountSubs.Add(account); + } + foreach (var account in emptyAccountSubs) + AccountSubs.Remove(account); + #endregion + + #region ticketer subs + var emptyTicketerSubs = new List(); + foreach (var (ticketer, ticketerSub) in TicketerSubs) + { + ticketerSub.All = TryRemove(ticketerSub.All, connectionId); + ticketerSub.Tickets = TryRemove(ticketerSub.Tickets, connectionId); + + if (ticketerSub.Empty) + emptyTicketerSubs.Add(ticketer); + } + foreach (var ticketer in emptyTicketerSubs) + TicketerSubs.Remove(ticketer); + #endregion + + if (Limits[connectionId] != 0) + Logger.LogCritical("Failed to unsubscribe {id}: {cnt} subs left", connectionId, Limits[connectionId]); + Limits.Remove(connectionId); + + Logger.LogDebug("Client {id} unsubscribed", connectionId); + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to remove subscription"); + } + finally + { + Sema.Release(); + } + } + + private static void TryAdd(Dictionary> subs, TSubKey key, string connectionId) + { + if (!subs.TryGetValue(key, out var set)) + { + set = new(4); + subs.Add(key, set); + } + + if (set.Add(connectionId)) + Limits[connectionId] = Limits.GetValueOrDefault(connectionId) + 1; + } + + private static void TryAdd(HashSet set, string connectionId) + { + if (set.Add(connectionId)) + Limits[connectionId] = Limits.GetValueOrDefault(connectionId) + 1; + } + + private static Dictionary> TryRemove(Dictionary> subs, string connectionId) + { + if (subs == null) return null; + foreach (var (key, value) in subs) + { + if (value.Remove(connectionId)) + Limits[connectionId]--; + + if (value.Count == 0) + subs.Remove(key); + } + if (subs.Count == 0) return null; + return subs; + } + + private static HashSet TryRemove(HashSet set, string connectionId) + { + if (set == null) return null; + if (set.Remove(connectionId)) + { + Limits[connectionId]--; + if (set.Count == 0) return null; + } + return set; + } + + private static IEnumerable Distinct(List items) + { + var set = new HashSet(items.Count); + foreach (var item in items) + if (set.Add(item.Id)) + yield return item; + } + } +} diff --git a/Tzkt.Api/Websocket/WebsocketConfig.cs b/Tzkt.Api/Websocket/WebsocketConfig.cs index 7b57428de..27141d41d 100644 --- a/Tzkt.Api/Websocket/WebsocketConfig.cs +++ b/Tzkt.Api/Websocket/WebsocketConfig.cs @@ -12,6 +12,8 @@ public class WebsocketConfig public int MaxAccountsSubscriptions { get; set; } = 50; public int MaxTokenBalancesSubscriptions { get; set; } = 50; public int MaxTokenTransfersSubscriptions { get; set; } = 50; + public int MaxTicketBalancesSubscriptions { get; set; } = 50; + public int MaxTicketTransfersSubscriptions { get; set; } = 50; } public static class CacheConfigExt diff --git a/Tzkt.Api/appsettings.json b/Tzkt.Api/appsettings.json index 9cff53740..0d2063e76 100644 --- a/Tzkt.Api/appsettings.json +++ b/Tzkt.Api/appsettings.json @@ -17,7 +17,9 @@ "MaxEventSubscriptions": 50, "MaxAccountsSubscriptions": 50, "MaxTokenBalancesSubscriptions": 50, - "MaxTokenTransfersSubscriptions": 50 + "MaxTokenTransfersSubscriptions": 50, + "MaxTicketBalancesSubscriptions": 50, + "MaxTicketTransfersSubscriptions": 50 }, "RpcHelpers": { "Enabled": false, diff --git a/Tzkt.Data/Migrations/20230818112210_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230822151754_Tickets.Designer.cs similarity index 99% rename from Tzkt.Data/Migrations/20230818112210_Tickets.Designer.cs rename to Tzkt.Data/Migrations/20230822151754_Tickets.Designer.cs index c5b65f8bc..5538be522 100644 --- a/Tzkt.Data/Migrations/20230818112210_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230822151754_Tickets.Designer.cs @@ -13,7 +13,7 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230818112210_Tickets")] + [Migration("20230822151754_Tickets")] partial class Tickets { /// @@ -3733,9 +3733,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("Level") .HasColumnType("integer"); - b.Property("MigrationId") - .HasColumnType("bigint"); - b.Property("SmartRollupExecuteId") .HasColumnType("bigint"); @@ -3764,9 +3761,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("Level"); - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - b.HasIndex("SmartRollupExecuteId") .HasFilter("\"SmartRollupExecuteId\" is not null"); diff --git a/Tzkt.Data/Migrations/20230818112210_Tickets.cs b/Tzkt.Data/Migrations/20230822151754_Tickets.cs similarity index 97% rename from Tzkt.Data/Migrations/20230818112210_Tickets.cs rename to Tzkt.Data/Migrations/20230822151754_Tickets.cs index a7af6364e..47cf33d05 100644 --- a/Tzkt.Data/Migrations/20230818112210_Tickets.cs +++ b/Tzkt.Data/Migrations/20230822151754_Tickets.cs @@ -151,8 +151,7 @@ protected override void Up(MigrationBuilder migrationBuilder) ToId = table.Column(type: "integer", nullable: true), TransferTicketId = table.Column(type: "bigint", nullable: true), TransactionId = table.Column(type: "bigint", nullable: true), - SmartRollupExecuteId = table.Column(type: "bigint", nullable: true), - MigrationId = table.Column(type: "bigint", nullable: true) + SmartRollupExecuteId = table.Column(type: "bigint", nullable: true) }, constraints: table => { @@ -251,12 +250,6 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "TicketTransfers", column: "Level"); - migrationBuilder.CreateIndex( - name: "IX_TicketTransfers_MigrationId", - table: "TicketTransfers", - column: "MigrationId", - filter: "\"MigrationId\" is not null"); - migrationBuilder.CreateIndex( name: "IX_TicketTransfers_SmartRollupExecuteId", table: "TicketTransfers", diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index e07f8ff69..1ae0e9196 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3730,9 +3730,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Level") .HasColumnType("integer"); - b.Property("MigrationId") - .HasColumnType("bigint"); - b.Property("SmartRollupExecuteId") .HasColumnType("bigint"); @@ -3761,9 +3758,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Level"); - b.HasIndex("MigrationId") - .HasFilter("\"MigrationId\" is not null"); - b.HasIndex("SmartRollupExecuteId") .HasFilter("\"SmartRollupExecuteId\" is not null"); diff --git a/Tzkt.Data/Models/Operations/TransactionOperation.cs b/Tzkt.Data/Models/Operations/TransactionOperation.cs index 08dec3ea9..801d7c0af 100644 --- a/Tzkt.Data/Models/Operations/TransactionOperation.cs +++ b/Tzkt.Data/Models/Operations/TransactionOperation.cs @@ -23,8 +23,6 @@ public class TransactionOperation : ContractOperation public short? InternalTransactions { get; set; } public int? EventsCount { get; set; } - - //TODO Make sure we don't need to put it to ContractOperation. public int? TicketTransfers { get; set; } #region relations diff --git a/Tzkt.Data/Models/Scripts/TicketBalance.cs b/Tzkt.Data/Models/Scripts/TicketBalance.cs index 0221fbeb8..53ea78db1 100644 --- a/Tzkt.Data/Models/Scripts/TicketBalance.cs +++ b/Tzkt.Data/Models/Scripts/TicketBalance.cs @@ -1,5 +1,4 @@ -using System.ComponentModel.DataAnnotations.Schema; -using System.Numerics; +using System.Numerics; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; @@ -9,7 +8,6 @@ public class TicketBalance { public long Id { get; set; } - //TODO Do we need ticketer here? public int TicketerId { get; set; } public long TicketId { get; set; } public int AccountId { get; set; } diff --git a/Tzkt.Data/Models/Scripts/TicketTransfer.cs b/Tzkt.Data/Models/Scripts/TicketTransfer.cs index dcee75914..d177dde71 100644 --- a/Tzkt.Data/Models/Scripts/TicketTransfer.cs +++ b/Tzkt.Data/Models/Scripts/TicketTransfer.cs @@ -18,10 +18,6 @@ public class TicketTransfer public long? TransferTicketId { get; set; } public long? TransactionId { get; set; } public long? SmartRollupExecuteId { get; set; } - - //TODO Do we need to add MigrationId here? - - public long? MigrationId { get; set; } } public static class TicketTransferModel @@ -70,10 +66,6 @@ public static void BuildTicketTransferModel(this ModelBuilder modelBuilder) .HasIndex(x => x.TransactionId) .HasFilter($@"""{nameof(TicketTransfer.TransactionId)}"" is not null"); - modelBuilder.Entity() - .HasIndex(x => x.MigrationId) - .HasFilter($@"""{nameof(TicketTransfer.MigrationId)}"" is not null"); - modelBuilder.Entity() .HasIndex(x => x.FromId) .HasFilter($@"""{nameof(TicketTransfer.FromId)}"" is not null"); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index e80b527b4..0fb879a55 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -71,6 +71,11 @@ public virtual async Task Apply() foreach (var (op, opUpdates) in Updates) { + if (op.Level == 5) + Console.WriteLine($"Check this"); + + op.Block.Events |= BlockEvents.Tickets; + var updatesDict = new Dictionary>(); foreach (var upd in opUpdates) @@ -87,9 +92,6 @@ public virtual async Task Apply() foreach (var (ticket, updates) in updatesDict) { - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.Tickets; - if (updates.Count == 1 || updates.BigSum(x => x.Amount) != BigInteger.Zero) { foreach (var ticketUpdate in updates) @@ -102,19 +104,16 @@ public virtual async Task Apply() else if (updates.Count(x => x.Amount < BigInteger.Zero) == 1) { var from = updates.First(x => x.Amount < BigInteger.Zero); - foreach (var ticketUpdate in updates) + foreach (var ticketUpdate in updates.Where(x => x.Amount > BigInteger.Zero)) { - //TODO Will we add transfers to oneself? For instance https://rpc.tzkt.io/sc39/chains/main/blocks/77 - if (from.Account == ticketUpdate.Account) continue; TransferTickets(op, ticket, from.Account, ticketUpdate.Account, ticketUpdate.Amount); } } else if (updates.Count(x => x.Amount > BigInteger.Zero) == 1) { var to = updates.First(x => x.Amount > BigInteger.Zero); - foreach (var ticketUpdate in updates) + foreach (var ticketUpdate in updates.Where(x => x.Amount < BigInteger.Zero)) { - if (to.Account == ticketUpdate.Account) continue; TransferTickets(op, ticket, ticketUpdate.Account, to.Account, ticketUpdate.Amount); } } @@ -154,10 +153,6 @@ Account GetOrCreateAccount(ManagerOperation op, string address) }; Db.Accounts.Add(account); Cache.Accounts.Add(account); - - //TODO Do we need to attach it twice? - Db.TryAttach(op.Block); - op.Block.Events |= BlockEvents.NewAccounts; } return account; } @@ -173,7 +168,7 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic { Id = op switch { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransactionOperation transaction => Cache.AppState.NextSubId(transaction), TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), _ => throw new ArgumentOutOfRangeException(nameof(op)) @@ -181,7 +176,7 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic TicketerId = contract.Id, FirstMinterId = op switch { - ContractOperation contractOperation => contractOperation.InitiatorId ?? contractOperation.SenderId, + TransactionOperation transaction => transaction.InitiatorId ?? transaction.SenderId, TransferTicketOperation transfer => transfer.SenderId, SmartRollupExecuteOperation sr => sr.SenderId, _ => throw new ArgumentOutOfRangeException(nameof(op)) @@ -219,7 +214,7 @@ TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Accou { Id = op switch { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransactionOperation transaction => Cache.AppState.NextSubId(transaction), TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), _ => throw new ArgumentOutOfRangeException(nameof(op)) @@ -256,7 +251,6 @@ void TransferTickets(ManagerOperation op, Ticket ticket, var to = GetOrCreateAccount(op, toAddress); var toBalance = GetOrCreateTicketBalance(op, ticket, to); - //TODO Something wrong here, sometimes ticketTransfersCount is null. switch (op) { case TransferTicketOperation transferTicket: @@ -310,7 +304,7 @@ void TransferTickets(ManagerOperation op, Ticket ticket, { Id = op switch { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransactionOperation transaction => Cache.AppState.NextSubId(transaction), TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), _ => throw new ArgumentOutOfRangeException(nameof(op)) @@ -375,7 +369,7 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, { Id = op switch { - ContractOperation contractOperation => Cache.AppState.NextSubId(contractOperation), + TransactionOperation transaction => Cache.AppState.NextSubId(transaction), TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), _ => throw new ArgumentOutOfRangeException(nameof(op)) @@ -563,6 +557,7 @@ public virtual async Task Revert(Block block) } } + //TODO TICKETS Make test for mint, burn and transfer in one operation foreach (var ticketBalance in ticketBalancesToRemove) { if (ticketBalance.FirstLevel == block.Level) From e69eba7d74b18230f1f74b9ae54a87fffa12fb19 Mon Sep 17 00:00:00 2001 From: dmir Date: Tue, 22 Aug 2023 21:09:18 +0300 Subject: [PATCH 35/51] Fix processors --- .../Parameters/TicketTransfersParameter.cs | 4 --- .../Processors/TicketBalancesProcessor.cs | 25 ++-------------- .../Processors/TicketTransfersProcessor.cs | 29 ++----------------- 3 files changed, 4 insertions(+), 54 deletions(-) diff --git a/Tzkt.Api/Websocket/Parameters/TicketTransfersParameter.cs b/Tzkt.Api/Websocket/Parameters/TicketTransfersParameter.cs index a23fa9732..b68612834 100644 --- a/Tzkt.Api/Websocket/Parameters/TicketTransfersParameter.cs +++ b/Tzkt.Api/Websocket/Parameters/TicketTransfersParameter.cs @@ -7,7 +7,6 @@ public class TicketTransfersParameter { public string Account { get; set; } public string Ticketer { get; set; } - public long? TicketId { get; set; } public void EnsureValid() { @@ -16,9 +15,6 @@ public void EnsureValid() if (Ticketer != null && !Regex.IsMatch(Ticketer, "^KT1[0-9A-Za-z]{33}$")) throw new HubException("Invalid contract address"); - - if (TicketId is < 0) - throw new HubException("Invalid ticketId"); } } } \ No newline at end of file diff --git a/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs b/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs index 56e5c95d4..15826e331 100644 --- a/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs @@ -28,9 +28,8 @@ class AccountSub class TicketerSub { public HashSet All { get; set; } - public Dictionary> Tickets { get; set; } - public bool Empty => All == null && Tickets == null; + public bool Empty => All == null; } #endregion @@ -140,10 +139,6 @@ void Add(HashSet subs, TicketBalance balance) { if (accountTicketerSubs.All != null) Add(accountTicketerSubs.All, balance); - - if (accountTicketerSubs.Tickets != null) - if (accountTicketerSubs.Tickets.TryGetValue(balance.Ticket.Id, out var ticketerTicketSubs)) - Add(ticketerTicketSubs, balance); } } } @@ -154,10 +149,6 @@ void Add(HashSet subs, TicketBalance balance) { if (ticketerSubs.All != null) Add(ticketerSubs.All, balance); - - if (ticketerSubs.Tickets != null) - if (ticketerSubs.Tickets.TryGetValue(balance.Ticket.Id, out var ticketerTicketSubs)) - Add(ticketerTicketSubs, balance); } #endregion } @@ -232,12 +223,7 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke { ticketerSub = new(); accountSub.Ticketers.Add(parameter.Ticketer, ticketerSub); - } - if (parameter.TicketId is long ticketId) - { - ticketerSub.Tickets ??= new(4); - TryAdd(ticketerSub.Tickets, ticketId, connectionId); - } + } else { ticketerSub.All ??= new(4); @@ -257,11 +243,6 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke ticketerSub = new(); TicketerSubs.Add(parameter.Ticketer, ticketerSub); } - if (parameter.TicketId is long ticketId) - { - ticketerSub.Tickets ??= new(4); - TryAdd(ticketerSub.Tickets, ticketId, connectionId); - } else { ticketerSub.All ??= new(); @@ -330,7 +311,6 @@ public void Unsubscribe(string connectionId) foreach (var (ticketer, ticketerSub) in accountSub.Ticketers) { ticketerSub.All = TryRemove(ticketerSub.All, connectionId); - ticketerSub.Tickets = TryRemove(ticketerSub.Tickets, connectionId); if (ticketerSub.Empty) emptyAccountTicketerSubs.Add(ticketer); @@ -353,7 +333,6 @@ public void Unsubscribe(string connectionId) foreach (var (ticketer, ticketerSub) in TicketerSubs) { ticketerSub.All = TryRemove(ticketerSub.All, connectionId); - ticketerSub.Tickets = TryRemove(ticketerSub.Tickets, connectionId); if (ticketerSub.Empty) emptyTicketerSubs.Add(ticketer); diff --git a/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs b/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs index 1a257356e..ceeb0160e 100644 --- a/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs @@ -28,9 +28,8 @@ class AccountSub class TicketerSub { public HashSet All { get; set; } - public Dictionary> Tickets { get; set; } - public bool Empty => All == null && Tickets == null; + public bool Empty => All == null; } #endregion @@ -142,10 +141,6 @@ void Add(HashSet subs, TicketTransfer transfer) { if (accountTicketerSubs.All != null) Add(accountTicketerSubs.All, transfer); - - if (accountTicketerSubs.Tickets != null) - if (accountTicketerSubs.Tickets.TryGetValue(transfer.Ticket.Id, out var ticketerTicketSubs)) - Add(ticketerTicketSubs, transfer); } } } @@ -163,10 +158,6 @@ void Add(HashSet subs, TicketTransfer transfer) { if (accountTicketerSubs.All != null) Add(accountTicketerSubs.All, transfer); - - if (accountTicketerSubs.Tickets != null) - if (accountTicketerSubs.Tickets.TryGetValue(transfer.Ticket.Id, out var ticketerTicketSubs)) - Add(ticketerTicketSubs, transfer); } } } @@ -178,10 +169,6 @@ void Add(HashSet subs, TicketTransfer transfer) { if (ticketerSubs.All != null) Add(ticketerSubs.All, transfer); - - if (ticketerSubs.Tickets != null) - if (ticketerSubs.Tickets.TryGetValue(transfer.Ticket.Id, out var ticketerTicketSubs)) - Add(ticketerTicketSubs, transfer); } #endregion } @@ -256,12 +243,7 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke { ticketerSub = new(); accountSub.Ticketers.Add(parameter.Ticketer, ticketerSub); - } - if (parameter.TicketId is long ticketId) - { - ticketerSub.Tickets ??= new(4); - TryAdd(ticketerSub.Tickets, ticketId, connectionId); - } + } else { ticketerSub.All ??= new(4); @@ -281,11 +263,6 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke ticketerSub = new(); TicketerSubs.Add(parameter.Ticketer, ticketerSub); } - if (parameter.TicketId is long ticketId) - { - ticketerSub.Tickets ??= new(4); - TryAdd(ticketerSub.Tickets, ticketId, connectionId); - } else { ticketerSub.All ??= new(); @@ -354,7 +331,6 @@ public void Unsubscribe(string connectionId) foreach (var (ticketer, ticketerSub) in accountSub.Ticketers) { ticketerSub.All = TryRemove(ticketerSub.All, connectionId); - ticketerSub.Tickets = TryRemove(ticketerSub.Tickets, connectionId); if (ticketerSub.Empty) emptyAccountTicketerSubs.Add(ticketer); @@ -377,7 +353,6 @@ public void Unsubscribe(string connectionId) foreach (var (ticketer, ticketerSub) in TicketerSubs) { ticketerSub.All = TryRemove(ticketerSub.All, connectionId); - ticketerSub.Tickets = TryRemove(ticketerSub.Tickets, connectionId); if (ticketerSub.Empty) emptyTicketerSubs.Add(ticketer); From 7b9e6205d2ab122216580570ecbd60558726bf59 Mon Sep 17 00:00:00 2001 From: dmir Date: Wed, 23 Aug 2023 13:47:52 +0300 Subject: [PATCH 36/51] Ticket Processors fix --- .../Processors/TicketBalancesProcessor.cs | 17 +++++++---------- .../Processors/TicketTransfersProcessor.cs | 17 +++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs b/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs index 15826e331..fd1cfc549 100644 --- a/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs @@ -216,6 +216,7 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke accountSub = new(); AccountSubs.Add(parameter.Account, accountSub); } + if (parameter.Ticketer != null) { accountSub.Ticketers ??= new(4); @@ -224,11 +225,9 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke ticketerSub = new(); accountSub.Ticketers.Add(parameter.Ticketer, ticketerSub); } - else - { - ticketerSub.All ??= new(4); - TryAdd(ticketerSub.All, connectionId); - } + + ticketerSub.All ??= new(4); + TryAdd(ticketerSub.All, connectionId); } else { @@ -243,11 +242,9 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke ticketerSub = new(); TicketerSubs.Add(parameter.Ticketer, ticketerSub); } - else - { - ticketerSub.All ??= new(); - TryAdd(ticketerSub.All, connectionId); - } + + ticketerSub.All ??= new(); + TryAdd(ticketerSub.All, connectionId); } else { diff --git a/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs b/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs index ceeb0160e..e5fae5cce 100644 --- a/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs @@ -236,6 +236,7 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke accountSub = new(); AccountSubs.Add(parameter.Account, accountSub); } + if (parameter.Ticketer != null) { accountSub.Ticketers ??= new(4); @@ -244,11 +245,9 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke ticketerSub = new(); accountSub.Ticketers.Add(parameter.Ticketer, ticketerSub); } - else - { - ticketerSub.All ??= new(4); - TryAdd(ticketerSub.All, connectionId); - } + + ticketerSub.All ??= new(4); + TryAdd(ticketerSub.All, connectionId); } else { @@ -263,11 +262,9 @@ public async Task Subscribe(IClientProxy client, string connectionId, Ticke ticketerSub = new(); TicketerSubs.Add(parameter.Ticketer, ticketerSub); } - else - { - ticketerSub.All ??= new(); - TryAdd(ticketerSub.All, connectionId); - } + + ticketerSub.All ??= new(); + TryAdd(ticketerSub.All, connectionId); } else { From b642c793f4699b9fb323625147407584fb83cfa5 Mon Sep 17 00:00:00 2001 From: dmir Date: Wed, 23 Aug 2023 17:09:43 +0300 Subject: [PATCH 37/51] Remove metadata --- ...Designer.cs => 20230823140932_Tickets.Designer.cs} | 10 +--------- ...822151754_Tickets.cs => 20230823140932_Tickets.cs} | 10 +--------- Tzkt.Data/Migrations/TzktContextModelSnapshot.cs | 8 -------- Tzkt.Data/Models/Scripts/Ticket.cs | 11 ----------- 4 files changed, 2 insertions(+), 37 deletions(-) rename Tzkt.Data/Migrations/{20230822151754_Tickets.Designer.cs => 20230823140932_Tickets.Designer.cs} (99%) rename Tzkt.Data/Migrations/{20230822151754_Tickets.cs => 20230823140932_Tickets.cs} (97%) diff --git a/Tzkt.Data/Migrations/20230822151754_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs similarity index 99% rename from Tzkt.Data/Migrations/20230822151754_Tickets.Designer.cs rename to Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs index 5538be522..c0c4fffc8 100644 --- a/Tzkt.Data/Migrations/20230822151754_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs @@ -13,7 +13,7 @@ namespace Tzkt.Data.Migrations { [DbContext(typeof(TzktContext))] - [Migration("20230822151754_Tickets")] + [Migration("20230823140932_Tickets")] partial class Tickets { /// @@ -3615,9 +3615,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("LastLevel") .HasColumnType("integer"); - b.Property("Metadata") - .HasColumnType("jsonb"); - b.Property("RawContent") .HasColumnType("bytea"); @@ -3651,11 +3648,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("LastLevel"); - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - b.HasIndex("TicketerId"); b.ToTable("Tickets"); diff --git a/Tzkt.Data/Migrations/20230822151754_Tickets.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.cs similarity index 97% rename from Tzkt.Data/Migrations/20230822151754_Tickets.cs rename to Tzkt.Data/Migrations/20230823140932_Tickets.cs index 47cf33d05..ec1a5cc21 100644 --- a/Tzkt.Data/Migrations/20230822151754_Tickets.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.cs @@ -129,8 +129,7 @@ protected override void Up(MigrationBuilder migrationBuilder) RawContent = table.Column(type: "bytea", nullable: true), RawType = table.Column(type: "bytea", nullable: true), JsonContent = table.Column(type: "jsonb", nullable: true), - JsonType = table.Column(type: "jsonb", nullable: true), - Metadata = table.Column(type: "jsonb", nullable: true) + JsonType = table.Column(type: "jsonb", nullable: true) }, constraints: table => { @@ -221,13 +220,6 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "Tickets", column: "LastLevel"); - migrationBuilder.CreateIndex( - name: "IX_Tickets_Metadata", - table: "Tickets", - column: "Metadata") - .Annotation("Npgsql:IndexMethod", "gin") - .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); - migrationBuilder.CreateIndex( name: "IX_Tickets_TicketerId", table: "Tickets", diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 1ae0e9196..2118d886a 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3612,9 +3612,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("LastLevel") .HasColumnType("integer"); - b.Property("Metadata") - .HasColumnType("jsonb"); - b.Property("RawContent") .HasColumnType("bytea"); @@ -3648,11 +3645,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("LastLevel"); - b.HasIndex("Metadata"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Metadata"), "gin"); - NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("Metadata"), new[] { "jsonb_path_ops" }); - b.HasIndex("TicketerId"); b.ToTable("Tickets"); diff --git a/Tzkt.Data/Models/Scripts/Ticket.cs b/Tzkt.Data/Models/Scripts/Ticket.cs index 053af8bbd..b46440c2b 100644 --- a/Tzkt.Data/Models/Scripts/Ticket.cs +++ b/Tzkt.Data/Models/Scripts/Ticket.cs @@ -40,11 +40,6 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) #endregion #region props - // shadow property - modelBuilder.Entity() - .Property("Metadata") - .HasColumnType("jsonb"); - modelBuilder.Entity() .Property(x => x.JsonContent) .HasColumnType("jsonb"); @@ -84,12 +79,6 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.LastLevel); - - // shadow property - modelBuilder.Entity() - .HasIndex("Metadata") - .HasMethod("gin") - .HasOperators("jsonb_path_ops"); #endregion } } From 56b2eb373d32c55c21e2bc2911ecd363652c6b4b Mon Sep 17 00:00:00 2001 From: dmir Date: Wed, 23 Aug 2023 17:16:28 +0300 Subject: [PATCH 38/51] String to JsonElement for GetTicketBalance --- Tzkt.Sync/Protocols/Abstract/IRpc.cs | 2 +- Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs | 2 +- Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs | 2 +- .../Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs | 2 +- Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tzkt.Sync/Protocols/Abstract/IRpc.cs b/Tzkt.Sync/Protocols/Abstract/IRpc.cs index c28497e63..8710224b2 100644 --- a/Tzkt.Sync/Protocols/Abstract/IRpc.cs +++ b/Tzkt.Sync/Protocols/Abstract/IRpc.cs @@ -22,7 +22,7 @@ public interface IRpc Task GetActiveDelegatesAsync(int level); Task GetDelegateParticipationAsync(int level, string address); Task GetCycleAsync(int level, int cycle); - Task GetTicketBalance(int level, string address, string ticket); + Task GetTicketBalance(int level, string address, string ticket); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs index 8a5283c5d..6c07449bb 100644 --- a/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Genesis/Rpc/Rpc.cs @@ -53,7 +53,7 @@ public Task GetCycleAsync(int level, int cycle) public Task GetDelegateParticipationAsync(int level, string address) => throw new InvalidOperationException(); - public Task GetTicketBalance(int level, string address, string ticket) + public Task GetTicketBalance(int level, string address, string ticket) => throw new InvalidOperationException(); #endregion } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs index 7bb96720a..23fe88835 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Rpc/Rpc.cs @@ -51,7 +51,7 @@ public virtual Task GetCycleAsync(int level, int cycle) public virtual Task GetDelegateParticipationAsync(int level, string address) => throw new InvalidOperationException(); - public virtual Task GetTicketBalance(int level, string address, string ticket) + public virtual Task GetTicketBalance(int level, string address, string ticket) => throw new InvalidOperationException(); #endregion } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs index d3ec68cae..c5f4120c5 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs @@ -22,7 +22,7 @@ protected override async Task TestTicketBalance(int level, TicketBalance balance content = Micheline.FromBytes(ticket.RawContent) }; - if (BigInteger.TryParse(await Rpc.GetTicketBalance(level, account.Address, JsonSerializer.Serialize(update)), out var remoteBalance)) + if (BigInteger.TryParse((await Rpc.GetTicketBalance(level, account.Address, JsonSerializer.Serialize(update))).RequiredString(), out var remoteBalance)) { if (remoteBalance != balance.Balance) throw new Exception($"Diagnostics failed: wrong ticket balance for {account.Address}"); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs index ab1d88eda..bed3ed1c0 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs @@ -8,11 +8,11 @@ class Rpc : Proto12.Rpc { public Rpc(TezosNode node) : base(node) { } - public override Task GetTicketBalance(int level, string address, string ticket) + public override Task GetTicketBalance(int level, string address, string ticket) { return Regex.IsMatch(address, "^sr1[0-9A-Za-z]{33}$") - ? Node.PostAsync($"chains/main/blocks/{level}/context/smart_rollups/smart_rollup/{address}/ticket_balance", ticket) - : Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); + ? Node.PostAsync($"chains/main/blocks/{level}/context/smart_rollups/smart_rollup/{address}/ticket_balance", ticket) + : Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); } } } From cba8bc00adb17b7ebf077355e916e9ceaf85d0bb Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Fri, 25 Aug 2023 14:31:31 +0300 Subject: [PATCH 39/51] Rename `Ticket.ContentType*` to `Ticket.Type*` --- Tzkt.Api/Controllers/TicketsController.cs | 14 ++-- Tzkt.Api/Models/Tickets/Ticket.cs | 15 ++-- Tzkt.Api/Models/Tickets/TicketInfo.cs | 4 +- Tzkt.Api/Parameters/TicketFilter.cs | 10 +-- Tzkt.Api/Parameters/TicketInfoFilter.cs | 4 +- Tzkt.Api/Repositories/TicketsRepository.cs | 74 +++++++++---------- .../20230823140932_Tickets.Designer.cs | 2 +- .../Migrations/20230823140932_Tickets.cs | 2 +- .../Migrations/TzktContextModelSnapshot.cs | 2 +- Tzkt.Data/Models/Scripts/Ticket.cs | 2 +- .../Commits/Operations/TransactionsCommit.cs | 2 +- .../Operations/TransferTicketCommit.cs | 2 +- .../Operations/SmartRollupExecuteCommit.cs | 2 +- .../Handlers/Proto16/Commits/TicketsCommit.cs | 8 +- Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs | 4 +- Tzkt.Sync/Services/Cache/TicketsCache.cs | 20 ++--- 16 files changed, 81 insertions(+), 86 deletions(-) diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index 080920b5c..f958735bb 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -43,9 +43,9 @@ public async Task> GetTicketsCount([FromQuery] TicketFilter fi filter.lastTime != null || filter.lastLevel != null || filter.contentHash != null || - filter.contentTypeHash != null || + filter.typeHash != null || filter.content != null || - filter.contentType != null || + filter.type != null || filter.id != null ) { var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); @@ -124,7 +124,7 @@ public async Task> GetTicketBalancesCount([FromQuery] TicketBa filter.ticket.id != null || filter.ticket.ticketer != null || filter.ticket.contentHash != null || - filter.ticket.contentTypeHash != null) + filter.ticket.typeHash != null) { #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) @@ -214,7 +214,7 @@ public async Task> GetTicketTransfersCount([FromQuery] TicketT filter.smartRollupExecuteId != null || filter.ticket.ticketer != null || filter.ticket.contentHash != null || - filter.ticket.contentTypeHash != null || + filter.ticket.typeHash != null || filter.ticket.id != null) { #region optimizations @@ -300,7 +300,7 @@ public async Task>> GetTicketTransfers( /// /// Returns a list of ticket balances at the end of the specified block. /// Note, this endpoint is quite heavy, therefore at least one of the filters - /// (`account`, `ticket.id`, `ticket.ticketer` with `ticket.contentHash` and `ticket.contentTypeHash`) must be specified. + /// (`account`, `ticket.id`, `ticket.ticketer` with `ticket.contentHash` and `ticket.typeHash`) must be specified. /// /// Level of the block at the end of which historical balances must be calculated /// Filter @@ -321,8 +321,8 @@ public async Task>> GetTicketBalanc filter.ticket.id?.In == null && (filter.ticket.ticketer?.Eq == null && filter.ticket.ticketer?.In == null || filter.ticket.contentHash?.Eq == null && filter.ticket.contentHash?.In == null || - filter.ticket.contentTypeHash?.Eq == null && filter.ticket.contentTypeHash?.In == null)) - return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.ticketer` with `ticket.contentHash` and `ticket.contentTypeHash`) must be specified"); + filter.ticket.typeHash?.Eq == null && filter.ticket.typeHash?.In == null)) + return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.ticketer` with `ticket.contentHash` and `ticket.typeHash`) must be specified"); #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) diff --git a/Tzkt.Api/Models/Tickets/Ticket.cs b/Tzkt.Api/Models/Tickets/Ticket.cs index 68f232888..600a8942a 100644 --- a/Tzkt.Api/Models/Tickets/Ticket.cs +++ b/Tzkt.Api/Models/Tickets/Ticket.cs @@ -1,7 +1,4 @@ -using System; -using NJsonSchema.Annotations; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class Ticket { @@ -14,25 +11,23 @@ public class Ticket /// /// Contract, created the ticket. /// - public Alias Ticketer { get; set; } - + public Alias Ticketer { get; set; } /// /// Micheline type of the content /// - public RawJson ContentType { get; set; } + public RawJson Type { get; set; } /// /// Ticket content /// - public object Content { get; set; } - + public object Content { get; set; } /// /// 32-bit hash of the ticket content type. /// This field can be used for searching similar tickets (which have the same type). /// - public int ContentTypeHash { get; set; } + public int TypeHash { get; set; } /// /// 32-bit hash of the ticket content. diff --git a/Tzkt.Api/Models/Tickets/TicketInfo.cs b/Tzkt.Api/Models/Tickets/TicketInfo.cs index da283e631..83a67f203 100644 --- a/Tzkt.Api/Models/Tickets/TicketInfo.cs +++ b/Tzkt.Api/Models/Tickets/TicketInfo.cs @@ -17,7 +17,7 @@ public class TicketInfo /// /// Micheline type of the content /// - public RawJson ContentType { get; set; } + public RawJson Type { get; set; } /// /// Ticket content @@ -28,7 +28,7 @@ public class TicketInfo /// 32-bit hash of the ticket content type. /// This field can be used for searching similar tickets (which have the same type). /// - public int ContentTypeHash { get; set; } + public int TypeHash { get; set; } /// /// 32-bit hash of the ticket content. diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs index 0583d89b3..1acb186a3 100644 --- a/Tzkt.Api/Parameters/TicketFilter.cs +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -57,7 +57,7 @@ public class TicketFilter : INormalizable /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). /// Click on the parameter to expand more details. /// - public Int32Parameter contentTypeHash { get; set; } + public Int32Parameter typeHash { get; set; } /// /// Filter by content. @@ -69,18 +69,18 @@ public class TicketFilter : INormalizable /// /// Filter by content type. - /// Note, this parameter supports the following format: `contentType{.path?}{.mode?}=...`, - /// so you can specify a path to a particular field to filter by (for example, `?contentType.prim.in=string,int`). + /// Note, this parameter supports the following format: `type{.path?}{.mode?}=...`, + /// so you can specify a path to a particular field to filter by (for example, `?type.prim.in=string,int`). /// Click on the parameter to expand more details. /// - public JsonParameter contentType { get; set; } + public JsonParameter type { get; set; } public string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("ticketer", ticketer), ("firstMinter", firstMinter), ("firstLevel", firstLevel), ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("contentHash", contentHash), - ("contentTypeHash", contentTypeHash), ("content", content), ("contentType", contentType)); + ("typeHash", typeHash), ("content", content), ("type", type)); } } } diff --git a/Tzkt.Api/Parameters/TicketInfoFilter.cs b/Tzkt.Api/Parameters/TicketInfoFilter.cs index 906ef26d9..454e24402 100644 --- a/Tzkt.Api/Parameters/TicketInfoFilter.cs +++ b/Tzkt.Api/Parameters/TicketInfoFilter.cs @@ -27,12 +27,12 @@ public class TicketInfoFilter : INormalizable /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). /// Click on the parameter to expand more details. /// - public Int32Parameter contentTypeHash { get; set; } + public Int32Parameter typeHash { get; set; } public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("ticketer", ticketer), ("contentHash", contentHash), ("contentTypeHash", contentTypeHash)); + ("id", id), ("ticketer", ticketer), ("contentHash", contentHash), ("typeHash", typeHash)); } } } diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index 73315c254..b71113508 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -42,8 +42,8 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati case "totalBurned": columns.Add(@"""TotalBurned"""); break; case "totalSupply": columns.Add(@"""TotalSupply"""); break; case "contentHash": columns.Add(@"o.""ContentHash"""); break; - case "contentTypeHash": columns.Add(@"o.""ContentTypeHash"""); break; - case "contentType": + case "typeHash": columns.Add(@"o.""TypeHash"""); break; + case "type": if (field.Path == null) { columns.Add(format <= MichelineFormat.JsonString ? @"""JsonType""" : @"""RawType"""); @@ -92,9 +92,9 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati .Filter("FirstLevel", filter.firstTime) .Filter("LastLevel", filter.lastLevel) .Filter("LastLevel", filter.lastTime) - .Filter("ContentTypeHash", filter.contentTypeHash) + .Filter("TypeHash", filter.typeHash) .Filter("ContentHash", filter.contentHash) - .Filter("JsonType", filter.contentType) + .Filter("JsonType", filter.type) .Filter("JsonContent", filter.content) .Take(pagination, x => x switch { @@ -105,7 +105,7 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati "firstLevel" => (@"""Id""", @"""FirstLevel"""), "lastLevel" => (@"""LastLevel""", @"""LastLevel"""), "contentHash" => (@"""ContentHash""", @"""ContentHash"""), - "contentTypeHash" => (@"""ContentTypeHash""", @"""ContentTypeHash"""), + "typeHash" => (@"""TypeHash""", @"""TypeHash"""), _ => (@"""Id""", @"""Id""") }); @@ -123,9 +123,9 @@ public async Task GetTicketsCount(TicketFilter filter) .Filter("FirstLevel", filter.firstTime) .Filter("LastLevel", filter.lastLevel) .Filter("LastLevel", filter.lastTime) - .Filter("ContentTypeHash", filter.contentTypeHash) + .Filter("TypeHash", filter.typeHash) .Filter("ContentHash", filter.contentHash) - .Filter("JsonType", filter.contentType) + .Filter("JsonType", filter.type) .Filter("JsonContent", filter.content); using var db = GetConnection(); @@ -150,10 +150,10 @@ public async Task> GetTickets(TicketFilter filter, Paginatio TotalMinted = row.TotalMinted, TotalSupply = row.TotalSupply, TransfersCount = row.TransfersCount, - ContentType = FormatType(row, format), + Type = FormatType(row, format), Content = FormatContent(row, format), ContentHash = row.ContentHash, - ContentTypeHash = row.ContentTypeHash + TypeHash = row.TypeHash }); } @@ -185,7 +185,7 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat foreach (var row in rows) result[j++][i] = Accounts.GetAlias(row.TicketerId).Address; break; - case "contentType": + case "type": foreach (var row in rows) result[j++][i] = FormatType(row, format); break; @@ -193,13 +193,13 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat foreach (var row in rows) result[j++][i] = FormatContent(row, format); break; - case "contentTypeHash": + case "typeHash": foreach (var row in rows) - result[j++][i] = row.ContentTypeHash; + result[j++][i] = row.TypeHash; break; case "contentHash": foreach (var row in rows) - result[j++][i] = row.ContentType; + result[j++][i] = row.ContentHash; break; case "firstMinter": foreach (var row in rows) @@ -277,7 +277,7 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi t.""JsonType"" as ""JsonType"", t.""RawType"" as ""RawType"", t.""ContentHash"" as ""ContentHash"", - t.""ContentTypeHash"" as ""ContentTypeHash"", + t.""TypeHash"" as ""TypeHash"", t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { @@ -302,7 +302,7 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi columns.Add(FormatContentQuery(format)); columns.Add(FormatTypeQuery(format)); columns.Add(@"t.""ContentHash"" as ""ContentHash"""); - columns.Add(@"t.""ContentTypeHash"" as ""ContentTypeHash"""); + columns.Add(@"t.""TypeHash"" as ""TypeHash"""); break; } } @@ -326,7 +326,7 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash) + .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) .Take(pagination, x => x switch { "balance" => (@"tb.""Balance""::numeric", @"tb.""Balance""::numeric"), @@ -355,7 +355,7 @@ SELECT COUNT(*) FROM ""TicketBalances"" as tb .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash); + .FilterA(@"t.""TypeHash""", filter.ticket.typeHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -379,10 +379,10 @@ public async Task> GetTicketBalances(TicketBalanceFil Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - ContentType = FormatType(row, format), + Type = FormatType(row, format), Content = FormatContent(row, format), ContentHash = row.ContentHash, - ContentTypeHash = row.ContentTypeHash + TypeHash = row.TypeHash } }); } @@ -446,10 +446,10 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - ContentType = FormatType(row, format), + Type = FormatType(row, format), Content = FormatContent(row, format), ContentHash = row.ContentHash, - ContentTypeHash = row.ContentTypeHash + TypeHash = row.TypeHash }; break; case "ticket.id": @@ -476,7 +476,7 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi foreach (var row in rows) result[j++][i] = FormatContent(row, format); break; - case "ticket.contentType": + case "ticket.type": foreach (var row in rows) result[j++][i] = FormatType(row, format); break; @@ -484,9 +484,9 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi foreach (var row in rows) result[j++][i] = row.ContentHash; break; - case "ticket.contentTypeHash": + case "ticket.typeHash": foreach (var row in rows) - result[j++][i] = row.ContentTypeHash; + result[j++][i] = row.TypeHash; break; } } @@ -514,7 +514,7 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter t.""JsonType"" as ""JsonType"", t.""RawType"" as ""RawType"", t.""ContentHash"" as ""ContentHash"", - t.""ContentTypeHash"" as ""ContentTypeHash"", + t.""TypeHash"" as ""TypeHash"", t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { @@ -540,7 +540,7 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter columns.Add(FormatContentQuery(format)); columns.Add(FormatTypeQuery(format)); columns.Add(@"t.""ContentHash"" as ""ContentHash"""); - columns.Add(@"t.""ContentTypeHash"" as ""ContentTypeHash"""); + columns.Add(@"t.""TypeHash"" as ""TypeHash"""); break; } } @@ -567,7 +567,7 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash) + .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) .Take(pagination, x => x switch { "level" => (@"tr.""Level""", @"tr.""Level"""), @@ -597,7 +597,7 @@ SELECT COUNT(*) FROM ""TicketTransfers"" as tr .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash); + .FilterA(@"t.""TypeHash""", filter.ticket.typeHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); @@ -622,10 +622,10 @@ public async Task> GetTicketTransfers(TicketTransfer Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - ContentType = FormatType(row, format), + Type = FormatType(row, format), Content = FormatContent(row, format), ContentHash = row.ContentHash, - ContentTypeHash = row.ContentTypeHash + TypeHash = row.TypeHash } }); } @@ -701,10 +701,10 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - ContentType = FormatType(row, format), + Type = FormatType(row, format), Content = FormatContent(row, format), ContentHash = row.ContentHash, - ContentTypeHash = row.ContentTypeHash + TypeHash = row.TypeHash }; break; case "ticket.id": @@ -731,7 +731,7 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa foreach (var row in rows) result[j++][i] = FormatContent(row, format); break; - case "ticket.contentType": + case "ticket.type": foreach (var row in rows) result[j++][i] = FormatType(row, format); break; @@ -739,9 +739,9 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa foreach (var row in rows) result[j++][i] = row.ContentHash; break; - case "ticket.contentTypeHash": + case "ticket.typeHash": foreach (var row in rows) - result[j++][i] = row.ContentTypeHash; + result[j++][i] = row.TypeHash; break; } } @@ -793,7 +793,7 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"t.""TicketerId""", filter.ticket.ticketer) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash) + .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) .ResetFilters() .Append("UNION ALL") @@ -806,7 +806,7 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"t.""TicketerId""", filter.ticket.ticketer) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""ContentTypeHash""", filter.ticket.contentTypeHash) + .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) .ResetFilters() .Append(") as tb") diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs index c0c4fffc8..4a212adfc 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs @@ -3594,7 +3594,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ContentHash") .HasColumnType("integer"); - b.Property("ContentTypeHash") + b.Property("TypeHash") .HasColumnType("integer"); b.Property("FirstLevel") diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.cs index ec1a5cc21..739713502 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.cs @@ -125,7 +125,7 @@ protected override void Up(MigrationBuilder migrationBuilder) TotalBurned = table.Column(type: "text", nullable: false), TotalSupply = table.Column(type: "text", nullable: false), ContentHash = table.Column(type: "integer", nullable: false), - ContentTypeHash = table.Column(type: "integer", nullable: false), + TypeHash = table.Column(type: "integer", nullable: false), RawContent = table.Column(type: "bytea", nullable: true), RawType = table.Column(type: "bytea", nullable: true), JsonContent = table.Column(type: "jsonb", nullable: true), diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 2118d886a..502830819 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3591,7 +3591,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ContentHash") .HasColumnType("integer"); - b.Property("ContentTypeHash") + b.Property("TypeHash") .HasColumnType("integer"); b.Property("FirstLevel") diff --git a/Tzkt.Data/Models/Scripts/Ticket.cs b/Tzkt.Data/Models/Scripts/Ticket.cs index b46440c2b..d0c9931ed 100644 --- a/Tzkt.Data/Models/Scripts/Ticket.cs +++ b/Tzkt.Data/Models/Scripts/Ticket.cs @@ -22,7 +22,7 @@ public class Ticket public BigInteger TotalSupply { get; set; } public int ContentHash { get; set; } - public int ContentTypeHash { get; set; } + public int TypeHash { get; set; } public byte[] RawContent { get; set; } public byte[] RawType { get; set; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index 9b7a67f20..20b2a549a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -712,7 +712,7 @@ protected virtual IEnumerable ParseTicketUpdates(string property, RawContent = rawContent, JsonContent = micheType.Humanize(value), JsonType = micheType.ToMicheline().ToJson(), - ContentTypeHash = Script.GetHash(rawType), + TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 8c09d8d95..995f945af 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -221,7 +221,7 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul RawContent = rawContent, JsonContent = micheType.Humanize(value), JsonType = micheType.ToMicheline().ToJson(), - ContentTypeHash = Script.GetHash(rawType), + TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index 3955ad282..47e801adf 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -217,7 +217,7 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul RawContent = rawContent, JsonContent = micheType.Humanize(value), JsonType = micheType.ToMicheline().ToJson(), - ContentTypeHash = Script.GetHash(rawType), + TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index 0fb879a55..926e7d8a4 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -45,7 +45,7 @@ public virtual async Task Apply() foreach (var update in list) { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) - ticketsSet.Add((ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash)); + ticketsSet.Add((ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.TypeHash)); } await Cache.Tickets.Preload(ticketsSet); @@ -54,7 +54,7 @@ public virtual async Task Apply() { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) { - if (Cache.Tickets.TryGet(ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.ContentTypeHash, out var ticket)) + if (Cache.Tickets.TryGet(ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.TypeHash, out var ticket)) { foreach (var upd in update.Updates) { @@ -159,7 +159,7 @@ Account GetOrCreateAccount(ManagerOperation op, string address) Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken ticketToken) { - if (Cache.Tickets.TryGet(contract.Id, ticketToken.ContentHash, ticketToken.ContentTypeHash, out var ticket)) return ticket; + if (Cache.Tickets.TryGet(contract.Id, ticketToken.ContentHash, ticketToken.TypeHash, out var ticket)) return ticket; var state = Cache.AppState.Get(); state.TicketsCount++; @@ -191,7 +191,7 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic JsonContent = ticketToken.JsonContent, JsonType = ticketToken.JsonType, ContentHash = ticketToken.ContentHash, - ContentTypeHash = ticketToken.ContentTypeHash, + TypeHash = ticketToken.TypeHash, }; Db.Tickets.Add(ticket); diff --git a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs index 10404fb95..ebf460d41 100644 --- a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs +++ b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs @@ -11,13 +11,13 @@ public class TicketUpdate public class TicketToken { public string Ticketer { get; set; } - public byte[] RawType { get; set; } public byte[] RawContent { get; set; } + public byte[] RawType { get; set; } public string JsonContent { get; set; } public string JsonType { get; set; } - public int ContentTypeHash { get; set; } public int ContentHash { get; set; } + public int TypeHash { get; set; } } public class Update diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs index 347ab0e60..44f963e1d 100644 --- a/Tzkt.Sync/Services/Cache/TicketsCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -15,7 +15,7 @@ public class TicketsCache public const int MaxItems = 4 * 4096; //TODO: set limits in app settings static readonly Dictionary CachedById = new(MaxItems); - static readonly Dictionary<(int ContractId, int ContentHash, int ContentTypeHash), Ticket> CachedByKey = new(MaxItems); + static readonly Dictionary<(int ContractId, int ContentHash, int TypeHash), Ticket> CachedByKey = new(MaxItems); readonly TzktContext Db; @@ -47,18 +47,18 @@ public void Trim() public void Add(Ticket ticket) { CachedById[ticket.Id] = ticket; - CachedByKey[(ticket.TicketerId, ticket.ContentHash, ticket.ContentTypeHash)] = ticket; + CachedByKey[(ticket.TicketerId, ticket.ContentHash, ticket.TypeHash)] = ticket; } public void Remove(Ticket ticket) { CachedById.Remove(ticket.Id); - CachedByKey.Remove((ticket.TicketerId, ticket.ContentHash, ticket.ContentTypeHash)); + CachedByKey.Remove((ticket.TicketerId, ticket.ContentHash, ticket.TypeHash)); } - public bool Has(int contractId, int contentHash, int contentTypeHash) + public bool Has(int contractId, int contentHash, int typeHash) { - return CachedByKey.ContainsKey((contractId, contentHash, contentTypeHash)); + return CachedByKey.ContainsKey((contractId, contentHash, typeHash)); } public Ticket GetOrAdd(Ticket token) @@ -76,16 +76,16 @@ public Ticket Get(long id) return token; } - public Ticket Get(int contractId, int contentHash, int contentTypeHash) + public Ticket Get(int contractId, int contentHash, int typeHash) { - if (!CachedByKey.TryGetValue((contractId, contentHash, contentTypeHash), out var ticket)) - throw new Exception($"Ticket ({contractId}, {contentHash}, {contentTypeHash}) doesn't exist"); + if (!CachedByKey.TryGetValue((contractId, contentHash, typeHash), out var ticket)) + throw new Exception($"Ticket ({contractId}, {contentHash}, {typeHash}) doesn't exist"); return ticket; } - public bool TryGet(int contractId, int contentHash, int contentTypeHash, out Ticket token) + public bool TryGet(int contractId, int contentHash, int typeHash, out Ticket token) { - return CachedByKey.TryGetValue((contractId, contentHash, contentTypeHash), out token); + return CachedByKey.TryGetValue((contractId, contentHash, typeHash), out token); } public async Task Preload(IEnumerable ids) From f56c32f16d7249cacaef8f126b878ebea2018a03 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Fri, 25 Aug 2023 15:18:59 +0300 Subject: [PATCH 40/51] Remove `Ticket.JsonType`, add more indexes --- Tzkt.Api/Models/Tickets/Ticket.cs | 6 +- Tzkt.Api/Models/Tickets/TicketInfo.cs | 4 +- Tzkt.Api/Parameters/TicketFilter.cs | 10 +--- Tzkt.Api/Repositories/TicketsRepository.cs | 59 ++++--------------- .../20230823140932_Tickets.Designer.cs | 18 ++++-- .../Migrations/20230823140932_Tickets.cs | 22 ++++++- .../Migrations/TzktContextModelSnapshot.cs | 18 ++++-- Tzkt.Data/Models/Scripts/Ticket.cs | 18 ++++-- .../Commits/Operations/TransactionsCommit.cs | 1 - .../Operations/TransferTicketCommit.cs | 1 - .../Operations/SmartRollupExecuteCommit.cs | 1 - .../Handlers/Proto16/Commits/TicketsCommit.cs | 3 +- Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs | 3 +- 13 files changed, 75 insertions(+), 89 deletions(-) diff --git a/Tzkt.Api/Models/Tickets/Ticket.cs b/Tzkt.Api/Models/Tickets/Ticket.cs index 600a8942a..efb054a85 100644 --- a/Tzkt.Api/Models/Tickets/Ticket.cs +++ b/Tzkt.Api/Models/Tickets/Ticket.cs @@ -1,4 +1,6 @@ -namespace Tzkt.Api.Models +using Netezos.Encoding; + +namespace Tzkt.Api.Models { public class Ticket { @@ -16,7 +18,7 @@ public class Ticket /// /// Micheline type of the content /// - public RawJson Type { get; set; } + public IMicheline Type { get; set; } /// /// Ticket content diff --git a/Tzkt.Api/Models/Tickets/TicketInfo.cs b/Tzkt.Api/Models/Tickets/TicketInfo.cs index 83a67f203..4277e14a1 100644 --- a/Tzkt.Api/Models/Tickets/TicketInfo.cs +++ b/Tzkt.Api/Models/Tickets/TicketInfo.cs @@ -1,4 +1,4 @@ -using NJsonSchema.Annotations; +using Netezos.Encoding; namespace Tzkt.Api.Models { @@ -17,7 +17,7 @@ public class TicketInfo /// /// Micheline type of the content /// - public RawJson Type { get; set; } + public IMicheline Type { get; set; } /// /// Ticket content diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs index 1acb186a3..55be2b28f 100644 --- a/Tzkt.Api/Parameters/TicketFilter.cs +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -66,21 +66,13 @@ public class TicketFilter : INormalizable /// Click on the parameter to expand more details. /// public JsonParameter content { get; set; } - - /// - /// Filter by content type. - /// Note, this parameter supports the following format: `type{.path?}{.mode?}=...`, - /// so you can specify a path to a particular field to filter by (for example, `?type.prim.in=string,int`). - /// Click on the parameter to expand more details. - /// - public JsonParameter type { get; set; } public string Normalize(string name) { return ResponseCacheService.BuildKey("", ("id", id), ("ticketer", ticketer), ("firstMinter", firstMinter), ("firstLevel", firstLevel), ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("contentHash", contentHash), - ("typeHash", typeHash), ("content", content), ("type", type)); + ("typeHash", typeHash), ("content", content)); } } } diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index b71113508..8aa071779 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -43,22 +43,7 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati case "totalSupply": columns.Add(@"""TotalSupply"""); break; case "contentHash": columns.Add(@"o.""ContentHash"""); break; case "typeHash": columns.Add(@"o.""TypeHash"""); break; - case "type": - if (field.Path == null) - { - columns.Add(format <= MichelineFormat.JsonString ? @"""JsonType""" : @"""RawType"""); - } - else if (format <= MichelineFormat.JsonString) - { - field.Column = $"c{counter++}"; - columns.Add($@"""JsonType"" #> '{{{field.PathString}}}' as {field.Column}"); - } - else - { - field.Column = $"c{counter++}"; - columns.Add($@"NULL as {field.Column}"); - } - break; + case "type": columns.Add(@"""RawType"""); break; case "content": if (field.Path == null) { @@ -94,7 +79,6 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati .Filter("LastLevel", filter.lastTime) .Filter("TypeHash", filter.typeHash) .Filter("ContentHash", filter.contentHash) - .Filter("JsonType", filter.type) .Filter("JsonContent", filter.content) .Take(pagination, x => x switch { @@ -125,7 +109,6 @@ public async Task GetTicketsCount(TicketFilter filter) .Filter("LastLevel", filter.lastTime) .Filter("TypeHash", filter.typeHash) .Filter("ContentHash", filter.contentHash) - .Filter("JsonType", filter.type) .Filter("JsonContent", filter.content); using var db = GetConnection(); @@ -150,7 +133,7 @@ public async Task> GetTickets(TicketFilter filter, Paginatio TotalMinted = row.TotalMinted, TotalSupply = row.TotalSupply, TransfersCount = row.TransfersCount, - Type = FormatType(row, format), + Type = Micheline.FromBytes((byte[])row.RawType), Content = FormatContent(row, format), ContentHash = row.ContentHash, TypeHash = row.TypeHash @@ -187,7 +170,7 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat break; case "type": foreach (var row in rows) - result[j++][i] = FormatType(row, format); + result[j++][i] = Micheline.FromBytes((byte[])row.RawType); break; case "content": foreach (var row in rows) @@ -274,7 +257,6 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi tb.""TicketerId"" as ""tTicketerId"", t.""JsonContent"" as ""JsonContent"", t.""RawContent"" as ""RawContent"", - t.""JsonType"" as ""JsonType"", t.""RawType"" as ""RawType"", t.""ContentHash"" as ""ContentHash"", t.""TypeHash"" as ""TypeHash"", @@ -300,7 +282,7 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi columns.Add(@"tb.""TicketerId"" as ""tTicketerId"""); columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); columns.Add(FormatContentQuery(format)); - columns.Add(FormatTypeQuery(format)); + columns.Add(@"t.""RawType"" as ""RawType"""); columns.Add(@"t.""ContentHash"" as ""ContentHash"""); columns.Add(@"t.""TypeHash"" as ""TypeHash"""); break; @@ -379,7 +361,7 @@ public async Task> GetTicketBalances(TicketBalanceFil Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - Type = FormatType(row, format), + Type = Micheline.FromBytes((byte[])row.RawType), Content = FormatContent(row, format), ContentHash = row.ContentHash, TypeHash = row.TypeHash @@ -446,7 +428,7 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - Type = FormatType(row, format), + Type = Micheline.FromBytes((byte[])row.RawType), Content = FormatContent(row, format), ContentHash = row.ContentHash, TypeHash = row.TypeHash @@ -478,7 +460,7 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi break; case "ticket.type": foreach (var row in rows) - result[j++][i] = FormatType(row, format); + result[j++][i] = Micheline.FromBytes((byte[])row.RawType); break; case "ticket.contentHash": foreach (var row in rows) @@ -511,7 +493,6 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter tr.""TicketerId"" as ""tTicketerId"", t.""JsonContent"" as ""JsonContent"", t.""RawContent"" as ""RawContent"", - t.""JsonType"" as ""JsonType"", t.""RawType"" as ""RawType"", t.""ContentHash"" as ""ContentHash"", t.""TypeHash"" as ""TypeHash"", @@ -538,7 +519,7 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter columns.Add(@"tr.""TicketerId"" as ""tTicketerId"""); columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); columns.Add(FormatContentQuery(format)); - columns.Add(FormatTypeQuery(format)); + columns.Add(@"t.""RawType"" as ""RawType"""); columns.Add(@"t.""ContentHash"" as ""ContentHash"""); columns.Add(@"t.""TypeHash"" as ""TypeHash"""); break; @@ -622,7 +603,7 @@ public async Task> GetTicketTransfers(TicketTransfer Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - Type = FormatType(row, format), + Type = Micheline.FromBytes((byte[])row.RawType), Content = FormatContent(row, format), ContentHash = row.ContentHash, TypeHash = row.TypeHash @@ -701,7 +682,7 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), TotalSupply = row.tTotalSupply, - Type = FormatType(row, format), + Type = Micheline.FromBytes((byte[])row.RawType), Content = FormatContent(row, format), ContentHash = row.ContentHash, TypeHash = row.TypeHash @@ -733,7 +714,7 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa break; case "ticket.type": foreach (var row in rows) - result[j++][i] = FormatType(row, format); + result[j++][i] = Micheline.FromBytes((byte[])row.RawType); break; case "ticket.contentHash": foreach (var row in rows) @@ -903,15 +884,6 @@ public async Task GetHistoricalTicketBalances(int level, TicketBalan _ => null }; - static object FormatType(dynamic row, MichelineFormat format) => format switch - { - MichelineFormat.Json => (RawJson)row.JsonType, - MichelineFormat.JsonString => row.JsonType, - MichelineFormat.Raw => (RawJson)Micheline.ToJson(row.RawType), - MichelineFormat.RawString => Micheline.ToJson(row.RawType), - _ => null - }; - static string FormatContentQuery(MichelineFormat format) => format switch { MichelineFormat.Json => @"t.""JsonContent"" as ""JsonContent""", @@ -920,14 +892,5 @@ public async Task GetHistoricalTicketBalances(int level, TicketBalan MichelineFormat.RawString => @"t.""RawContent"" as ""RawContent""", _ => throw new Exception("Invalid MichelineFormat value") }; - - static string FormatTypeQuery(MichelineFormat format) => format switch - { - MichelineFormat.Json => @"t.""JsonType"" as ""JsonType""", - MichelineFormat.JsonString => @"t.""JsonType"" as ""JsonType""", - MichelineFormat.Raw => @"t.""RawType"" as ""RawType""", - MichelineFormat.RawString => @"t.""RawType"" as ""RawType""", - _ => throw new Exception("Invalid MichelineFormat value") - }; } } diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs index 4a212adfc..730491583 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs @@ -3594,9 +3594,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("ContentHash") .HasColumnType("integer"); - b.Property("TypeHash") - .HasColumnType("integer"); - b.Property("FirstLevel") .HasColumnType("integer"); @@ -3609,9 +3606,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("JsonContent") .HasColumnType("jsonb"); - b.Property("JsonType") - .HasColumnType("jsonb"); - b.Property("LastLevel") .HasColumnType("integer"); @@ -3639,17 +3633,29 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("TransfersCount") .HasColumnType("integer"); + b.Property("TypeHash") + .HasColumnType("integer"); + b.HasKey("Id"); + b.HasIndex("ContentHash"); + b.HasIndex("FirstMinterId"); b.HasIndex("Id") .IsUnique(); + b.HasIndex("JsonContent"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonContent"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonContent"), new[] { "jsonb_path_ops" }); + b.HasIndex("LastLevel"); b.HasIndex("TicketerId"); + b.HasIndex("TypeHash"); + b.ToTable("Tickets"); }); diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.cs index 739713502..76abd233b 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.cs @@ -126,10 +126,9 @@ protected override void Up(MigrationBuilder migrationBuilder) TotalSupply = table.Column(type: "text", nullable: false), ContentHash = table.Column(type: "integer", nullable: false), TypeHash = table.Column(type: "integer", nullable: false), - RawContent = table.Column(type: "bytea", nullable: true), RawType = table.Column(type: "bytea", nullable: true), - JsonContent = table.Column(type: "jsonb", nullable: true), - JsonType = table.Column(type: "jsonb", nullable: true) + RawContent = table.Column(type: "bytea", nullable: true), + JsonContent = table.Column(type: "jsonb", nullable: true) }, constraints: table => { @@ -204,6 +203,11 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "TicketId", filter: "\"Balance\" != '0'"); + migrationBuilder.CreateIndex( + name: "IX_Tickets_ContentHash", + table: "Tickets", + column: "ContentHash"); + migrationBuilder.CreateIndex( name: "IX_Tickets_FirstMinterId", table: "Tickets", @@ -215,6 +219,13 @@ protected override void Up(MigrationBuilder migrationBuilder) column: "Id", unique: true); + migrationBuilder.CreateIndex( + name: "IX_Tickets_JsonContent", + table: "Tickets", + column: "JsonContent") + .Annotation("Npgsql:IndexMethod", "gin") + .Annotation("Npgsql:IndexOperators", new[] { "jsonb_path_ops" }); + migrationBuilder.CreateIndex( name: "IX_Tickets_LastLevel", table: "Tickets", @@ -225,6 +236,11 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "Tickets", column: "TicketerId"); + migrationBuilder.CreateIndex( + name: "IX_Tickets_TypeHash", + table: "Tickets", + column: "TypeHash"); + migrationBuilder.CreateIndex( name: "IX_TicketTransfers_FromId", table: "TicketTransfers", diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 502830819..77aa9062a 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3591,9 +3591,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ContentHash") .HasColumnType("integer"); - b.Property("TypeHash") - .HasColumnType("integer"); - b.Property("FirstLevel") .HasColumnType("integer"); @@ -3606,9 +3603,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("JsonContent") .HasColumnType("jsonb"); - b.Property("JsonType") - .HasColumnType("jsonb"); - b.Property("LastLevel") .HasColumnType("integer"); @@ -3636,17 +3630,29 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("TransfersCount") .HasColumnType("integer"); + b.Property("TypeHash") + .HasColumnType("integer"); + b.HasKey("Id"); + b.HasIndex("ContentHash"); + b.HasIndex("FirstMinterId"); b.HasIndex("Id") .IsUnique(); + b.HasIndex("JsonContent"); + + NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("JsonContent"), "gin"); + NpgsqlIndexBuilderExtensions.HasOperators(b.HasIndex("JsonContent"), new[] { "jsonb_path_ops" }); + b.HasIndex("LastLevel"); b.HasIndex("TicketerId"); + b.HasIndex("TypeHash"); + b.ToTable("Tickets"); }); diff --git a/Tzkt.Data/Models/Scripts/Ticket.cs b/Tzkt.Data/Models/Scripts/Ticket.cs index d0c9931ed..3433d79af 100644 --- a/Tzkt.Data/Models/Scripts/Ticket.cs +++ b/Tzkt.Data/Models/Scripts/Ticket.cs @@ -24,10 +24,9 @@ public class Ticket public int ContentHash { get; set; } public int TypeHash { get; set; } - public byte[] RawContent { get; set; } public byte[] RawType { get; set; } + public byte[] RawContent { get; set; } public string JsonContent { get; set; } - public string JsonType { get; set; } } public static class TicketModel @@ -43,10 +42,6 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .Property(x => x.JsonContent) .HasColumnType("jsonb"); - - modelBuilder.Entity() - .Property(x => x.JsonType) - .HasColumnType("jsonb"); // TODO: switch to `numeric` type after migration to .NET 6 var converter = new ValueConverter( @@ -79,6 +74,17 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.LastLevel); + + modelBuilder.Entity() + .HasIndex(x => x.ContentHash); + + modelBuilder.Entity() + .HasIndex(x => x.TypeHash); + + modelBuilder.Entity() + .HasIndex(x => x.JsonContent) + .HasMethod("gin") + .HasOperators("jsonb_path_ops"); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index 20b2a549a..88c3c9263 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -711,7 +711,6 @@ protected virtual IEnumerable ParseTicketUpdates(string property, RawType = rawType, RawContent = rawContent, JsonContent = micheType.Humanize(value), - JsonType = micheType.ToMicheline().ToJson(), TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 995f945af..ece09a180 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -220,7 +220,6 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul RawType = rawType, RawContent = rawContent, JsonContent = micheType.Humanize(value), - JsonType = micheType.ToMicheline().ToJson(), TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index 47e801adf..8fae0a9aa 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -216,7 +216,6 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul RawType = rawType, RawContent = rawContent, JsonContent = micheType.Humanize(value), - JsonType = micheType.ToMicheline().ToJson(), TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index 926e7d8a4..c2f62aaa6 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -186,10 +186,9 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic TotalBurned = BigInteger.Zero, TotalMinted = BigInteger.Zero, TotalSupply = BigInteger.Zero, - RawContent = ticketToken.RawContent, RawType = ticketToken.RawType, + RawContent = ticketToken.RawContent, JsonContent = ticketToken.JsonContent, - JsonType = ticketToken.JsonType, ContentHash = ticketToken.ContentHash, TypeHash = ticketToken.TypeHash, }; diff --git a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs index ebf460d41..d2b46d6f0 100644 --- a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs +++ b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs @@ -11,10 +11,9 @@ public class TicketUpdate public class TicketToken { public string Ticketer { get; set; } - public byte[] RawContent { get; set; } public byte[] RawType { get; set; } + public byte[] RawContent { get; set; } public string JsonContent { get; set; } - public string JsonType { get; set; } public int ContentHash { get; set; } public int TypeHash { get; set; } From f0964e43bfbc53f84e91b4daffed92b99ede054d Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Fri, 25 Aug 2023 21:30:35 +0300 Subject: [PATCH 41/51] Fix models --- .../20230823140932_Tickets.Designer.cs | 6 +++--- Tzkt.Data/Migrations/20230823140932_Tickets.cs | 4 ++-- .../Migrations/TzktContextModelSnapshot.cs | 6 +++--- .../Operations/Fictive/MigrationOperation.cs | 1 - .../Operations/SmartRollupExecuteOperation.cs | 2 ++ Tzkt.Data/Models/Scripts/TicketBalance.cs | 1 - .../Handlers/Proto16/Commits/TicketsCommit.cs | 18 ++++++++++++------ 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs index 730491583..80d8a5a78 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs @@ -1878,9 +1878,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SubIds") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3051,6 +3048,9 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.Property("SubIds") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.cs index 76abd233b..5d676e0af 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.cs @@ -37,7 +37,7 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.AddColumn( name: "TicketTransfers", - table: "MigrationOps", + table: "SmartRollupExecuteOps", type: "integer", nullable: true); @@ -323,7 +323,7 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropColumn( name: "TicketTransfers", - table: "MigrationOps"); + table: "SmartRollupExecuteOps"); migrationBuilder.DropColumn( name: "TicketBalancesCount", diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 77aa9062a..3a6c12e0e 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -1875,9 +1875,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SubIds") .HasColumnType("integer"); - b.Property("TicketTransfers") - .HasColumnType("integer"); - b.Property("Timestamp") .HasColumnType("timestamp with time zone"); @@ -3048,6 +3045,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("SubIds") .HasColumnType("integer"); + b.Property("TicketTransfers") + .HasColumnType("integer"); + b.Property("Timestamp") .HasColumnType("timestamp with time zone"); diff --git a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs index 75c18c06e..04b10dbe4 100644 --- a/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs +++ b/Tzkt.Data/Models/Operations/Fictive/MigrationOperation.cs @@ -18,7 +18,6 @@ public class MigrationOperation public int? StorageId { get; set; } public int? BigMapUpdates { get; set; } public int? TokenTransfers { get; set; } - public int? TicketTransfers { get; set; } public int? SubIds { get; set; } diff --git a/Tzkt.Data/Models/Operations/SmartRollupExecuteOperation.cs b/Tzkt.Data/Models/Operations/SmartRollupExecuteOperation.cs index ae0389f03..e6d3abe4a 100644 --- a/Tzkt.Data/Models/Operations/SmartRollupExecuteOperation.cs +++ b/Tzkt.Data/Models/Operations/SmartRollupExecuteOperation.cs @@ -7,6 +7,8 @@ public class SmartRollupExecuteOperation : ManagerOperation { public int? SmartRollupId { get; set; } public int? CommitmentId { get; set; } + + public int? TicketTransfers { get; set; } public int? SubIds { get; set; } } diff --git a/Tzkt.Data/Models/Scripts/TicketBalance.cs b/Tzkt.Data/Models/Scripts/TicketBalance.cs index 53ea78db1..d92338dca 100644 --- a/Tzkt.Data/Models/Scripts/TicketBalance.cs +++ b/Tzkt.Data/Models/Scripts/TicketBalance.cs @@ -7,7 +7,6 @@ namespace Tzkt.Data.Models public class TicketBalance { public long Id { get; set; } - public int TicketerId { get; set; } public long TicketId { get; set; } public int AccountId { get; set; } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index c2f62aaa6..157ba0d0b 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -252,11 +252,14 @@ void TransferTickets(ManagerOperation op, Ticket ticket, switch (op) { + case TransactionOperation transaction: + transaction.TicketTransfers = (transaction.TicketTransfers ?? 0) + 1; + break; case TransferTicketOperation transferTicket: transferTicket.TicketTransfers = (transferTicket.TicketTransfers ?? 0) + 1; break; - case TransactionOperation tx: - tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; + case SmartRollupExecuteOperation srExecute: + srExecute.TicketTransfers = (srExecute.TicketTransfers ?? 0) + 1; break; } @@ -327,11 +330,14 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, Db.TryAttach(op); switch (op) { - case TransferTicketOperation transfer1: - transfer1.TicketTransfers = (transfer1.TicketTransfers ?? 0) + 1; + case TransactionOperation transaction: + transaction.TicketTransfers = (transaction.TicketTransfers ?? 0) + 1; + break; + case TransferTicketOperation transferTicket: + transferTicket.TicketTransfers = (transferTicket.TicketTransfers ?? 0) + 1; break; - case TransactionOperation tx: - tx.TicketTransfers = (tx.TicketTransfers ?? 0) + 1; + case SmartRollupExecuteOperation srExecute: + srExecute.TicketTransfers = (srExecute.TicketTransfers ?? 0) + 1; break; } From cd770c7a7b8597c3db1269a7623b15d6fa15bd8c Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Mon, 28 Aug 2023 14:40:36 +0300 Subject: [PATCH 42/51] Improve tickets cache --- Tzkt.Api/Controllers/TicketsController.cs | 1 - .../Handlers/Proto16/Commits/TicketsCommit.cs | 8 ++-- .../Services/Cache/TicketBalancesCache.cs | 7 +-- Tzkt.Sync/Services/Cache/TicketsCache.cs | 46 ++++--------------- Tzkt.Sync/Services/TezosNode/TezosNode.cs | 4 +- Tzkt.Sync/Utils/JsonContent.cs | 2 +- Tzkt.Sync/Utils/TzktClient.cs | 2 +- 7 files changed, 19 insertions(+), 51 deletions(-) diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index f958735bb..3bf4a1083 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -45,7 +45,6 @@ public async Task> GetTicketsCount([FromQuery] TicketFilter fi filter.contentHash != null || filter.typeHash != null || filter.content != null || - filter.type != null || filter.id != null ) { var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index 157ba0d0b..7f9370781 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -27,7 +27,7 @@ public virtual async Task Apply() #region precache var accountsSet = new HashSet(); - var ticketsSet = new HashSet<(int, int, int)>(); + var ticketsSet = new HashSet<(int, byte[], int, byte[], int)>(); var balancesSet = new HashSet<(int, long)>(); var list = Updates.SelectMany(x => x.Value).ToList(); @@ -45,7 +45,7 @@ public virtual async Task Apply() foreach (var update in list) { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) - ticketsSet.Add((ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.TypeHash)); + ticketsSet.Add((ticketer.Id, update.TicketToken.RawContent, update.TicketToken.ContentHash, update.TicketToken.RawType, update.TicketToken.TypeHash)); } await Cache.Tickets.Preload(ticketsSet); @@ -54,7 +54,7 @@ public virtual async Task Apply() { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) { - if (Cache.Tickets.TryGet(ticketer.Id, update.TicketToken.ContentHash, update.TicketToken.TypeHash, out var ticket)) + if (Cache.Tickets.TryGet(ticketer.Id, update.TicketToken.RawContent, update.TicketToken.RawType, out var ticket)) { foreach (var upd in update.Updates) { @@ -159,7 +159,7 @@ Account GetOrCreateAccount(ManagerOperation op, string address) Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken ticketToken) { - if (Cache.Tickets.TryGet(contract.Id, ticketToken.ContentHash, ticketToken.TypeHash, out var ticket)) return ticket; + if (Cache.Tickets.TryGet(contract.Id, ticketToken.RawContent, ticketToken.RawType, out var ticket)) return ticket; var state = Cache.AppState.Get(); state.TicketsCount++; diff --git a/Tzkt.Sync/Services/Cache/TicketBalancesCache.cs b/Tzkt.Sync/Services/Cache/TicketBalancesCache.cs index 0a70b76ee..8ccf8425a 100644 --- a/Tzkt.Sync/Services/Cache/TicketBalancesCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketBalancesCache.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; - +using Microsoft.EntityFrameworkCore; using Tzkt.Data; using Tzkt.Data.Models; diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs index 44f963e1d..678c0043d 100644 --- a/Tzkt.Sync/Services/Cache/TicketsCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Numerics; -using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; - +using Microsoft.EntityFrameworkCore; using Tzkt.Data; using Tzkt.Data.Models; @@ -15,7 +9,7 @@ public class TicketsCache public const int MaxItems = 4 * 4096; //TODO: set limits in app settings static readonly Dictionary CachedById = new(MaxItems); - static readonly Dictionary<(int ContractId, int ContentHash, int TypeHash), Ticket> CachedByKey = new(MaxItems); + static readonly Dictionary<(int ContractId, byte[] RawContent, byte[] RawType), Ticket> CachedByKey = new(MaxItems); readonly TzktContext Db; @@ -47,26 +41,13 @@ public void Trim() public void Add(Ticket ticket) { CachedById[ticket.Id] = ticket; - CachedByKey[(ticket.TicketerId, ticket.ContentHash, ticket.TypeHash)] = ticket; + CachedByKey[(ticket.TicketerId, ticket.RawContent, ticket.RawType)] = ticket; } public void Remove(Ticket ticket) { CachedById.Remove(ticket.Id); - CachedByKey.Remove((ticket.TicketerId, ticket.ContentHash, ticket.TypeHash)); - } - - public bool Has(int contractId, int contentHash, int typeHash) - { - return CachedByKey.ContainsKey((contractId, contentHash, typeHash)); - } - - public Ticket GetOrAdd(Ticket token) - { - if (CachedById.TryGetValue(token.Id, out var res)) - return res; - Add(token); - return token; + CachedByKey.Remove((ticket.TicketerId, ticket.RawContent, ticket.RawType)); } public Ticket Get(long id) @@ -76,16 +57,9 @@ public Ticket Get(long id) return token; } - public Ticket Get(int contractId, int contentHash, int typeHash) - { - if (!CachedByKey.TryGetValue((contractId, contentHash, typeHash), out var ticket)) - throw new Exception($"Ticket ({contractId}, {contentHash}, {typeHash}) doesn't exist"); - return ticket; - } - - public bool TryGet(int contractId, int contentHash, int typeHash, out Ticket token) + public bool TryGet(int contractId, byte[] rawContent, byte[] rawType, out Ticket token) { - return CachedByKey.TryGetValue((contractId, contentHash, typeHash), out token); + return CachedByKey.TryGetValue((contractId, rawContent, rawType), out token); } public async Task Preload(IEnumerable ids) @@ -102,18 +76,18 @@ public async Task Preload(IEnumerable ids) } } - public async Task Preload(IEnumerable<(int, int, int)> ids) + public async Task Preload(IEnumerable<(int, byte[], int, byte[], int)> keys) { - var missed = ids.Where(x => !CachedByKey.ContainsKey(x)).ToHashSet(); + var missed = keys.Where(x => !CachedByKey.ContainsKey((x.Item1, x.Item2, x.Item4))).ToHashSet(); if (missed.Count > 0) { for (int i = 0, n = 2048; i < missed.Count; i += n) { - var corteges = string.Join(',', missed.Skip(i).Take(n).Select(x => $"({x.Item1}, '{x.Item2}')")); + var corteges = string.Join(',', missed.Skip(i).Take(n).Select(x => $"({x.Item1}, '{x.Item3}', '{x.Item5}')")); var items = await Db.Tickets .FromSqlRaw($@" SELECT * FROM ""{nameof(TzktContext.Tickets)}"" - WHERE (""{nameof(Ticket.TicketerId)}"", ""{nameof(Ticket.ContentHash)}"") IN ({corteges})") + WHERE (""{nameof(Ticket.TicketerId)}"", ""{nameof(Ticket.ContentHash)}"", ""{nameof(Ticket.TypeHash)}"") IN ({corteges})") .ToListAsync(); foreach (var item in items) diff --git a/Tzkt.Sync/Services/TezosNode/TezosNode.cs b/Tzkt.Sync/Services/TezosNode/TezosNode.cs index d7e1b1684..562097745 100644 --- a/Tzkt.Sync/Services/TezosNode/TezosNode.cs +++ b/Tzkt.Sync/Services/TezosNode/TezosNode.cs @@ -1,5 +1,5 @@ -using Microsoft.EntityFrameworkCore; -using System.Text.Json; +using System.Text.Json; +using Microsoft.EntityFrameworkCore; using Tzkt.Data; using Tzkt.Data.Models; diff --git a/Tzkt.Sync/Utils/JsonContent.cs b/Tzkt.Sync/Utils/JsonContent.cs index 57997fee3..4bfb19546 100644 --- a/Tzkt.Sync/Utils/JsonContent.cs +++ b/Tzkt.Sync/Utils/JsonContent.cs @@ -6,7 +6,7 @@ class JsonContent : StringContent { public JsonContent(string content) : base(content) { - Headers.ContentType = MediaTypeHeaderValue.Parse("application/json"); + Headers.ContentType = new MediaTypeHeaderValue("application/json"); } } } \ No newline at end of file diff --git a/Tzkt.Sync/Utils/TzktClient.cs b/Tzkt.Sync/Utils/TzktClient.cs index 3eecb01c9..23d1a6194 100644 --- a/Tzkt.Sync/Utils/TzktClient.cs +++ b/Tzkt.Sync/Utils/TzktClient.cs @@ -70,7 +70,7 @@ public async Task PostAsync(string path, string content) var response = await HttpClient.PostAsync(path, new JsonContent(content)); using var stream = await response.Content.ReadAsStreamAsync(); - return await JsonSerializer.DeserializeAsync(stream); + return await JsonSerializer.DeserializeAsync(stream, SerializerOptions.Default); } public void Dispose() => _HttpClient?.Dispose(); From 818afd008fb2311d630550d7b3669dbde225cdd7 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Mon, 28 Aug 2023 15:04:07 +0300 Subject: [PATCH 43/51] Fix tickets rpc --- Tzkt.Sync/Protocols/Handlers/Proto16/Rpc/Rpc.cs | 10 +++++++++- Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs | 13 ++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Rpc/Rpc.cs index bc64238b0..23b9bd61e 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Rpc/Rpc.cs @@ -1,9 +1,17 @@ -using Tzkt.Sync.Services; +using System.Text.Json; +using Tzkt.Sync.Services; namespace Tzkt.Sync.Protocols.Proto16 { class Rpc : Proto12.Rpc { public Rpc(TezosNode node) : base(node) { } + + public override Task GetTicketBalance(int level, string address, string ticket) + { + return address.StartsWith("sr1") + ? Node.PostAsync($"chains/main/blocks/{level}/context/smart_rollups/smart_rollup/{address}/ticket_balance", ticket) + : Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); + } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs index bed3ed1c0..1f9b57fca 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Rpc/Rpc.cs @@ -1,18 +1,9 @@ -using System.Text.Json; -using System.Text.RegularExpressions; -using Tzkt.Sync.Services; +using Tzkt.Sync.Services; namespace Tzkt.Sync.Protocols.Proto17 { - class Rpc : Proto12.Rpc + class Rpc : Proto16.Rpc { public Rpc(TezosNode node) : base(node) { } - - public override Task GetTicketBalance(int level, string address, string ticket) - { - return Regex.IsMatch(address, "^sr1[0-9A-Za-z]{33}$") - ? Node.PostAsync($"chains/main/blocks/{level}/context/smart_rollups/smart_rollup/{address}/ticket_balance", ticket) - : Node.PostAsync($"chains/main/blocks/{level}/context/contracts/{address}/ticket_balance", ticket); - } } } From dfd416e755abb833135a420ba3086b96191d3463 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Mon, 28 Aug 2023 18:21:50 +0300 Subject: [PATCH 44/51] Minor fixes --- .../Commits/Operations/TransactionsCommit.cs | 17 +-- .../Proto1/Diagnostics/Diagnostics.cs | 8 +- .../Operations/TransferTicketCommit.cs | 32 ++--- .../Operations/SmartRollupExecuteCommit.cs | 19 +-- .../Handlers/Proto16/Commits/TicketsCommit.cs | 109 ++++++++---------- .../Proto2/Activation/ProtoActivator.cs | 56 +++++++++ Tzkt.Sync/Services/Cache/TicketsCache.cs | 2 +- 7 files changed, 141 insertions(+), 102 deletions(-) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index 88c3c9263..884a772fc 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -699,10 +699,11 @@ protected virtual IEnumerable ParseTicketUpdates(string property, try { var ticketToken = update.Required("ticket_token"); - var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); var value = Micheline.FromJson(ticketToken.Required("content")); - var rawContent = micheType.Optimize(value).ToBytes(); - var rawType = micheType.ToMicheline().ToBytes(); + var type = Micheline.FromJson(ticketToken.Required("content_type")); + var schema = Schema.Create(type as MichelinePrim); ; + var rawContent = schema.Optimize(value).ToBytes(); + var rawType = type.ToBytes(); res.Add(new TicketUpdate { TicketToken = new TicketToken @@ -710,20 +711,20 @@ protected virtual IEnumerable ParseTicketUpdates(string property, Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, RawContent = rawContent, - JsonContent = micheType.Humanize(value), + JsonContent = schema.Humanize(value), TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update + Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new Update { - Account = y.RequiredString("account"), - Amount = BigInteger.Parse(y.RequiredString("amount")) + Account = x.RequiredString("account"), + Amount = BigInteger.Parse(x.RequiredString("amount")) }) }); } catch (Exception ex) { - Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); + Logger.LogError(ex, "Failed to process ticket updates"); } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs index 030143ae7..87c487a82 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Diagnostics/Diagnostics.cs @@ -1,9 +1,5 @@ -using System; -using System.Linq; -using System.Text.Json; -using System.Threading.Tasks; +using System.Text.Json; using Microsoft.EntityFrameworkCore; -using Netezos.Encoding; using Tzkt.Data; using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -74,7 +70,7 @@ protected virtual async Task RunDiagnostics(int level, int ops = -1) .Select(x => x.Entity as Account); var ticketBalances = entries.Where(x => - x.Entity is TicketBalance && (x.State == EntityState.Modified || x.State == EntityState.Added)) + x.Entity is TicketBalance && (x.State == EntityState.Modified || x.State == EntityState.Added)) .Select(x => x.Entity as TicketBalance); foreach (var ticketBalance in ticketBalances) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index ece09a180..035c9519a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -201,41 +201,43 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul { if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; - - return ticketUpdates.RequiredArray().EnumerateArray().Select(update => + + var res = new List(); + foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { try { var ticketToken = update.Required("ticket_token"); - var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); var value = Micheline.FromJson(ticketToken.Required("content")); - var rawContent = micheType.Optimize(value).ToBytes(); - var rawType = micheType.ToMicheline().ToBytes(); - - return new TicketUpdate + var type = Micheline.FromJson(ticketToken.Required("content_type")); + var schema = Schema.Create(type as MichelinePrim); ; + var rawContent = schema.Optimize(value).ToBytes(); + var rawType = type.ToBytes(); + res.Add(new TicketUpdate { TicketToken = new TicketToken { Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, RawContent = rawContent, - JsonContent = micheType.Humanize(value), + JsonContent = schema.Humanize(value), TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update + Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new Update { - Account = y.RequiredString("account"), - Amount = BigInteger.Parse(y.RequiredString("amount")) + Account = x.RequiredString("account"), + Amount = BigInteger.Parse(x.RequiredString("amount")) }) - }; + }); } catch (Exception ex) { - Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); - return null; + Logger.LogError(ex, "Failed to process ticket updates"); } - }).Where(update => update != null); + } + + return res; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index 8fae0a9aa..c61a4fb12 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -199,15 +199,16 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul return null; var res = new List(); - foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) + foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { try { var ticketToken = update.Required("ticket_token"); - var micheType = Schema.Create(Micheline.FromJson(ticketToken.Required("content_type")) as MichelinePrim); var value = Micheline.FromJson(ticketToken.Required("content")); - var rawContent = micheType.Optimize(value).ToBytes(); - var rawType = micheType.ToMicheline().ToBytes(); + var type = Micheline.FromJson(ticketToken.Required("content_type")); + var schema = Schema.Create(type as MichelinePrim); ; + var rawContent = schema.Optimize(value).ToBytes(); + var rawType = type.ToBytes(); res.Add(new TicketUpdate { TicketToken = new TicketToken @@ -215,20 +216,20 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, RawContent = rawContent, - JsonContent = micheType.Humanize(value), + JsonContent = schema.Humanize(value), TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.Required("updates").RequiredArray().EnumerateArray().Select(y => new Update + Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new Update { - Account = y.RequiredString("account"), - Amount = BigInteger.Parse(y.RequiredString("amount")) + Account = x.RequiredString("account"), + Amount = BigInteger.Parse(x.RequiredString("amount")) }) }); } catch (Exception ex) { - Logger.LogError(ex, "failed to process 'transfer_ticket' parameters"); + Logger.LogError(ex, "Failed to process ticket updates"); } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index 7f9370781..749a07d1e 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -14,9 +14,8 @@ public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } public virtual void Append(ManagerOperation op, IEnumerable updates) { if (!Updates.TryGetValue(op, out var list)) - { Updates.Add(op, list = new()); - } + list.AddRange(updates); } @@ -25,7 +24,6 @@ public virtual async Task Apply() if (Updates.Count == 0) return; #region precache - var accountsSet = new HashSet(); var ticketsSet = new HashSet<(int, byte[], int, byte[], int)>(); var balancesSet = new HashSet<(int, long)>(); @@ -54,7 +52,7 @@ public virtual async Task Apply() { if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) { - if (Cache.Tickets.TryGet(ticketer.Id, update.TicketToken.RawContent, update.TicketToken.RawType, out var ticket)) + if (Cache.Tickets.TryGetCached(ticketer.Id, update.TicketToken.RawContent, update.TicketToken.RawType, out var ticket)) { foreach (var upd in update.Updates) { @@ -66,65 +64,48 @@ public virtual async Task Apply() } await Cache.TicketBalances.Preload(balancesSet); - #endregion foreach (var (op, opUpdates) in Updates) { - if (op.Level == 5) - Console.WriteLine($"Check this"); - op.Block.Events |= BlockEvents.Tickets; - var updatesDict = new Dictionary>(); + var ticketUpdates = new Dictionary>(); foreach (var upd in opUpdates) { var ticketer = GetOrCreateAccount(op, upd.TicketToken.Ticketer) as Contract; var ticket = GetOrCreateTicket(op, ticketer, upd.TicketToken); - if (!updatesDict.TryGetValue(ticket, out var upds)) - { - updatesDict.Add(ticket, upds = new()); - } + if (!ticketUpdates.TryGetValue(ticket, out var upds)) + ticketUpdates.Add(ticket, upds = new()); + upds.AddRange(upd.Updates); } - foreach (var (ticket, updates) in updatesDict) + foreach (var (ticket, updates) in ticketUpdates) { if (updates.Count == 1 || updates.BigSum(x => x.Amount) != BigInteger.Zero) { foreach (var ticketUpdate in updates) - { - var account = GetOrCreateAccount(op, ticketUpdate.Account); - var balance = GetOrCreateTicketBalance(op, ticket, account); - MintOrBurnTickets(op, ticket, account, balance, ticketUpdate.Amount); - } + MintOrBurnTickets(op, ticket, ticketUpdate.Account, ticketUpdate.Amount); } else if (updates.Count(x => x.Amount < BigInteger.Zero) == 1) { var from = updates.First(x => x.Amount < BigInteger.Zero); foreach (var ticketUpdate in updates.Where(x => x.Amount > BigInteger.Zero)) - { TransferTickets(op, ticket, from.Account, ticketUpdate.Account, ticketUpdate.Amount); - } } else if (updates.Count(x => x.Amount > BigInteger.Zero) == 1) { var to = updates.First(x => x.Amount > BigInteger.Zero); foreach (var ticketUpdate in updates.Where(x => x.Amount < BigInteger.Zero)) - { - TransferTickets(op, ticket, ticketUpdate.Account, to.Account, ticketUpdate.Amount); - } + TransferTickets(op, ticket, ticketUpdate.Account, to.Account, -ticketUpdate.Amount); } else { foreach (var ticketUpdate in updates) - { - var account = GetOrCreateAccount(op, ticketUpdate.Account); - var balance = GetOrCreateTicketBalance(op, ticket, account); - MintOrBurnTickets(op, ticket, account, balance, ticketUpdate.Amount); - } + MintOrBurnTickets(op, ticket, ticketUpdate.Account, ticketUpdate.Amount); } } } @@ -159,7 +140,8 @@ Account GetOrCreateAccount(ManagerOperation op, string address) Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken ticketToken) { - if (Cache.Tickets.TryGet(contract.Id, ticketToken.RawContent, ticketToken.RawType, out var ticket)) return ticket; + if (Cache.Tickets.TryGetCached(contract.Id, ticketToken.RawContent, ticketToken.RawType, out var ticket)) + return ticket; var state = Cache.AppState.Get(); state.TicketsCount++; @@ -169,16 +151,16 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic Id = op switch { TransactionOperation transaction => Cache.AppState.NextSubId(transaction), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), + TransferTicketOperation transferTicket => Cache.AppState.NextSubId(transferTicket), + SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, TicketerId = contract.Id, FirstMinterId = op switch { TransactionOperation transaction => transaction.InitiatorId ?? transaction.SenderId, - TransferTicketOperation transfer => transfer.SenderId, - SmartRollupExecuteOperation sr => sr.SenderId, + TransferTicketOperation transferTicket => transferTicket.SenderId, + SmartRollupExecuteOperation srExecute => srExecute.SenderId, _ => throw new ArgumentOutOfRangeException(nameof(op)) }, FirstLevel = op.Level, @@ -204,7 +186,8 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken tic TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Account account) { - if (Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) return ticketBalance; + if (Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) + return ticketBalance; var state = Cache.AppState.Get(); state.TicketBalancesCount++; @@ -214,8 +197,8 @@ TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Accou Id = op switch { TransactionOperation transaction => Cache.AppState.NextSubId(transaction), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), + TransferTicketOperation transferTicket => Cache.AppState.NextSubId(transferTicket), + SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, AccountId = account.Id, @@ -233,17 +216,11 @@ TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Accou Db.TryAttach(account); account.TicketBalancesCount++; - if (account.FirstLevel > op.Level) - { - account.FirstLevel = op.Level; - op.Block.Events |= BlockEvents.NewAccounts; - } + return ticketBalance; } - void TransferTickets(ManagerOperation op, Ticket ticket, - string fromAddress, string toAddress, - BigInteger amount) + void TransferTickets(ManagerOperation op, Ticket ticket, string fromAddress, string toAddress, BigInteger amount) { var from = GetOrCreateAccount(op, fromAddress); var fromBalance = GetOrCreateTicketBalance(op, ticket, from); @@ -285,7 +262,7 @@ void TransferTickets(ManagerOperation op, Ticket ticket, toBalance.LastLevel = op.Level; ticket.TransfersCount++; - if (amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) + if (amount != BigInteger.Zero && fromBalance != toBalance) { if (fromBalance.Balance == BigInteger.Zero) { @@ -307,8 +284,8 @@ void TransferTickets(ManagerOperation op, Ticket ticket, Id = op switch { TransactionOperation transaction => Cache.AppState.NextSubId(transaction), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), + TransferTicketOperation transferTicket => Cache.AppState.NextSubId(transferTicket), + SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, Amount = amount, @@ -323,11 +300,11 @@ void TransferTickets(ManagerOperation op, Ticket ticket, }); } - void MintOrBurnTickets(ManagerOperation op, Ticket ticket, - Account account, TicketBalance balance, - BigInteger amount) + void MintOrBurnTickets(ManagerOperation op, Ticket ticket, string address, BigInteger amount) { - Db.TryAttach(op); + var account = GetOrCreateAccount(op, address); + var balance = GetOrCreateTicketBalance(op, ticket, account); + switch (op) { case TransactionOperation transaction: @@ -353,19 +330,25 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, Db.TryAttach(ticket); ticket.TransfersCount++; ticket.LastLevel = op.Level; - if (balance.Balance == BigInteger.Zero) + ticket.TotalSupply += amount; + if (amount > BigInteger.Zero) { - account.ActiveTicketsCount--; - ticket.HoldersCount--; + ticket.TotalMinted += amount; + if (balance.Balance == amount) + { + account.ActiveTicketsCount++; + ticket.HoldersCount++; + } } - if (balance.Balance == amount) + else if (amount < BigInteger.Zero) { - account.ActiveTicketsCount++; - ticket.HoldersCount++; + ticket.TotalBurned += -amount; + if (balance.Balance == BigInteger.Zero) + { + account.ActiveTicketsCount--; + ticket.HoldersCount--; + } } - if (amount > 0) ticket.TotalMinted += amount; - else ticket.TotalBurned += -amount; - ticket.TotalSupply += amount; var state = Cache.AppState.Get(); state.TicketTransfersCount++; @@ -375,8 +358,8 @@ void MintOrBurnTickets(ManagerOperation op, Ticket ticket, Id = op switch { TransactionOperation transaction => Cache.AppState.NextSubId(transaction), - TransferTicketOperation transfer => Cache.AppState.NextSubId(transfer), - SmartRollupExecuteOperation sr => Cache.AppState.NextSubId(sr), + TransferTicketOperation transferTicket => Cache.AppState.NextSubId(transferTicket), + SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, Amount = amount > BigInteger.Zero ? amount : -amount, diff --git a/Tzkt.Sync/Protocols/Handlers/Proto2/Activation/ProtoActivator.cs b/Tzkt.Sync/Protocols/Handlers/Proto2/Activation/ProtoActivator.cs index 7f75d3a60..c999ec274 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto2/Activation/ProtoActivator.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto2/Activation/ProtoActivator.cs @@ -200,6 +200,34 @@ protected override async Task RevertContext(AppState state) ActiveTokensCount = user.ActiveTokensCount, TokenBalancesCount = user.TokenBalancesCount, TokenTransfersCount = user.TokenTransfersCount, + ActiveTicketsCount = user.ActiveTicketsCount, + TicketBalancesCount = user.TicketBalancesCount, + TicketTransfersCount = user.TicketTransfersCount, + TransferTicketCount = user.TransferTicketCount, + TxRollupCommitCount = user.TxRollupCommitCount, + TxRollupDispatchTicketsCount = user.TxRollupDispatchTicketsCount, + TxRollupFinalizeCommitmentCount = user.TxRollupFinalizeCommitmentCount, + TxRollupOriginationCount = user.TxRollupOriginationCount, + TxRollupRejectionCount = user.TxRollupRejectionCount, + TxRollupRemoveCommitmentCount = user.TxRollupRemoveCommitmentCount, + TxRollupReturnBondCount = user.TxRollupReturnBondCount, + TxRollupSubmitBatchCount = user.TxRollupSubmitBatchCount, + IncreasePaidStorageCount = user.IncreasePaidStorageCount, + UpdateConsensusKeyCount = user.UpdateConsensusKeyCount, + DrainDelegateCount = user.DrainDelegateCount, + RollupBonds = user.RollupBonds, + RollupsCount = user.RollupsCount, + SmartRollupBonds = user.SmartRollupBonds, + SmartRollupsCount = user.SmartRollupsCount, + SmartRollupAddMessagesCount = user.SmartRollupAddMessagesCount, + SmartRollupCementCount = user.SmartRollupCementCount, + SmartRollupExecuteCount = user.SmartRollupExecuteCount, + SmartRollupOriginateCount = user.SmartRollupOriginateCount, + SmartRollupPublishCount = user.SmartRollupPublishCount, + SmartRollupRecoverBondCount = user.SmartRollupRecoverBondCount, + SmartRollupRefuteCount = user.SmartRollupRefuteCount, + RefutationGamesCount = user.RefutationGamesCount, + ActiveRefutationGamesCount = user.ActiveRefutationGamesCount }; Db.Entry(user).State = EntityState.Detached; @@ -238,6 +266,34 @@ User DowngradeDelegate(Data.Models.Delegate delegat) ActiveTokensCount = delegat.ActiveTokensCount, TokenBalancesCount = delegat.TokenBalancesCount, TokenTransfersCount = delegat.TokenTransfersCount, + ActiveTicketsCount = delegat.ActiveTicketsCount, + TicketBalancesCount = delegat.TicketBalancesCount, + TicketTransfersCount = delegat.TicketTransfersCount, + TransferTicketCount = delegat.TransferTicketCount, + TxRollupCommitCount = delegat.TxRollupCommitCount, + TxRollupDispatchTicketsCount = delegat.TxRollupDispatchTicketsCount, + TxRollupFinalizeCommitmentCount = delegat.TxRollupFinalizeCommitmentCount, + TxRollupOriginationCount = delegat.TxRollupOriginationCount, + TxRollupRejectionCount = delegat.TxRollupRejectionCount, + TxRollupRemoveCommitmentCount = delegat.TxRollupRemoveCommitmentCount, + TxRollupReturnBondCount = delegat.TxRollupReturnBondCount, + TxRollupSubmitBatchCount = delegat.TxRollupSubmitBatchCount, + IncreasePaidStorageCount = delegat.IncreasePaidStorageCount, + UpdateConsensusKeyCount = delegat.UpdateConsensusKeyCount, + DrainDelegateCount = delegat.DrainDelegateCount, + RollupBonds = delegat.RollupBonds, + RollupsCount = delegat.RollupsCount, + SmartRollupBonds = delegat.SmartRollupBonds, + SmartRollupsCount = delegat.SmartRollupsCount, + SmartRollupAddMessagesCount = delegat.SmartRollupAddMessagesCount, + SmartRollupCementCount = delegat.SmartRollupCementCount, + SmartRollupExecuteCount = delegat.SmartRollupExecuteCount, + SmartRollupOriginateCount = delegat.SmartRollupOriginateCount, + SmartRollupPublishCount = delegat.SmartRollupPublishCount, + SmartRollupRecoverBondCount = delegat.SmartRollupRecoverBondCount, + SmartRollupRefuteCount = delegat.SmartRollupRefuteCount, + RefutationGamesCount = delegat.RefutationGamesCount, + ActiveRefutationGamesCount = delegat.ActiveRefutationGamesCount }; Db.Entry(delegat).State = EntityState.Detached; diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs index 678c0043d..04ea24030 100644 --- a/Tzkt.Sync/Services/Cache/TicketsCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -57,7 +57,7 @@ public Ticket Get(long id) return token; } - public bool TryGet(int contractId, byte[] rawContent, byte[] rawType, out Ticket token) + public bool TryGetCached(int contractId, byte[] rawContent, byte[] rawType, out Ticket token) { return CachedByKey.TryGetValue((contractId, rawContent, rawType), out token); } From b71aec752a46c57ded6354dc68b9af0d24fa48b6 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Wed, 30 Aug 2023 14:32:36 +0300 Subject: [PATCH 45/51] Refactoring and fixes --- Tzkt.Sync/Extensions/BytesExtension.cs | 12 +- .../Commits/Operations/TransactionsCommit.cs | 12 +- .../Operations/TransferTicketCommit.cs | 12 +- .../Operations/SmartRollupExecuteCommit.cs | 12 +- .../Handlers/Proto16/Commits/TicketsCommit.cs | 330 +++++++++--------- .../Proto16/Diagnostics/Diagnostics.cs | 8 +- .../Handlers/Proto16/Proto16Handler.cs | 12 +- .../Handlers/Proto17/Proto17Handler.cs | 12 +- Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs | 23 +- Tzkt.Sync/Services/Cache/TicketsCache.cs | 6 +- Tzkt.Sync/Utils/HashableBytes.cs | 11 + 11 files changed, 235 insertions(+), 215 deletions(-) create mode 100644 Tzkt.Sync/Utils/HashableBytes.cs diff --git a/Tzkt.Sync/Extensions/BytesExtension.cs b/Tzkt.Sync/Extensions/BytesExtension.cs index a4fca77aa..ff8e133f4 100644 --- a/Tzkt.Sync/Extensions/BytesExtension.cs +++ b/Tzkt.Sync/Extensions/BytesExtension.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tzkt.Sync +namespace Tzkt.Sync { static class BytesExtension { @@ -49,6 +47,14 @@ public static bool IsEqual(this byte[] src, byte[] data) return true; } + public static int GetHashCodeExt(this byte[] data) + { + var res = data.Length; + for (int i = 0; i < data.Length; i++) + res ^= data[i] << (8 * (i % 4)); + return res; + } + public static void Flush(this byte[] data) { for (int i = 0; i < data.Length; i++) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index 884a772fc..5262a7a74 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -13,7 +13,7 @@ class TransactionsCommit : ProtocolCommit { public TransactionOperation Transaction { get; private set; } public IEnumerable BigMapDiffs { get; private set; } - public IEnumerable TicketUpdates { get; private set; } + public IEnumerable TicketUpdates { get; private set; } public TransactionsCommit(ProtocolHandler protocol) : base(protocol) { } @@ -688,12 +688,12 @@ protected virtual int GetConsumedGas(JsonElement result) return result.OptionalInt32("consumed_gas") ?? 0; } - protected virtual IEnumerable ParseTicketUpdates(string property, JsonElement result) + protected virtual IEnumerable ParseTicketUpdates(string property, JsonElement result) { if (!result.TryGetProperty(property, out var ticketUpdates)) return null; - var res = new List(); + var res = new List(); foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { try @@ -704,9 +704,9 @@ protected virtual IEnumerable ParseTicketUpdates(string property, var schema = Schema.Create(type as MichelinePrim); ; var rawContent = schema.Optimize(value).ToBytes(); var rawType = type.ToBytes(); - res.Add(new TicketUpdate + res.Add(new TicketUpdates { - TicketToken = new TicketToken + Ticket = new TicketIdentity { Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, @@ -715,7 +715,7 @@ protected virtual IEnumerable ParseTicketUpdates(string property, TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new Update + Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new TicketUpdate { Account = x.RequiredString("account"), Amount = BigInteger.Parse(x.RequiredString("amount")) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 035c9519a..36933ecd5 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -10,7 +10,7 @@ namespace Tzkt.Sync.Protocols.Proto13 class TransferTicketCommit : ProtocolCommit { public TransferTicketOperation Operation { get; private set; } - public IEnumerable TicketUpdates { get; private set; } + public IEnumerable TicketUpdates { get; private set; } public TransferTicketCommit(ProtocolHandler protocol) : base(protocol) { } @@ -197,12 +197,12 @@ public virtual async Task Revert(Block block, TransferTicketOperation operation) Cache.AppState.ReleaseOperationId(); } - protected virtual IEnumerable ParseTicketUpdates(JsonElement result) + protected virtual IEnumerable ParseTicketUpdates(JsonElement result) { if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; - var res = new List(); + var res = new List(); foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { try @@ -213,9 +213,9 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul var schema = Schema.Create(type as MichelinePrim); ; var rawContent = schema.Optimize(value).ToBytes(); var rawType = type.ToBytes(); - res.Add(new TicketUpdate + res.Add(new TicketUpdates { - TicketToken = new TicketToken + Ticket = new TicketIdentity { Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, @@ -224,7 +224,7 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new Update + Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new TicketUpdate { Account = x.RequiredString("account"), Amount = BigInteger.Parse(x.RequiredString("amount")) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index c61a4fb12..1ea36fc42 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -10,7 +10,7 @@ namespace Tzkt.Sync.Protocols.Proto16 class SmartRollupExecuteCommit : ProtocolCommit { public SmartRollupExecuteOperation Operation { get; private set; } - public IEnumerable TicketUpdates { get; private set; } + public IEnumerable TicketUpdates { get; private set; } public SmartRollupExecuteCommit(ProtocolHandler protocol) : base(protocol) { } @@ -193,12 +193,12 @@ public virtual async Task Revert(Block block, SmartRollupExecuteOperation operat Cache.AppState.ReleaseOperationId(); } - protected virtual IEnumerable ParseTicketUpdates(JsonElement result) + protected virtual IEnumerable ParseTicketUpdates(JsonElement result) { if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; - var res = new List(); + var res = new List(); foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) { try @@ -209,9 +209,9 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul var schema = Schema.Create(type as MichelinePrim); ; var rawContent = schema.Optimize(value).ToBytes(); var rawType = type.ToBytes(); - res.Add(new TicketUpdate + res.Add(new TicketUpdates { - TicketToken = new TicketToken + Ticket = new TicketIdentity { Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, @@ -220,7 +220,7 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resul TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new Update + Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new TicketUpdate { Account = x.RequiredString("account"), Amount = BigInteger.Parse(x.RequiredString("amount")) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index 749a07d1e..d41354cd6 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -9,14 +9,20 @@ class TicketsCommit : ProtocolCommit { public TicketsCommit(ProtocolHandler protocol) : base(protocol) { } - readonly Dictionary> Updates = new(); - - public virtual void Append(ManagerOperation op, IEnumerable updates) + readonly Dictionary>> Updates = new(); + + public virtual void Append(ManagerOperation parent, ManagerOperation op, IEnumerable updates) { - if (!Updates.TryGetValue(op, out var list)) - Updates.Add(op, list = new()); + if (!Updates.TryGetValue(parent, out var opUpdates)) + Updates.Add(parent, opUpdates = new()); + + foreach (var update in updates) + { + if (!opUpdates.TryGetValue(update.Ticket, out var ticketUpdates)) + opUpdates.Add(update.Ticket, ticketUpdates = new()); - list.AddRange(updates); + ticketUpdates.AddRange(update.Updates.Select(update => (op, update))); + } } public virtual async Task Apply() @@ -28,36 +34,33 @@ public virtual async Task Apply() var ticketsSet = new HashSet<(int, byte[], int, byte[], int)>(); var balancesSet = new HashSet<(int, long)>(); - var list = Updates.SelectMany(x => x.Value).ToList(); - - foreach (var update in list) + foreach (var (ticket, updates) in Updates.SelectMany(x => x.Value)) { - accountsSet.Add(update.TicketToken.Ticketer); - foreach (var upd in update.Updates) - { + accountsSet.Add(ticket.Ticketer); + foreach (var (_, upd) in updates) accountsSet.Add(upd.Account); - } } + await Cache.Accounts.Preload(accountsSet); - - foreach (var update in list) + + foreach (var (ticket, _) in Updates.SelectMany(x => x.Value)) { - if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) - ticketsSet.Add((ticketer.Id, update.TicketToken.RawContent, update.TicketToken.ContentHash, update.TicketToken.RawType, update.TicketToken.TypeHash)); + if (Cache.Accounts.TryGetCached(ticket.Ticketer, out var ticketer)) + ticketsSet.Add((ticketer.Id, ticket.RawContent, ticket.ContentHash, ticket.RawType, ticket.TypeHash)); } await Cache.Tickets.Preload(ticketsSet); - foreach (var update in list) + foreach (var (ticket, updates) in Updates.SelectMany(x => x.Value)) { - if (Cache.Accounts.TryGetCached(update.TicketToken.Ticketer, out var ticketer)) + if (Cache.Accounts.TryGetCached(ticket.Ticketer, out var ticketer)) { - if (Cache.Tickets.TryGetCached(ticketer.Id, update.TicketToken.RawContent, update.TicketToken.RawType, out var ticket)) + if (Cache.Tickets.TryGetCached(ticketer.Id, ticket.RawContent, ticket.RawType, out var _ticket)) { - foreach (var upd in update.Updates) + foreach (var (_, upd) in updates) { if (Cache.Accounts.TryGetCached(upd.Account, out var acc)) - balancesSet.Add((acc.Id, ticket.Id)); + balancesSet.Add((acc.Id, _ticket.Id)); } } } @@ -66,45 +69,35 @@ public virtual async Task Apply() await Cache.TicketBalances.Preload(balancesSet); #endregion - foreach (var (op, opUpdates) in Updates) - { - op.Block.Events |= BlockEvents.Tickets; - - var ticketUpdates = new Dictionary>(); + Updates.First().Key.Block.Events |= BlockEvents.Tickets; - foreach (var upd in opUpdates) + foreach (var (parent, opUpdates) in Updates.OrderBy(kv => kv.Key.Id)) + { + foreach (var (ticketIdentity, ticketUpdates) in opUpdates.OrderBy(x => x.Value[0].Op.Id).ThenBy(x => x.Key.ContentHash + x.Key.TypeHash)) { - var ticketer = GetOrCreateAccount(op, upd.TicketToken.Ticketer) as Contract; - var ticket = GetOrCreateTicket(op, ticketer, upd.TicketToken); - - if (!ticketUpdates.TryGetValue(ticket, out var upds)) - ticketUpdates.Add(ticket, upds = new()); + var ticketer = GetOrCreateAccount(ticketUpdates[0].Op, ticketIdentity.Ticketer) as Contract; + var ticket = GetOrCreateTicket(ticketUpdates[0].Op, ticketer, ticketIdentity); - upds.AddRange(upd.Updates); - } - - foreach (var (ticket, updates) in ticketUpdates) - { - if (updates.Count == 1 || updates.BigSum(x => x.Amount) != BigInteger.Zero) + if (ticketUpdates.Count == 1 || ticketUpdates.BigSum(x => x.Update.Amount) != BigInteger.Zero) { - foreach (var ticketUpdate in updates) + foreach (var (op, ticketUpdate) in ticketUpdates) MintOrBurnTickets(op, ticket, ticketUpdate.Account, ticketUpdate.Amount); } - else if (updates.Count(x => x.Amount < BigInteger.Zero) == 1) + else if (ticketUpdates.Count(x => x.Update.Amount < BigInteger.Zero) == 1) { - var from = updates.First(x => x.Amount < BigInteger.Zero); - foreach (var ticketUpdate in updates.Where(x => x.Amount > BigInteger.Zero)) - TransferTickets(op, ticket, from.Account, ticketUpdate.Account, ticketUpdate.Amount); + var (fromOp, fromUpdate) = ticketUpdates.First(x => x.Update.Amount < BigInteger.Zero); + foreach (var (op, ticketUpdate) in ticketUpdates.Where(x => x.Update.Amount > BigInteger.Zero)) + TransferTickets(ticketUpdates[0].Op, ticket, fromUpdate.Account, ticketUpdate.Account, ticketUpdate.Amount); } - else if (updates.Count(x => x.Amount > BigInteger.Zero) == 1) + else if (ticketUpdates.Count(x => x.Update.Amount > BigInteger.Zero) == 1) { - var to = updates.First(x => x.Amount > BigInteger.Zero); - foreach (var ticketUpdate in updates.Where(x => x.Amount < BigInteger.Zero)) - TransferTickets(op, ticket, ticketUpdate.Account, to.Account, -ticketUpdate.Amount); + var (toOp, toUpdate) = ticketUpdates.First(x => x.Update.Amount > BigInteger.Zero); + foreach (var (op, ticketUpdate) in ticketUpdates.Where(x => x.Update.Amount < BigInteger.Zero)) + TransferTickets(ticketUpdates[0].Op, ticket, ticketUpdate.Account, toUpdate.Account, -ticketUpdate.Amount); } else { - foreach (var ticketUpdate in updates) + foreach (var (op, ticketUpdate) in ticketUpdates) MintOrBurnTickets(op, ticket, ticketUpdate.Account, ticketUpdate.Amount); } } @@ -132,91 +125,91 @@ Account GetOrCreateAccount(ManagerOperation op, string address) LastLevel = op.Level, Type = AccountType.Ghost }; + Db.Accounts.Add(account); Cache.Accounts.Add(account); } return account; } - Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketToken ticketToken) + Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketIdentity ticketToken) { - if (Cache.Tickets.TryGetCached(contract.Id, ticketToken.RawContent, ticketToken.RawType, out var ticket)) - return ticket; - - var state = Cache.AppState.Get(); - state.TicketsCount++; - - ticket = new Ticket + if (!Cache.Tickets.TryGetCached(contract.Id, ticketToken.RawContent, ticketToken.RawType, out var ticket)) { - Id = op switch + ticket = new Ticket { - TransactionOperation transaction => Cache.AppState.NextSubId(transaction), - TransferTicketOperation transferTicket => Cache.AppState.NextSubId(transferTicket), - SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - TicketerId = contract.Id, - FirstMinterId = op switch - { - TransactionOperation transaction => transaction.InitiatorId ?? transaction.SenderId, - TransferTicketOperation transferTicket => transferTicket.SenderId, - SmartRollupExecuteOperation srExecute => srExecute.SenderId, - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - FirstLevel = op.Level, - LastLevel = op.Level, - TotalBurned = BigInteger.Zero, - TotalMinted = BigInteger.Zero, - TotalSupply = BigInteger.Zero, - RawType = ticketToken.RawType, - RawContent = ticketToken.RawContent, - JsonContent = ticketToken.JsonContent, - ContentHash = ticketToken.ContentHash, - TypeHash = ticketToken.TypeHash, - }; - - Db.Tickets.Add(ticket); - Cache.Tickets.Add(ticket); - - Db.TryAttach(contract); - contract.TicketsCount++; - + Id = op switch + { + TransactionOperation transaction => Cache.AppState.NextSubId(transaction), + TransferTicketOperation transferTicket => Cache.AppState.NextSubId(transferTicket), + SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + TicketerId = contract.Id, + FirstMinterId = op switch + { + TransactionOperation transaction => transaction.InitiatorId ?? transaction.SenderId, + TransferTicketOperation transferTicket => transferTicket.SenderId, + SmartRollupExecuteOperation srExecute => srExecute.SenderId, + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + FirstLevel = op.Level, + LastLevel = op.Level, + TotalBurned = BigInteger.Zero, + TotalMinted = BigInteger.Zero, + TotalSupply = BigInteger.Zero, + RawType = ticketToken.RawType, + RawContent = ticketToken.RawContent, + JsonContent = ticketToken.JsonContent, + ContentHash = ticketToken.ContentHash, + TypeHash = ticketToken.TypeHash, + }; + + Db.Tickets.Add(ticket); + Cache.Tickets.Add(ticket); + + Db.TryAttach(contract); + contract.TicketsCount++; + + var state = Cache.AppState.Get(); + state.TicketsCount++; + } return ticket; } - + TicketBalance GetOrCreateTicketBalance(ManagerOperation op, Ticket ticket, Account account) { - if (Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) - return ticketBalance; - - var state = Cache.AppState.Get(); - state.TicketBalancesCount++; - - ticketBalance = new TicketBalance + if (!Cache.TicketBalances.TryGet(account.Id, ticket.Id, out var ticketBalance)) { - Id = op switch + ticketBalance = new TicketBalance { - TransactionOperation transaction => Cache.AppState.NextSubId(transaction), - TransferTicketOperation transferTicket => Cache.AppState.NextSubId(transferTicket), - SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), - _ => throw new ArgumentOutOfRangeException(nameof(op)) - }, - AccountId = account.Id, - TicketId = ticket.Id, - TicketerId = ticket.TicketerId, - FirstLevel = op.Level, - LastLevel = op.Level, - Balance = BigInteger.Zero - }; - Db.TicketBalances.Add(ticketBalance); - Cache.TicketBalances.Add(ticketBalance); + Id = op switch + { + TransactionOperation transaction => Cache.AppState.NextSubId(transaction), + TransferTicketOperation transferTicket => Cache.AppState.NextSubId(transferTicket), + SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), + _ => throw new ArgumentOutOfRangeException(nameof(op)) + }, + AccountId = account.Id, + TicketId = ticket.Id, + TicketerId = ticket.TicketerId, + FirstLevel = op.Level, + LastLevel = op.Level, + Balance = BigInteger.Zero + }; + + Db.TicketBalances.Add(ticketBalance); + Cache.TicketBalances.Add(ticketBalance); - Db.TryAttach(ticket); - ticket.BalancesCount++; + Db.TryAttach(ticket); + ticket.BalancesCount++; - Db.TryAttach(account); - account.TicketBalancesCount++; + Db.TryAttach(account); + account.TicketBalancesCount++; + var state = Cache.AppState.Get(); + state.TicketBalancesCount++; + } return ticketBalance; } @@ -261,7 +254,9 @@ void TransferTickets(ManagerOperation op, Ticket ticket, string fromAddress, str if (toBalance != fromBalance) toBalance.TransfersCount++; toBalance.LastLevel = op.Level; + Db.TryAttach(ticket); ticket.TransfersCount++; + ticket.LastLevel = op.Level; if (amount != BigInteger.Zero && fromBalance != toBalance) { if (fromBalance.Balance == BigInteger.Zero) @@ -414,7 +409,7 @@ public virtual async Task Revert(Block block) foreach (var id in ticketsSet) { - var ticket = Cache.Tickets.Get(id); + var ticket = Cache.Tickets.GetCached(id); accountsSet.Add(ticket.TicketerId); } @@ -427,42 +422,49 @@ public virtual async Task Revert(Block block) foreach (var transfer in transfers) { - var ticket = Cache.Tickets.Get(transfer.TicketId); + var ticket = Cache.Tickets.GetCached(transfer.TicketId); Db.TryAttach(ticket); - ticket.LastLevel = block.Level; ticket.TransfersCount--; - if (ticket.FirstLevel == block.Level) + ticket.LastLevel = block.Level; + if (ticket.TransfersCount == 0) ticketsToRemove.Add(ticket); + state.TicketTransfersCount--; + if (transfer.FromId is int fromId && transfer.ToId is int toId) { #region revert transfer var from = Cache.Accounts.GetCached(fromId); - var to = Cache.Accounts.GetCached(toId); var fromBalance = Cache.TicketBalances.Get(from.Id, ticket.Id); + var to = Cache.Accounts.GetCached(toId); var toBalance = Cache.TicketBalances.Get(to.Id, ticket.Id); Db.TryAttach(from); - Db.TryAttach(to); - Db.TryAttach(fromBalance); - Db.TryAttach(toBalance); - from.TicketTransfersCount--; - if (to != from) to.TicketTransfersCount--; + from.LastLevel = block.Level; + Db.TryAttach(to); + if (to != from) + { + to.TicketTransfersCount--; + to.LastLevel = block.Level; + } + + Db.TryAttach(fromBalance); fromBalance.Balance += transfer.Amount; fromBalance.TransfersCount--; fromBalance.LastLevel = block.Level; - if (fromBalance.FirstLevel == block.Level) + if (fromBalance.TransfersCount == 0) ticketBalancesToRemove.Add(fromBalance); + Db.TryAttach(toBalance); toBalance.Balance -= transfer.Amount; if (toBalance != fromBalance) toBalance.TransfersCount--; toBalance.LastLevel = block.Level; - if (toBalance.FirstLevel == block.Level) + if (toBalance.TransfersCount == 0) ticketBalancesToRemove.Add(toBalance); - if (transfer.Amount != BigInteger.Zero && fromBalance.Id != toBalance.Id) + if (transfer.Amount != BigInteger.Zero && fromBalance != toBalance) { if (fromBalance.Balance == transfer.Amount) { @@ -475,8 +477,6 @@ public virtual async Task Revert(Block block) ticket.HoldersCount--; } } - - state.TicketTransfersCount--; #endregion } else if (transfer.ToId != null) @@ -486,29 +486,26 @@ public virtual async Task Revert(Block block) var toBalance = Cache.TicketBalances.Get(to.Id, ticket.Id); Db.TryAttach(to); - Db.TryAttach(toBalance); - to.TicketTransfersCount--; + to.LastLevel = block.Level; + Db.TryAttach(toBalance); toBalance.Balance -= transfer.Amount; toBalance.TransfersCount--; toBalance.LastLevel = block.Level; - if (toBalance.FirstLevel == block.Level) + if (toBalance.TransfersCount == 0) ticketBalancesToRemove.Add(toBalance); if (transfer.Amount != BigInteger.Zero) { + ticket.TotalSupply -= transfer.Amount; + ticket.TotalMinted -= transfer.Amount; if (toBalance.Balance == BigInteger.Zero) { to.ActiveTicketsCount--; ticket.HoldersCount--; } - - ticket.TotalMinted -= transfer.Amount; - ticket.TotalSupply -= transfer.Amount; } - - state.TicketTransfersCount--; #endregion } else @@ -518,69 +515,62 @@ public virtual async Task Revert(Block block) var fromBalance = Cache.TicketBalances.Get(from.Id, ticket.Id); Db.TryAttach(from); - Db.TryAttach(fromBalance); - from.TicketTransfersCount--; + from.LastLevel = block.Level; + Db.TryAttach(fromBalance); fromBalance.Balance += transfer.Amount; fromBalance.TransfersCount--; fromBalance.LastLevel = block.Level; - if (fromBalance.FirstLevel == block.Level) + if (fromBalance.TransfersCount == 0) ticketBalancesToRemove.Add(fromBalance); if (transfer.Amount != BigInteger.Zero) { + ticket.TotalSupply += transfer.Amount; + ticket.TotalBurned -= transfer.Amount; if (fromBalance.Balance == transfer.Amount) { from.ActiveTicketsCount++; ticket.HoldersCount++; } - - ticket.TotalBurned -= transfer.Amount; - ticket.TotalSupply += transfer.Amount; } - - state.TicketTransfersCount--; #endregion } } - //TODO TICKETS Make test for mint, burn and transfer in one operation foreach (var ticketBalance in ticketBalancesToRemove) { - if (ticketBalance.FirstLevel == block.Level) - { - Db.TicketBalances.Remove(ticketBalance); - Cache.TicketBalances.Remove(ticketBalance); + Db.TicketBalances.Remove(ticketBalance); + Cache.TicketBalances.Remove(ticketBalance); - var t = Cache.Tickets.Get(ticketBalance.TicketId); - Db.TryAttach(t); - t.BalancesCount--; + var t = Cache.Tickets.GetCached(ticketBalance.TicketId); + Db.TryAttach(t); + t.BalancesCount--; - var a = Cache.Accounts.GetCached(ticketBalance.AccountId); - Db.TryAttach(a); - a.TicketBalancesCount--; + var a = Cache.Accounts.GetCached(ticketBalance.AccountId); + Db.TryAttach(a); + a.TicketBalancesCount--; - state.TicketBalancesCount--; - } + state.TicketBalancesCount--; } foreach (var ticket in ticketsToRemove) { - if (ticket.FirstLevel == block.Level) - { - Db.Tickets.Remove(ticket); - Cache.Tickets.Remove(ticket); + Db.Tickets.Remove(ticket); + Cache.Tickets.Remove(ticket); - var c = (Contract)Cache.Accounts.GetCached(ticket.TicketerId); - Db.TryAttach(c); - c.TicketsCount--; + var contract = (Contract)Cache.Accounts.GetCached(ticket.TicketerId); + Db.TryAttach(contract); + contract.TicketsCount--; - state.TicketsCount--; - } + state.TicketsCount--; } - await Db.Database.ExecuteSqlRawAsync($@"DELETE FROM ""TicketTransfers"" WHERE ""Level"" = {block.Level};"); + await Db.Database.ExecuteSqlRawAsync($""" + DELETE FROM "TicketTransfers" + WHERE "Level" = {block.Level} + """); } } } \ No newline at end of file diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs index c5f4120c5..0bf01d82e 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Diagnostics/Diagnostics.cs @@ -12,17 +12,17 @@ public Diagnostics(ProtocolHandler handler) : base(handler) { } protected override async Task TestTicketBalance(int level, TicketBalance balance) { var ticketer = await Cache.Accounts.GetAsync(balance.TicketerId); - var ticket = Cache.Tickets.Get(balance.TicketId); + var ticket = Cache.Tickets.GetCached(balance.TicketId); var account = await Cache.Accounts.GetAsync(balance.AccountId); - var update = new + var ticketIdentity = JsonSerializer.Serialize(new { ticketer = ticketer.Address, content_type = Micheline.FromBytes(ticket.RawType), content = Micheline.FromBytes(ticket.RawContent) - }; + }); - if (BigInteger.TryParse((await Rpc.GetTicketBalance(level, account.Address, JsonSerializer.Serialize(update))).RequiredString(), out var remoteBalance)) + if (BigInteger.TryParse((await Rpc.GetTicketBalance(level, account.Address, ticketIdentity)).RequiredString(), out var remoteBalance)) { if (remoteBalance != balance.Balance) throw new Exception($"Diagnostics failed: wrong ticket balance for {account.Address}"); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs index 6c36b5221..8ab151828 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Proto16Handler.cs @@ -171,7 +171,7 @@ public override async Task Commit(JsonElement block) if (parent.BigMapDiffs != null) bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); if (parent.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction, parent.TicketUpdates); + ticketsCommit.Append(parent.Transaction, parent.Transaction, parent.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) { @@ -194,7 +194,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent.Transaction, internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -233,7 +233,7 @@ public override async Task Commit(JsonElement block) var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); if (parent1.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation, parent1.TicketUpdates); + ticketsCommit.Append(parent1.Operation, parent1.Operation, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) @@ -246,7 +246,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation, internalTx.TicketUpdates); + ticketsCommit.Append(parent1.Operation, internalTx.Transaction, internalTx.TicketUpdates); break; default: throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); @@ -264,7 +264,7 @@ public override async Task Commit(JsonElement block) var parent2 = new SmartRollupExecuteCommit(this); await parent2.Apply(blockCommit.Block, operation, content); if (parent2.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation, parent2.TicketUpdates); + ticketsCommit.Append(parent2.Operation, parent2.Operation, parent2.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult2)) { foreach (var internalContent in internalResult2.EnumerateArray()) @@ -286,7 +286,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation, internalTx.TicketUpdates); + ticketsCommit.Append(parent2.Operation, internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); diff --git a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs index bf884ca4c..f5c23e376 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto17/Proto17Handler.cs @@ -171,7 +171,7 @@ public override async Task Commit(JsonElement block) if (parent.BigMapDiffs != null) bigMapCommit.Append(parent.Transaction, parent.Transaction.Target as Contract, parent.BigMapDiffs); if (parent.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction, parent.TicketUpdates); + ticketsCommit.Append(parent.Transaction, parent.Transaction, parent.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult)) { @@ -194,7 +194,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent.Transaction, internalTx.TicketUpdates); + ticketsCommit.Append(parent.Transaction, internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); @@ -233,7 +233,7 @@ public override async Task Commit(JsonElement block) var parent1 = new TransferTicketCommit(this); await parent1.Apply(blockCommit.Block, operation, content); if (parent1.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation, parent1.TicketUpdates); + ticketsCommit.Append(parent1.Operation, parent1.Operation, parent1.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult1)) { foreach (var internalContent in internalResult1.EnumerateArray()) @@ -246,7 +246,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent1.Operation, internalTx.TicketUpdates); + ticketsCommit.Append(parent1.Operation, internalTx.Transaction, internalTx.TicketUpdates); break; default: throw new NotImplementedException($"internal '{content.RequiredString("kind")}' inside 'transfer_ticket' is not expected"); @@ -264,7 +264,7 @@ public override async Task Commit(JsonElement block) var parent2 = new SmartRollupExecuteCommit(this); await parent2.Apply(blockCommit.Block, operation, content); if (parent2.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation, parent2.TicketUpdates); + ticketsCommit.Append(parent2.Operation, parent2.Operation, parent2.TicketUpdates); if (content.Required("metadata").TryGetProperty("internal_operation_results", out var internalResult2)) { foreach (var internalContent in internalResult2.EnumerateArray()) @@ -286,7 +286,7 @@ public override async Task Commit(JsonElement block) if (internalTx.BigMapDiffs != null) bigMapCommit.Append(internalTx.Transaction, internalTx.Transaction.Target as Contract, internalTx.BigMapDiffs); if (internalTx.TicketUpdates != null) - ticketsCommit.Append(parent2.Operation, internalTx.TicketUpdates); + ticketsCommit.Append(parent2.Operation, internalTx.Transaction, internalTx.TicketUpdates); break; case "event": await new ContractEventCommit(this).Apply(blockCommit.Block, internalContent); diff --git a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs index d2b46d6f0..f22c5899d 100644 --- a/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs +++ b/Tzkt.Sync/Protocols/Helpers/TicketUpdate.cs @@ -2,13 +2,13 @@ namespace Tzkt.Sync.Protocols { - public class TicketUpdate + public class TicketUpdates { - public TicketToken TicketToken { get; set; } - public IEnumerable Updates { get; set; } + public TicketIdentity Ticket { get; set; } + public IEnumerable Updates { get; set; } } - public class TicketToken + public class TicketIdentity { public string Ticketer { get; set; } public byte[] RawType { get; set; } @@ -17,9 +17,22 @@ public class TicketToken public int ContentHash { get; set; } public int TypeHash { get; set; } + + public override bool Equals(object obj) + { + return obj is TicketIdentity ticket && + ticket.Ticketer == Ticketer && + ticket.RawType.IsEqual(RawType) && + ticket.RawContent.IsEqual(RawContent); + } + + public override int GetHashCode() + { + return HashCode.Combine(Ticketer.GetHashCode(), ContentHash, TypeHash); + } } - public class Update + public class TicketUpdate { public string Account { get; set; } public BigInteger Amount { get; set; } diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs index 04ea24030..d71938759 100644 --- a/Tzkt.Sync/Services/Cache/TicketsCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -9,7 +9,7 @@ public class TicketsCache public const int MaxItems = 4 * 4096; //TODO: set limits in app settings static readonly Dictionary CachedById = new(MaxItems); - static readonly Dictionary<(int ContractId, byte[] RawContent, byte[] RawType), Ticket> CachedByKey = new(MaxItems); + static readonly Dictionary<(int ContractId, HashableBytes RawContent, HashableBytes RawType), Ticket> CachedByKey = new(MaxItems); readonly TzktContext Db; @@ -50,10 +50,10 @@ public void Remove(Ticket ticket) CachedByKey.Remove((ticket.TicketerId, ticket.RawContent, ticket.RawType)); } - public Ticket Get(long id) + public Ticket GetCached(long id) { if (!CachedById.TryGetValue(id, out var token)) - throw new Exception($"Ticket #{id} doesn't exist"); + throw new Exception($"Ticket #{id} doesn't exist in the cache"); return token; } diff --git a/Tzkt.Sync/Utils/HashableBytes.cs b/Tzkt.Sync/Utils/HashableBytes.cs new file mode 100644 index 000000000..9aae4096c --- /dev/null +++ b/Tzkt.Sync/Utils/HashableBytes.cs @@ -0,0 +1,11 @@ +namespace Tzkt.Sync +{ + class HashableBytes + { + readonly byte[] Bytes; + public HashableBytes(byte[] bytes) => Bytes = bytes; + public static implicit operator HashableBytes(byte[] array) => new(array); + public override bool Equals(object obj) => obj is HashableBytes hb && hb.Bytes.IsEqual(Bytes); + public override int GetHashCode() => Bytes.GetHashCodeExt(); + } +} From 3040fa427ec47a0c00202b57634bddcc3f96af4a Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Wed, 30 Aug 2023 15:29:09 +0300 Subject: [PATCH 46/51] Better handle multiple transfers in a single op --- .../Handlers/Proto16/Commits/TicketsCommit.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index d41354cd6..07c185fb3 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -95,6 +95,19 @@ public virtual async Task Apply() foreach (var (op, ticketUpdate) in ticketUpdates.Where(x => x.Update.Amount < BigInteger.Zero)) TransferTickets(ticketUpdates[0].Op, ticket, ticketUpdate.Account, toUpdate.Account, -ticketUpdate.Amount); } + else if (IsTransfersSequence(ticketUpdates)) + { + for (int i = 0; i < ticketUpdates.Count; i += 2) + { + var u1 = ticketUpdates[i].Update; + var u2 = ticketUpdates[i + 1].Update; + + if (u1.Amount < 0) // from u1 to u2 + TransferTickets(ticketUpdates[i].Op, ticket, u1.Account, u2.Account, u2.Amount); + else // from u2 to u1 + TransferTickets(ticketUpdates[i].Op, ticket, u2.Account, u1.Account, u1.Amount); + } + } else { foreach (var (op, ticketUpdate) in ticketUpdates) @@ -104,6 +117,18 @@ public virtual async Task Apply() } } + static bool IsTransfersSequence(List<(ManagerOperation Op, TicketUpdate Update)> updates) + { + if (updates.Count % 2 != 0) + return false; + + for (int i = 0; i < updates.Count; i += 2) + if (updates[i].Update.Amount != -updates[i + 1].Update.Amount) + return false; + + return true; + } + Account GetOrCreateAccount(ManagerOperation op, string address) { if (!Cache.Accounts.TryGetCached(address, out var account)) From 314d2b1847c254ddd1b05fa77aa2c57b6b869c36 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Wed, 30 Aug 2023 16:18:58 +0300 Subject: [PATCH 47/51] More bug-resistant ticket updates parsing --- Tzkt.Sync/Extensions/JsonElementExtension.cs | 9 ++- .../Commits/Operations/TransactionsCommit.cs | 56 ++++++++++++------ .../Operations/TransferTicketCommit.cs | 57 +++++++++++++------ .../Operations/SmartRollupExecuteCommit.cs | 57 +++++++++++++------ 4 files changed, 123 insertions(+), 56 deletions(-) diff --git a/Tzkt.Sync/Extensions/JsonElementExtension.cs b/Tzkt.Sync/Extensions/JsonElementExtension.cs index 80aa65978..6b32ed447 100644 --- a/Tzkt.Sync/Extensions/JsonElementExtension.cs +++ b/Tzkt.Sync/Extensions/JsonElementExtension.cs @@ -1,5 +1,4 @@ -using System; -using System.Linq; +using System.Numerics; using System.Text.Json; namespace Tzkt.Sync @@ -136,6 +135,12 @@ public static long RequiredInt64(this JsonElement el, string name) : throw new SerializationException($"Missed required long {name}"); } + public static BigInteger RequiredBigInteger(this JsonElement el, string name) + { + return el.TryGetProperty(name, out var prop) && BigInteger.TryParse(prop.GetString(), out var res) ? res + : throw new SerializationException($"Missed required BigInteger {name}"); + } + public static int ParseInt32(this JsonElement el) { return el.ValueKind == JsonValueKind.String diff --git a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs index 5262a7a74..f75dc8297 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto1/Commits/Operations/TransactionsCommit.cs @@ -3,7 +3,6 @@ using Microsoft.EntityFrameworkCore; using Netezos.Contracts; using Netezos.Encoding; - using Tzkt.Data.Models; using Tzkt.Data.Models.Base; @@ -694,16 +693,45 @@ protected virtual IEnumerable ParseTicketUpdates(string property, return null; var res = new List(); - foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) + foreach (var updates in ticketUpdates.RequiredArray().EnumerateArray()) { - try + var list = new List(); + foreach (var update in updates.RequiredArray("updates").EnumerateArray()) { - var ticketToken = update.Required("ticket_token"); - var value = Micheline.FromJson(ticketToken.Required("content")); + var amount = update.RequiredBigInteger("amount"); + if (amount != BigInteger.Zero) + { + list.Add(new TicketUpdate + { + Account = update.RequiredString("account"), + Amount = amount + }); + } + } + + if (list.Count > 0) + { + var ticketToken = updates.Required("ticket_token"); var type = Micheline.FromJson(ticketToken.Required("content_type")); - var schema = Schema.Create(type as MichelinePrim); ; - var rawContent = schema.Optimize(value).ToBytes(); + var value = Micheline.FromJson(ticketToken.Required("content")); var rawType = type.ToBytes(); + + byte[] rawContent; + string jsonContent; + + try + { + var schema = Schema.Create(type as MichelinePrim); + rawContent = schema.Optimize(value).ToBytes(); + jsonContent = schema.Humanize(value); + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to parse ticket content"); + rawContent = value.ToBytes(); + jsonContent = null; + } + res.Add(new TicketUpdates { Ticket = new TicketIdentity @@ -711,24 +739,16 @@ protected virtual IEnumerable ParseTicketUpdates(string property, Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, RawContent = rawContent, - JsonContent = schema.Humanize(value), + JsonContent = jsonContent, TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new TicketUpdate - { - Account = x.RequiredString("account"), - Amount = BigInteger.Parse(x.RequiredString("amount")) - }) + Updates = list }); } - catch (Exception ex) - { - Logger.LogError(ex, "Failed to process ticket updates"); - } } - return res; + return res.Count > 0 ? res : null; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs index 36933ecd5..3a8e0d61a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto13/Commits/Operations/TransferTicketCommit.cs @@ -196,23 +196,52 @@ public virtual async Task Revert(Block block, TransferTicketOperation operation) Cache.AppState.ReleaseManagerCounter(); Cache.AppState.ReleaseOperationId(); } - + protected virtual IEnumerable ParseTicketUpdates(JsonElement result) { if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; var res = new List(); - foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) + foreach (var updates in ticketUpdates.RequiredArray().EnumerateArray()) { - try + var list = new List(); + foreach (var update in updates.RequiredArray("updates").EnumerateArray()) { - var ticketToken = update.Required("ticket_token"); - var value = Micheline.FromJson(ticketToken.Required("content")); + var amount = update.RequiredBigInteger("amount"); + if (amount != BigInteger.Zero) + { + list.Add(new TicketUpdate + { + Account = update.RequiredString("account"), + Amount = amount + }); + } + } + + if (list.Count > 0) + { + var ticketToken = updates.Required("ticket_token"); var type = Micheline.FromJson(ticketToken.Required("content_type")); - var schema = Schema.Create(type as MichelinePrim); ; - var rawContent = schema.Optimize(value).ToBytes(); + var value = Micheline.FromJson(ticketToken.Required("content")); var rawType = type.ToBytes(); + + byte[] rawContent; + string jsonContent; + + try + { + var schema = Schema.Create(type as MichelinePrim); + rawContent = schema.Optimize(value).ToBytes(); + jsonContent = schema.Humanize(value); + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to parse ticket content"); + rawContent = value.ToBytes(); + jsonContent = null; + } + res.Add(new TicketUpdates { Ticket = new TicketIdentity @@ -220,24 +249,16 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resu Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, RawContent = rawContent, - JsonContent = schema.Humanize(value), + JsonContent = jsonContent, TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new TicketUpdate - { - Account = x.RequiredString("account"), - Amount = BigInteger.Parse(x.RequiredString("amount")) - }) + Updates = list }); } - catch (Exception ex) - { - Logger.LogError(ex, "Failed to process ticket updates"); - } } - return res; + return res.Count > 0 ? res : null; } } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs index 1ea36fc42..bfd4c6f6a 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/Operations/SmartRollupExecuteCommit.cs @@ -192,23 +192,52 @@ public virtual async Task Revert(Block block, SmartRollupExecuteOperation operat Cache.AppState.ReleaseManagerCounter(); Cache.AppState.ReleaseOperationId(); } - + protected virtual IEnumerable ParseTicketUpdates(JsonElement result) { if (!result.TryGetProperty("ticket_updates", out var ticketUpdates)) return null; var res = new List(); - foreach (var update in ticketUpdates.RequiredArray().EnumerateArray()) + foreach (var updates in ticketUpdates.RequiredArray().EnumerateArray()) { - try + var list = new List(); + foreach (var update in updates.RequiredArray("updates").EnumerateArray()) { - var ticketToken = update.Required("ticket_token"); - var value = Micheline.FromJson(ticketToken.Required("content")); + var amount = update.RequiredBigInteger("amount"); + if (amount != BigInteger.Zero) + { + list.Add(new TicketUpdate + { + Account = update.RequiredString("account"), + Amount = amount + }); + } + } + + if (list.Count > 0) + { + var ticketToken = updates.Required("ticket_token"); var type = Micheline.FromJson(ticketToken.Required("content_type")); - var schema = Schema.Create(type as MichelinePrim); ; - var rawContent = schema.Optimize(value).ToBytes(); + var value = Micheline.FromJson(ticketToken.Required("content")); var rawType = type.ToBytes(); + + byte[] rawContent; + string jsonContent; + + try + { + var schema = Schema.Create(type as MichelinePrim); + rawContent = schema.Optimize(value).ToBytes(); + jsonContent = schema.Humanize(value); + } + catch (Exception ex) + { + Logger.LogError(ex, "Failed to parse ticket content"); + rawContent = value.ToBytes(); + jsonContent = null; + } + res.Add(new TicketUpdates { Ticket = new TicketIdentity @@ -216,24 +245,16 @@ protected virtual IEnumerable ParseTicketUpdates(JsonElement resu Ticketer = ticketToken.RequiredString("ticketer"), RawType = rawType, RawContent = rawContent, - JsonContent = schema.Humanize(value), + JsonContent = jsonContent, TypeHash = Script.GetHash(rawType), ContentHash = Script.GetHash(rawContent) }, - Updates = update.RequiredArray("updates").EnumerateArray().Select(x => new TicketUpdate - { - Account = x.RequiredString("account"), - Amount = BigInteger.Parse(x.RequiredString("amount")) - }) + Updates = list }); } - catch (Exception ex) - { - Logger.LogError(ex, "Failed to process ticket updates"); - } } - return res; + return res.Count > 0 ? res : null; } } } From c438649ed5e5b3e3ae6c5014c2bb692c1fc0c684 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Thu, 31 Aug 2023 13:00:45 +0300 Subject: [PATCH 48/51] Minor refactoring --- .../20230823140932_Tickets.Designer.cs | 21 ++++++------ .../Migrations/20230823140932_Tickets.cs | 34 ++++++++++++------- .../Migrations/TzktContextModelSnapshot.cs | 21 ++++++------ Tzkt.Data/Models/Scripts/Ticket.cs | 12 +++++-- Tzkt.Data/Models/Scripts/TicketBalance.cs | 15 ++------ Tzkt.Data/Models/Scripts/TicketTransfer.cs | 22 ++++++------ .../Handlers/Proto16/Commits/TicketsCommit.cs | 14 ++++---- Tzkt.Sync/Services/Cache/TicketsCache.cs | 12 +++---- 8 files changed, 79 insertions(+), 72 deletions(-) diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs index 80d8a5a78..18b26e24e 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.Designer.cs @@ -3640,6 +3640,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("ContentHash"); + b.HasIndex("FirstLevel"); + b.HasIndex("FirstMinterId"); b.HasIndex("Id") @@ -3656,6 +3658,8 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("TypeHash"); + b.HasIndex("TicketerId", "TypeHash", "ContentHash"); + b.ToTable("Tickets"); }); @@ -3691,19 +3695,18 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); + b.HasIndex("AccountId"); + + b.HasIndex("FirstLevel"); b.HasIndex("Id") .IsUnique(); b.HasIndex("LastLevel"); - b.HasIndex("TicketId") - .HasFilter("\"Balance\" != '0'"); + b.HasIndex("TicketId"); - b.HasIndex("TicketerId") - .HasFilter("\"Balance\" != '0'"); + b.HasIndex("TicketerId"); b.HasIndex("AccountId", "TicketId") .IsUnique(); @@ -3751,8 +3754,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); + b.HasIndex("FromId"); b.HasIndex("Id") .IsUnique(); @@ -3766,8 +3768,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("TicketerId"); - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); + b.HasIndex("ToId"); b.HasIndex("TransactionId") .HasFilter("\"TransactionId\" is not null"); diff --git a/Tzkt.Data/Migrations/20230823140932_Tickets.cs b/Tzkt.Data/Migrations/20230823140932_Tickets.cs index 5d676e0af..399126d52 100644 --- a/Tzkt.Data/Migrations/20230823140932_Tickets.cs +++ b/Tzkt.Data/Migrations/20230823140932_Tickets.cs @@ -124,8 +124,8 @@ protected override void Up(MigrationBuilder migrationBuilder) TotalMinted = table.Column(type: "text", nullable: false), TotalBurned = table.Column(type: "text", nullable: false), TotalSupply = table.Column(type: "text", nullable: false), - ContentHash = table.Column(type: "integer", nullable: false), TypeHash = table.Column(type: "integer", nullable: false), + ContentHash = table.Column(type: "integer", nullable: false), RawType = table.Column(type: "bytea", nullable: true), RawContent = table.Column(type: "bytea", nullable: true), JsonContent = table.Column(type: "jsonb", nullable: true) @@ -147,8 +147,8 @@ protected override void Up(MigrationBuilder migrationBuilder) Amount = table.Column(type: "text", nullable: false), FromId = table.Column(type: "integer", nullable: true), ToId = table.Column(type: "integer", nullable: true), - TransferTicketId = table.Column(type: "bigint", nullable: true), TransactionId = table.Column(type: "bigint", nullable: true), + TransferTicketId = table.Column(type: "bigint", nullable: true), SmartRollupExecuteId = table.Column(type: "bigint", nullable: true) }, constraints: table => @@ -166,8 +166,7 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateIndex( name: "IX_TicketBalances_AccountId", table: "TicketBalances", - column: "AccountId", - filter: "\"Balance\" != '0'"); + column: "AccountId"); migrationBuilder.CreateIndex( name: "IX_TicketBalances_AccountId_TicketerId", @@ -180,6 +179,11 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: new[] { "AccountId", "TicketId" }, unique: true); + migrationBuilder.CreateIndex( + name: "IX_TicketBalances_FirstLevel", + table: "TicketBalances", + column: "FirstLevel"); + migrationBuilder.CreateIndex( name: "IX_TicketBalances_Id", table: "TicketBalances", @@ -194,20 +198,23 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateIndex( name: "IX_TicketBalances_TicketerId", table: "TicketBalances", - column: "TicketerId", - filter: "\"Balance\" != '0'"); + column: "TicketerId"); migrationBuilder.CreateIndex( name: "IX_TicketBalances_TicketId", table: "TicketBalances", - column: "TicketId", - filter: "\"Balance\" != '0'"); + column: "TicketId"); migrationBuilder.CreateIndex( name: "IX_Tickets_ContentHash", table: "Tickets", column: "ContentHash"); + migrationBuilder.CreateIndex( + name: "IX_Tickets_FirstLevel", + table: "Tickets", + column: "FirstLevel"); + migrationBuilder.CreateIndex( name: "IX_Tickets_FirstMinterId", table: "Tickets", @@ -236,6 +243,11 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "Tickets", column: "TicketerId"); + migrationBuilder.CreateIndex( + name: "IX_Tickets_TicketerId_TypeHash_ContentHash", + table: "Tickets", + columns: new[] { "TicketerId", "TypeHash", "ContentHash" }); + migrationBuilder.CreateIndex( name: "IX_Tickets_TypeHash", table: "Tickets", @@ -244,8 +256,7 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateIndex( name: "IX_TicketTransfers_FromId", table: "TicketTransfers", - column: "FromId", - filter: "\"FromId\" is not null"); + column: "FromId"); migrationBuilder.CreateIndex( name: "IX_TicketTransfers_Id", @@ -277,8 +288,7 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateIndex( name: "IX_TicketTransfers_ToId", table: "TicketTransfers", - column: "ToId", - filter: "\"ToId\" is not null"); + column: "ToId"); migrationBuilder.CreateIndex( name: "IX_TicketTransfers_TransactionId", diff --git a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs index 3a6c12e0e..e59b72946 100644 --- a/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs +++ b/Tzkt.Data/Migrations/TzktContextModelSnapshot.cs @@ -3637,6 +3637,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ContentHash"); + b.HasIndex("FirstLevel"); + b.HasIndex("FirstMinterId"); b.HasIndex("Id") @@ -3653,6 +3655,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TypeHash"); + b.HasIndex("TicketerId", "TypeHash", "ContentHash"); + b.ToTable("Tickets"); }); @@ -3688,19 +3692,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("AccountId") - .HasFilter("\"Balance\" != '0'"); + b.HasIndex("AccountId"); + + b.HasIndex("FirstLevel"); b.HasIndex("Id") .IsUnique(); b.HasIndex("LastLevel"); - b.HasIndex("TicketId") - .HasFilter("\"Balance\" != '0'"); + b.HasIndex("TicketId"); - b.HasIndex("TicketerId") - .HasFilter("\"Balance\" != '0'"); + b.HasIndex("TicketerId"); b.HasIndex("AccountId", "TicketId") .IsUnique(); @@ -3748,8 +3751,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.HasIndex("FromId") - .HasFilter("\"FromId\" is not null"); + b.HasIndex("FromId"); b.HasIndex("Id") .IsUnique(); @@ -3763,8 +3765,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("TicketerId"); - b.HasIndex("ToId") - .HasFilter("\"ToId\" is not null"); + b.HasIndex("ToId"); b.HasIndex("TransactionId") .HasFilter("\"TransactionId\" is not null"); diff --git a/Tzkt.Data/Models/Scripts/Ticket.cs b/Tzkt.Data/Models/Scripts/Ticket.cs index 3433d79af..846ab3c0c 100644 --- a/Tzkt.Data/Models/Scripts/Ticket.cs +++ b/Tzkt.Data/Models/Scripts/Ticket.cs @@ -21,8 +21,8 @@ public class Ticket public BigInteger TotalBurned { get; set; } public BigInteger TotalSupply { get; set; } - public int ContentHash { get; set; } public int TypeHash { get; set; } + public int ContentHash { get; set; } public byte[] RawType { get; set; } public byte[] RawContent { get; set; } @@ -68,18 +68,24 @@ public static void BuildTicketModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.TicketerId); - + modelBuilder.Entity() .HasIndex(x => x.FirstMinterId); + modelBuilder.Entity() + .HasIndex(x => x.FirstLevel); + modelBuilder.Entity() .HasIndex(x => x.LastLevel); + modelBuilder.Entity() + .HasIndex(x => x.TypeHash); + modelBuilder.Entity() .HasIndex(x => x.ContentHash); modelBuilder.Entity() - .HasIndex(x => x.TypeHash); + .HasIndex(x => new { x.TicketerId, x.TypeHash, x.ContentHash }); modelBuilder.Entity() .HasIndex(x => x.JsonContent) diff --git a/Tzkt.Data/Models/Scripts/TicketBalance.cs b/Tzkt.Data/Models/Scripts/TicketBalance.cs index d92338dca..518edbf89 100644 --- a/Tzkt.Data/Models/Scripts/TicketBalance.cs +++ b/Tzkt.Data/Models/Scripts/TicketBalance.cs @@ -44,24 +44,12 @@ public static void BuildTicketBalanceModel(this ModelBuilder modelBuilder) modelBuilder.Entity() .HasIndex(x => x.TicketerId); - modelBuilder.Entity() - .HasIndex(x => x.TicketerId) - .HasFilter($@"""{nameof(TicketBalance.Balance)}"" != '0'"); - modelBuilder.Entity() .HasIndex(x => x.TicketId); - modelBuilder.Entity() - .HasIndex(x => x.TicketId) - .HasFilter($@"""{nameof(TicketBalance.Balance)}"" != '0'"); - modelBuilder.Entity() .HasIndex(x => x.AccountId); - modelBuilder.Entity() - .HasIndex(x => x.AccountId) - .HasFilter($@"""{nameof(TicketBalance.Balance)}"" != '0'"); - modelBuilder.Entity() .HasIndex(x => new { x.AccountId, x.TicketerId }); @@ -69,6 +57,9 @@ public static void BuildTicketBalanceModel(this ModelBuilder modelBuilder) .HasIndex(x => new { x.AccountId, x.TicketId }) .IsUnique(); + modelBuilder.Entity() + .HasIndex(x => x.FirstLevel); + modelBuilder.Entity() .HasIndex(x => x.LastLevel); #endregion diff --git a/Tzkt.Data/Models/Scripts/TicketTransfer.cs b/Tzkt.Data/Models/Scripts/TicketTransfer.cs index d177dde71..b37ff01ae 100644 --- a/Tzkt.Data/Models/Scripts/TicketTransfer.cs +++ b/Tzkt.Data/Models/Scripts/TicketTransfer.cs @@ -15,8 +15,8 @@ public class TicketTransfer public int? FromId { get; set; } public int? ToId { get; set; } - public long? TransferTicketId { get; set; } public long? TransactionId { get; set; } + public long? TransferTicketId { get; set; } public long? SmartRollupExecuteId { get; set; } } @@ -46,33 +46,31 @@ public static void BuildTicketTransferModel(this ModelBuilder modelBuilder) .IsUnique(); modelBuilder.Entity() - .HasIndex(x => x.TicketerId); + .HasIndex(x => x.Level); modelBuilder.Entity() - .HasIndex(x => x.TicketId); + .HasIndex(x => x.TicketerId); modelBuilder.Entity() - .HasIndex(x => x.Level); + .HasIndex(x => x.TicketId); modelBuilder.Entity() - .HasIndex(x => x.SmartRollupExecuteId) - .HasFilter($@"""{nameof(TicketTransfer.SmartRollupExecuteId)}"" is not null"); + .HasIndex(x => x.FromId); modelBuilder.Entity() - .HasIndex(x => x.TransferTicketId) - .HasFilter($@"""{nameof(TicketTransfer.TransferTicketId)}"" is not null"); + .HasIndex(x => x.ToId); modelBuilder.Entity() .HasIndex(x => x.TransactionId) .HasFilter($@"""{nameof(TicketTransfer.TransactionId)}"" is not null"); modelBuilder.Entity() - .HasIndex(x => x.FromId) - .HasFilter($@"""{nameof(TicketTransfer.FromId)}"" is not null"); + .HasIndex(x => x.TransferTicketId) + .HasFilter($@"""{nameof(TicketTransfer.TransferTicketId)}"" is not null"); modelBuilder.Entity() - .HasIndex(x => x.ToId) - .HasFilter($@"""{nameof(TicketTransfer.ToId)}"" is not null"); + .HasIndex(x => x.SmartRollupExecuteId) + .HasFilter($@"""{nameof(TicketTransfer.SmartRollupExecuteId)}"" is not null"); #endregion } } diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index 07c185fb3..cad18ed83 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -46,7 +46,7 @@ public virtual async Task Apply() foreach (var (ticket, _) in Updates.SelectMany(x => x.Value)) { if (Cache.Accounts.TryGetCached(ticket.Ticketer, out var ticketer)) - ticketsSet.Add((ticketer.Id, ticket.RawContent, ticket.ContentHash, ticket.RawType, ticket.TypeHash)); + ticketsSet.Add((ticketer.Id, ticket.RawType, ticket.TypeHash, ticket.RawContent, ticket.ContentHash)); } await Cache.Tickets.Preload(ticketsSet); @@ -55,7 +55,7 @@ public virtual async Task Apply() { if (Cache.Accounts.TryGetCached(ticket.Ticketer, out var ticketer)) { - if (Cache.Tickets.TryGetCached(ticketer.Id, ticket.RawContent, ticket.RawType, out var _ticket)) + if (Cache.Tickets.TryGetCached(ticketer.Id, ticket.RawType, ticket.RawContent, out var _ticket)) { foreach (var (_, upd) in updates) { @@ -157,9 +157,9 @@ Account GetOrCreateAccount(ManagerOperation op, string address) return account; } - Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketIdentity ticketToken) + Ticket GetOrCreateTicket(ManagerOperation op, Contract ticketer, TicketIdentity ticketToken) { - if (!Cache.Tickets.TryGetCached(contract.Id, ticketToken.RawContent, ticketToken.RawType, out var ticket)) + if (!Cache.Tickets.TryGetCached(ticketer.Id, ticketToken.RawType, ticketToken.RawContent, out var ticket)) { ticket = new Ticket { @@ -170,7 +170,7 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketIdentity SmartRollupExecuteOperation srExecute => Cache.AppState.NextSubId(srExecute), _ => throw new ArgumentOutOfRangeException(nameof(op)) }, - TicketerId = contract.Id, + TicketerId = ticketer.Id, FirstMinterId = op switch { TransactionOperation transaction => transaction.InitiatorId ?? transaction.SenderId, @@ -193,8 +193,8 @@ Ticket GetOrCreateTicket(ManagerOperation op, Contract contract, TicketIdentity Db.Tickets.Add(ticket); Cache.Tickets.Add(ticket); - Db.TryAttach(contract); - contract.TicketsCount++; + Db.TryAttach(ticketer); + ticketer.TicketsCount++; var state = Cache.AppState.Get(); state.TicketsCount++; diff --git a/Tzkt.Sync/Services/Cache/TicketsCache.cs b/Tzkt.Sync/Services/Cache/TicketsCache.cs index d71938759..fafc7691e 100644 --- a/Tzkt.Sync/Services/Cache/TicketsCache.cs +++ b/Tzkt.Sync/Services/Cache/TicketsCache.cs @@ -9,7 +9,7 @@ public class TicketsCache public const int MaxItems = 4 * 4096; //TODO: set limits in app settings static readonly Dictionary CachedById = new(MaxItems); - static readonly Dictionary<(int ContractId, HashableBytes RawContent, HashableBytes RawType), Ticket> CachedByKey = new(MaxItems); + static readonly Dictionary<(int TicketerId, HashableBytes RawType, HashableBytes RawContent), Ticket> CachedByKey = new(MaxItems); readonly TzktContext Db; @@ -41,13 +41,13 @@ public void Trim() public void Add(Ticket ticket) { CachedById[ticket.Id] = ticket; - CachedByKey[(ticket.TicketerId, ticket.RawContent, ticket.RawType)] = ticket; + CachedByKey[(ticket.TicketerId, ticket.RawType, ticket.RawContent)] = ticket; } public void Remove(Ticket ticket) { CachedById.Remove(ticket.Id); - CachedByKey.Remove((ticket.TicketerId, ticket.RawContent, ticket.RawType)); + CachedByKey.Remove((ticket.TicketerId, ticket.RawType, ticket.RawContent)); } public Ticket GetCached(long id) @@ -57,9 +57,9 @@ public Ticket GetCached(long id) return token; } - public bool TryGetCached(int contractId, byte[] rawContent, byte[] rawType, out Ticket token) + public bool TryGetCached(int ticketerId, byte[] rawType, byte[] rawContent, out Ticket token) { - return CachedByKey.TryGetValue((contractId, rawContent, rawType), out token); + return CachedByKey.TryGetValue((ticketerId, rawType, rawContent), out token); } public async Task Preload(IEnumerable ids) @@ -87,7 +87,7 @@ public async Task Preload(IEnumerable<(int, byte[], int, byte[], int)> keys) var items = await Db.Tickets .FromSqlRaw($@" SELECT * FROM ""{nameof(TzktContext.Tickets)}"" - WHERE (""{nameof(Ticket.TicketerId)}"", ""{nameof(Ticket.ContentHash)}"", ""{nameof(Ticket.TypeHash)}"") IN ({corteges})") + WHERE (""{nameof(Ticket.TicketerId)}"", ""{nameof(Ticket.TypeHash)}"", ""{nameof(Ticket.ContentHash)}"") IN ({corteges})") .ToListAsync(); foreach (var item in items) From bced25da3df6fede4a70132197f941cfc2472928 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Thu, 31 Aug 2023 17:15:29 +0300 Subject: [PATCH 49/51] API refactoring --- Tzkt.Api/Controllers/TicketsController.cs | 158 ++--- Tzkt.Api/Models/Accounts/Contract.cs | 18 +- Tzkt.Api/Models/Accounts/Delegate.cs | 4 +- Tzkt.Api/Models/Accounts/Ghost.cs | 6 +- Tzkt.Api/Models/Accounts/Rollup.cs | 4 +- Tzkt.Api/Models/Accounts/SmartRollup.cs | 4 +- Tzkt.Api/Models/Accounts/User.cs | 4 +- .../Models/Operations/MigrationOperation.cs | 5 - .../Operations/SmartRollupExecuteOperation.cs | 5 + Tzkt.Api/Models/Tickets/Ticket.cs | 23 +- Tzkt.Api/Models/Tickets/TicketBalance.cs | 14 +- Tzkt.Api/Models/Tickets/TicketBalanceShort.cs | 14 +- Tzkt.Api/Models/Tickets/TicketInfo.cs | 21 +- Tzkt.Api/Models/Tickets/TicketInfoShort.cs | 48 ++ Tzkt.Api/Models/Tickets/TicketTransfer.cs | 4 +- Tzkt.Api/Parameters/TicketBalanceFilter.cs | 32 +- .../Parameters/TicketBalanceShortFilter.cs | 22 +- Tzkt.Api/Parameters/TicketFilter.cs | 61 +- Tzkt.Api/Parameters/TicketInfoFilter.cs | 21 +- Tzkt.Api/Parameters/TicketInfoShortFilter.cs | 29 + Tzkt.Api/Parameters/TicketTransferFilter.cs | 16 +- .../AccountRepository.Contracts.cs | 14 +- Tzkt.Api/Repositories/AccountRepository.cs | 24 +- .../OperationRepository.Migrations.cs | 12 - ...nRepository.SmartRollupExecuteOperation.cs | 8 +- Tzkt.Api/Repositories/TicketsRepository.cs | 540 +++++++++++------- .../Processors/TicketBalancesProcessor.cs | 32 +- .../Processors/TicketTransfersProcessor.cs | 32 +- 28 files changed, 677 insertions(+), 498 deletions(-) create mode 100644 Tzkt.Api/Models/Tickets/TicketInfoShort.cs create mode 100644 Tzkt.Api/Parameters/TicketInfoShortFilter.cs diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index 3bf4a1083..b6d6b94b9 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -1,7 +1,4 @@ -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Tzkt.Api.Models; using Tzkt.Api.Repositories; using Tzkt.Api.Services; @@ -36,28 +33,17 @@ public TicketsController(TicketsRepository tickets, StateCache state, ResponseCa [HttpGet("count")] public async Task> GetTicketsCount([FromQuery] TicketFilter filter) { - if (filter.ticketer != null || - filter.firstTime != null || - filter.firstMinter != null || - filter.firstLevel != null || - filter.lastTime != null || - filter.lastLevel != null || - filter.contentHash != null || - filter.typeHash != null || - filter.content != null || - filter.id != null ) - { - var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); + if (filter.Empty) + return Ok(State.Current.TicketsCount); - if (ResponseCache.TryGet(query, out var cached)) - return this.Bytes(cached); + var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); - var res = await Tickets.GetTicketsCount(filter); - cached = ResponseCache.Set(query, res); + if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); - } - return Ok(State.Current.TicketsCount); + var res = await Tickets.GetTicketsCount(filter); + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); } /// @@ -74,11 +60,10 @@ public async Task> GetTicketsCount([FromQuery] TicketFilter fi public async Task>> GetTickets( [FromQuery] TicketFilter filter, [FromQuery] Pagination pagination, - [FromQuery] Selection selection, - MichelineFormat micheline = MichelineFormat.Json) + [FromQuery] Selection selection) { var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("filter", filter), ("pagination", pagination), ("selection", selection), ("micheline", micheline)); + ("filter", filter), ("pagination", pagination), ("selection", selection)); if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); @@ -86,14 +71,14 @@ public async Task>> GetTickets( object res; if (selection.select == null) { - res = await Tickets.GetTickets(filter, pagination, micheline); + res = await Tickets.GetTickets(filter, pagination); } else { res = new SelectionResponse { Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), - Rows = await Tickets.GetTickets(filter, pagination, micheline, selection.select.Fields ?? selection.select.Values) + Rows = await Tickets.GetTickets(filter, pagination, selection.select.Fields ?? selection.select.Values) }; } cached = ResponseCache.Set(query, res); @@ -113,34 +98,22 @@ public async Task>> GetTickets( [HttpGet("balances/count")] public async Task> GetTicketBalancesCount([FromQuery] TicketBalanceFilter filter) { - if (filter.account != null || - filter.balance != null || - filter.firstTime != null || - filter.firstLevel != null || - filter.lastTime != null || - filter.lastLevel != null || - filter.id != null || - filter.ticket.id != null || - filter.ticket.ticketer != null || - filter.ticket.contentHash != null || - filter.ticket.typeHash != null) - { - #region optimizations - if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) - return Ok(0); - #endregion + if (filter.Empty) + return Ok(State.Current.TicketBalancesCount); + + #region optimizations + if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) + return Ok(0); + #endregion - var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); + var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); - if (ResponseCache.TryGet(query, out var cached)) - return this.Bytes(cached); - - var res = await Tickets.GetTicketBalancesCount(filter); - cached = ResponseCache.Set(query, res); + if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); - } - - return Ok(State.Current.TicketBalancesCount); + + var res = await Tickets.GetTicketBalancesCount(filter); + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); } /// @@ -157,8 +130,7 @@ public async Task> GetTicketBalancesCount([FromQuery] TicketBa public async Task>> GetTicketBalances( [FromQuery] TicketBalanceFilter filter, [FromQuery] Pagination pagination, - [FromQuery] Selection selection, - MichelineFormat micheline = MichelineFormat.Json) + [FromQuery] Selection selection) { #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) @@ -166,7 +138,7 @@ public async Task>> GetTicketBalances( #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("filter", filter), ("pagination", pagination), ("selection", selection), ("micheline", micheline)); + ("filter", filter), ("pagination", pagination), ("selection", selection)); if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); @@ -174,14 +146,14 @@ public async Task>> GetTicketBalances( object res; if (selection.select == null) { - res = await Tickets.GetTicketBalances(filter, pagination, micheline); + res = await Tickets.GetTicketBalances(filter, pagination); } else { res = new SelectionResponse { Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), - Rows = await Tickets.GetTicketBalances(filter, pagination, micheline, selection.select.Fields ?? selection.select.Values) + Rows = await Tickets.GetTicketBalances(filter, pagination, selection.select.Fields ?? selection.select.Values) }; } cached = ResponseCache.Set(query, res); @@ -201,43 +173,28 @@ public async Task>> GetTicketBalances( [HttpGet("transfers/count")] public async Task> GetTicketTransfersCount([FromQuery] TicketTransferFilter filter) { - if (filter.level != null || - filter.timestamp != null || - filter.from != null || - filter.to != null || - filter.anyof != null || - filter.amount != null || - filter.id != null || - filter.transactionId != null || - filter.transferTicketId != null || - filter.smartRollupExecuteId != null || - filter.ticket.ticketer != null || - filter.ticket.contentHash != null || - filter.ticket.typeHash != null || - filter.ticket.id != null) - { - #region optimizations - if (filter.from != null && (filter.from.Eq == -1 || filter.from.In?.Count == 0 && !filter.from.InHasNull)) - return Ok(0); + if (filter.Empty) + return Ok(State.Current.TicketTransfersCount); - if (filter.to != null && (filter.to.Eq == -1 || filter.to.In?.Count == 0 && !filter.to.InHasNull)) - return Ok(0); + #region optimizations + if (filter.from != null && (filter.from.Eq == -1 || filter.from.In?.Count == 0 && !filter.from.InHasNull)) + return Ok(0); - if (filter.anyof != null && (filter.anyof.Eq == -1 || filter.anyof.In?.Count == 0 && !filter.anyof.InHasNull)) - return Ok(0); - #endregion + if (filter.to != null && (filter.to.Eq == -1 || filter.to.In?.Count == 0 && !filter.to.InHasNull)) + return Ok(0); - var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); + if (filter.anyof != null && (filter.anyof.Eq == -1 || filter.anyof.In?.Count == 0 && !filter.anyof.InHasNull)) + return Ok(0); + #endregion - if (ResponseCache.TryGet(query, out var cached)) - return this.Bytes(cached); + var query = ResponseCacheService.BuildKey(Request.Path.Value, ("filter", filter)); - var res = await Tickets.GetTicketTransfersCount(filter); - cached = ResponseCache.Set(query, res); + if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); - } - return Ok(State.Current.TicketTransfersCount); + var res = await Tickets.GetTicketTransfersCount(filter); + cached = ResponseCache.Set(query, res); + return this.Bytes(cached); } /// @@ -254,8 +211,7 @@ public async Task> GetTicketTransfersCount([FromQuery] TicketT public async Task>> GetTicketTransfers( [FromQuery] TicketTransferFilter filter, [FromQuery] Pagination pagination, - [FromQuery] Selection selection, - MichelineFormat micheline = MichelineFormat.Json) + [FromQuery] Selection selection) { #region optimizations if (filter.from != null && (filter.from.Eq == -1 || filter.from.In?.Count == 0 && !filter.from.InHasNull)) @@ -269,7 +225,7 @@ public async Task>> GetTicketTransfers( #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("filter", filter), ("pagination", pagination), ("selection", selection), ("micheline", micheline)); + ("filter", filter), ("pagination", pagination), ("selection", selection)); if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); @@ -277,14 +233,14 @@ public async Task>> GetTicketTransfers( object res; if (selection.select == null) { - res = await Tickets.GetTicketTransfers(filter, pagination, micheline); + res = await Tickets.GetTicketTransfers(filter, pagination); } else { res = new SelectionResponse { Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), - Rows = await Tickets.GetTicketTransfers(filter, pagination, micheline, selection.select.Fields ?? selection.select.Values) + Rows = await Tickets.GetTicketTransfers(filter, pagination, selection.select.Fields ?? selection.select.Values) }; } cached = ResponseCache.Set(query, res); @@ -299,7 +255,7 @@ public async Task>> GetTicketTransfers( /// /// Returns a list of ticket balances at the end of the specified block. /// Note, this endpoint is quite heavy, therefore at least one of the filters - /// (`account`, `ticket.id`, `ticket.ticketer` with `ticket.contentHash` and `ticket.typeHash`) must be specified. + /// (`account`, `ticket.id`, `ticket.ticketer`) must be specified. /// /// Level of the block at the end of which historical balances must be calculated /// Filter @@ -310,18 +266,16 @@ public async Task>> GetTicketTransfers( public async Task>> GetTicketBalances(int level, [FromQuery] TicketBalanceShortFilter filter, [FromQuery] Pagination pagination, - [FromQuery] Selection selection, - MichelineFormat micheline = MichelineFormat.Json) + [FromQuery] Selection selection) { if (filter.account?.Eq == null && filter.account?.In == null && filter.ticket.id?.Eq == null && filter.ticket.id?.In == null && - (filter.ticket.ticketer?.Eq == null && filter.ticket.ticketer?.In == null || - filter.ticket.contentHash?.Eq == null && filter.ticket.contentHash?.In == null || - filter.ticket.typeHash?.Eq == null && filter.ticket.typeHash?.In == null)) - return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.ticketer` with `ticket.contentHash` and `ticket.typeHash`) must be specified"); + filter.ticket.ticketer?.Eq == null && + filter.ticket.ticketer?.In == null) + return new BadRequest("query", "At least one of the filters (`account`, `ticket.id`, `ticket.ticketer`) must be specified"); #region optimizations if (filter.account != null && (filter.account.Eq == -1 || filter.account.In?.Count == 0 && !filter.account.InHasNull)) @@ -329,7 +283,7 @@ public async Task>> GetTicketBalanc #endregion var query = ResponseCacheService.BuildKey(Request.Path.Value, - ("filter", filter), ("pagination", pagination), ("selection", selection), ("micheline", micheline)); + ("filter", filter), ("pagination", pagination), ("selection", selection)); if (ResponseCache.TryGet(query, out var cached)) return this.Bytes(cached); @@ -337,14 +291,14 @@ public async Task>> GetTicketBalanc object res; if (selection.select == null) { - res = await Tickets.GetHistoricalTicketBalances(level, filter, pagination, micheline); + res = await Tickets.GetHistoricalTicketBalances(level, filter, pagination); } else { res = new SelectionResponse { Cols = selection.select.Fields?.Select(x => x.Alias).ToArray(), - Rows = await Tickets.GetHistoricalTicketBalances(level, filter, pagination, micheline, selection.select.Fields ?? selection.select.Values) + Rows = await Tickets.GetHistoricalTicketBalances(level, filter, pagination, selection.select.Fields ?? selection.select.Values) }; } cached = ResponseCache.Set(query, res); diff --git a/Tzkt.Api/Models/Accounts/Contract.cs b/Tzkt.Api/Models/Accounts/Contract.cs index df93c05bc..9f11fc27f 100644 --- a/Tzkt.Api/Models/Accounts/Contract.cs +++ b/Tzkt.Api/Models/Accounts/Contract.cs @@ -76,14 +76,14 @@ public class Contract : Account public int NumContracts { get; set; } /// - /// Number of account tokens with non-zero balances. + /// Number of tokens minted in the contract. /// - public int ActiveTokensCount { get; set; } + public int TokensCount { get; set; } /// - /// Number of tokens minted in the contract. + /// Number of account tokens with non-zero balances. /// - public int TokensCount { get; set; } + public int ActiveTokensCount { get; set; } /// /// Number of tokens the account ever had. @@ -96,17 +96,17 @@ public class Contract : Account public int TokenTransfersCount { get; set; } /// - /// Number of account tickets with non-zero balances. + /// Number of tickets minted in the contract. /// - public int ActiveTicketsCount { get; set; } + public int TicketsCount { get; set; } /// - /// Number of tickets minted in the contract. + /// Number of tickets the account owns. /// - public int TicketsCount { get; set; } + public int ActiveTicketsCount { get; set; } /// - /// Number of tickets the account ever had. + /// Number of tickets the account ever owned. /// public int TicketBalancesCount { get; set; } diff --git a/Tzkt.Api/Models/Accounts/Delegate.cs b/Tzkt.Api/Models/Accounts/Delegate.cs index 183a45683..5aefb6d8d 100644 --- a/Tzkt.Api/Models/Accounts/Delegate.cs +++ b/Tzkt.Api/Models/Accounts/Delegate.cs @@ -131,12 +131,12 @@ public class Delegate : Account public int TokenTransfersCount { get; set; } /// - /// Number of account tickets with non-zero balances. + /// Number of tickets the account owns. /// public int ActiveTicketsCount { get; set; } /// - /// Number of tickets the account ever had. + /// Number of tickets the account ever owned. /// public int TicketBalancesCount { get; set; } diff --git a/Tzkt.Api/Models/Accounts/Ghost.cs b/Tzkt.Api/Models/Accounts/Ghost.cs index 4b78c9647..5241758ee 100644 --- a/Tzkt.Api/Models/Accounts/Ghost.cs +++ b/Tzkt.Api/Models/Accounts/Ghost.cs @@ -41,12 +41,12 @@ public class Ghost : Account public int TokenTransfersCount { get; set; } /// - /// Number of account tickets with non-zero balances. + /// Number of tickets the account owns. /// public int ActiveTicketsCount { get; set; } - + /// - /// Number of tickets the account ever had. + /// Number of tickets the account ever owned. /// public int TicketBalancesCount { get; set; } diff --git a/Tzkt.Api/Models/Accounts/Rollup.cs b/Tzkt.Api/Models/Accounts/Rollup.cs index 44ec7a50e..a4ce343c8 100644 --- a/Tzkt.Api/Models/Accounts/Rollup.cs +++ b/Tzkt.Api/Models/Accounts/Rollup.cs @@ -51,12 +51,12 @@ public class Rollup : Account public int TokenTransfersCount { get; set; } /// - /// Number of account tickets with non-zero balances. + /// Number of tickets the account owns. /// public int ActiveTicketsCount { get; set; } /// - /// Number of tickets the account ever had. + /// Number of tickets the account ever owned. /// public int TicketBalancesCount { get; set; } diff --git a/Tzkt.Api/Models/Accounts/SmartRollup.cs b/Tzkt.Api/Models/Accounts/SmartRollup.cs index e3b9d4122..1ace94ef8 100644 --- a/Tzkt.Api/Models/Accounts/SmartRollup.cs +++ b/Tzkt.Api/Models/Accounts/SmartRollup.cs @@ -105,12 +105,12 @@ public class SmartRollup : Account public int TokenTransfersCount { get; set; } /// - /// Number of account tickets with non-zero balances. + /// Number of tickets the account owns. /// public int ActiveTicketsCount { get; set; } /// - /// Number of tickets the account ever had. + /// Number of tickets the account ever owned. /// public int TicketBalancesCount { get; set; } diff --git a/Tzkt.Api/Models/Accounts/User.cs b/Tzkt.Api/Models/Accounts/User.cs index 56565693f..14c6ebf74 100644 --- a/Tzkt.Api/Models/Accounts/User.cs +++ b/Tzkt.Api/Models/Accounts/User.cs @@ -99,12 +99,12 @@ public class User : Account public int TokenTransfersCount { get; set; } /// - /// Number of account tickets with non-zero balances. + /// Number of tickets the account owns. /// public int ActiveTicketsCount { get; set; } /// - /// Number of tickets the account ever had. + /// Number of tickets the account ever owned. /// public int TicketBalancesCount { get; set; } diff --git a/Tzkt.Api/Models/Operations/MigrationOperation.cs b/Tzkt.Api/Models/Operations/MigrationOperation.cs index a0bc63b85..5cd2d6206 100644 --- a/Tzkt.Api/Models/Operations/MigrationOperation.cs +++ b/Tzkt.Api/Models/Operations/MigrationOperation.cs @@ -71,11 +71,6 @@ public class MigrationOperation : Operation /// public int? TokenTransfersCount { get; set; } - /// - /// Number of ticket transfers produced by the operation, or `null` if there are no transfers - /// - public int? TicketTransfersCount { get; set; } - #region injecting /// /// Injected historical quote at the time of operation diff --git a/Tzkt.Api/Models/Operations/SmartRollupExecuteOperation.cs b/Tzkt.Api/Models/Operations/SmartRollupExecuteOperation.cs index 53388b87e..0b995288e 100644 --- a/Tzkt.Api/Models/Operations/SmartRollupExecuteOperation.cs +++ b/Tzkt.Api/Models/Operations/SmartRollupExecuteOperation.cs @@ -91,6 +91,11 @@ public class SmartRollupExecuteOperation : Operation /// public List Errors { get; set; } + /// + /// Number of ticket transfers produced by the operation, or `null` if there are no transfers + /// + public int? TicketTransfersCount { get; set; } + #region injecting /// /// Injected historical quote at the time of operation diff --git a/Tzkt.Api/Models/Tickets/Ticket.cs b/Tzkt.Api/Models/Tickets/Ticket.cs index efb054a85..1126dcd30 100644 --- a/Tzkt.Api/Models/Tickets/Ticket.cs +++ b/Tzkt.Api/Models/Tickets/Ticket.cs @@ -1,4 +1,5 @@ using Netezos.Encoding; +using NJsonSchema.Annotations; namespace Tzkt.Api.Models { @@ -11,29 +12,35 @@ public class Ticket public long Id { get; set; } /// - /// Contract, created the ticket. + /// Contract, issued the ticket. /// - public Alias Ticketer { get; set; } + public Alias Ticketer { get; set; } /// - /// Micheline type of the content + /// Ticket content type in Micheline format. + /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// - public IMicheline Type { get; set; } + public IMicheline RawType { get; set; } /// - /// Ticket content + /// Ticket content in Micheline format. + /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// - public object Content { get; set; } + public IMicheline RawContent { get; set; } + + /// + /// Ticket content in JSON format. + /// + [JsonSchemaType(typeof(object), IsNullable = true)] + public RawJson Content { get; set; } /// /// 32-bit hash of the ticket content type. - /// This field can be used for searching similar tickets (which have the same type). /// public int TypeHash { get; set; } /// /// 32-bit hash of the ticket content. - /// This field can be used for searching same tickets (which have the same content). /// public int ContentHash { get; set; } diff --git a/Tzkt.Api/Models/Tickets/TicketBalance.cs b/Tzkt.Api/Models/Tickets/TicketBalance.cs index 3feabd519..7fa4850b8 100644 --- a/Tzkt.Api/Models/Tickets/TicketBalance.cs +++ b/Tzkt.Api/Models/Tickets/TicketBalance.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class TicketBalance { @@ -11,19 +9,19 @@ public class TicketBalance public long Id { get; set; } /// - /// Owner account. + /// Ticket info. /// Click on the field to expand more details. /// - public Alias Account { get; set; } + public TicketInfo Ticket { get; set; } /// - /// Ticket info. + /// Owner account. /// Click on the field to expand more details. /// - public TicketInfo Ticket { get; set; } + public Alias Account { get; set; } /// - /// Balance (raw value, not divided by `decimals`). + /// Balance. /// **[sortable]** /// public string Balance { get; set; } diff --git a/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs b/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs index 4ba9af85c..06039895e 100644 --- a/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs +++ b/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs @@ -3,16 +3,22 @@ public class TicketBalanceShort { /// - /// Owner account. - /// Click on the field to expand more details. + /// Internal TzKT id. + /// **[sortable]** /// - public Alias Account { get; set; } + public long Id { get; set; } /// /// Ticket info. /// Click on the field to expand more details. /// - public TicketInfo Ticket { get; set; } + public TicketInfoShort Ticket { get; set; } + + /// + /// Owner account. + /// Click on the field to expand more details. + /// + public Alias Account { get; set; } /// /// Balance (raw value, not divided by `decimals`). diff --git a/Tzkt.Api/Models/Tickets/TicketInfo.cs b/Tzkt.Api/Models/Tickets/TicketInfo.cs index 4277e14a1..c0d4cdc73 100644 --- a/Tzkt.Api/Models/Tickets/TicketInfo.cs +++ b/Tzkt.Api/Models/Tickets/TicketInfo.cs @@ -1,4 +1,5 @@ using Netezos.Encoding; +using NJsonSchema.Annotations; namespace Tzkt.Api.Models { @@ -13,16 +14,24 @@ public class TicketInfo /// Contract, created the ticket. /// public Alias Ticketer { get; set; } - + + /// + /// Ticket content type in Micheline format. + /// This field is omitted by default and must be explicitly selected via `?select=` parameter. + /// + public IMicheline RawType { get; set; } + /// - /// Micheline type of the content + /// Ticket content in Micheline format. + /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// - public IMicheline Type { get; set; } + public IMicheline RawContent { get; set; } /// - /// Ticket content + /// Ticket content in JSON format. /// - public object Content { get; set; } + [JsonSchemaType(typeof(object), IsNullable = true)] + public RawJson Content { get; set; } /// /// 32-bit hash of the ticket content type. @@ -37,7 +46,7 @@ public class TicketInfo public int ContentHash { get; set; } /// - /// Total number of existing tickets (raw value, not divided by `decimals`). In historical ticket balances this field is omitted. + /// Total amount of existing tickets. /// public string TotalSupply { get; set; } } diff --git a/Tzkt.Api/Models/Tickets/TicketInfoShort.cs b/Tzkt.Api/Models/Tickets/TicketInfoShort.cs new file mode 100644 index 000000000..ecc387b5c --- /dev/null +++ b/Tzkt.Api/Models/Tickets/TicketInfoShort.cs @@ -0,0 +1,48 @@ +using Netezos.Encoding; +using NJsonSchema.Annotations; + +namespace Tzkt.Api.Models +{ + public class TicketInfoShort + { + /// + /// Internal TzKT id. + /// + public long Id { get; set; } + + /// + /// Contract, created the ticket. + /// + public Alias Ticketer { get; set; } + + /// + /// Ticket content type in Micheline format. + /// This field is omitted by default and must be explicitly selected via `?select=` parameter. + /// + public IMicheline RawType { get; set; } + + /// + /// Ticket content in Micheline format. + /// This field is omitted by default and must be explicitly selected via `?select=` parameter. + /// + public IMicheline RawContent { get; set; } + + /// + /// Ticket content in JSON format. + /// + [JsonSchemaType(typeof(object), IsNullable = true)] + public RawJson Content { get; set; } + + /// + /// 32-bit hash of the ticket content type. + /// This field can be used for searching similar tickets (which have the same type). + /// + public int TypeHash { get; set; } + + /// + /// 32-bit hash of the ticket content. + /// This field can be used for searching same tickets (which have the same content). + /// + public int ContentHash { get; set; } + } +} diff --git a/Tzkt.Api/Models/Tickets/TicketTransfer.cs b/Tzkt.Api/Models/Tickets/TicketTransfer.cs index 5482873c7..559c6c50d 100644 --- a/Tzkt.Api/Models/Tickets/TicketTransfer.cs +++ b/Tzkt.Api/Models/Tickets/TicketTransfer.cs @@ -1,6 +1,4 @@ -using System; - -namespace Tzkt.Api.Models +namespace Tzkt.Api.Models { public class TicketTransfer { diff --git a/Tzkt.Api/Parameters/TicketBalanceFilter.cs b/Tzkt.Api/Parameters/TicketBalanceFilter.cs index 74f352f9a..38c3d0304 100644 --- a/Tzkt.Api/Parameters/TicketBalanceFilter.cs +++ b/Tzkt.Api/Parameters/TicketBalanceFilter.cs @@ -1,5 +1,4 @@ -using System.Text.Json.Serialization; -using Tzkt.Api.Services; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -12,16 +11,16 @@ public class TicketBalanceFilter : INormalizable public Int64Parameter id { get; set; } /// - /// Filter by account address. + /// Filter by ticket. /// Click on the parameter to expand more details. /// - public AccountParameter account { get; set; } + public TicketInfoFilter ticket { get; set; } /// - /// Filter by ticket. + /// Filter by account address. /// Click on the parameter to expand more details. /// - public TicketInfoFilter ticket { get; set; } + public AccountParameter account { get; set; } /// /// Filter by balance. @@ -29,6 +28,12 @@ public class TicketBalanceFilter : INormalizable /// public NatParameter balance { get; set; } + /// + /// Filter by number of transfers. + /// Click on the parameter to expand more details. + /// + public Int32Parameter transfersCount { get; set; } + /// /// Filter by level of the block where the balance was first changed. /// Click on the parameter to expand more details. @@ -53,11 +58,22 @@ public class TicketBalanceFilter : INormalizable /// public TimestampParameter lastTime { get; set; } + public bool Empty => + id == null && + (ticket == null || ticket.Empty) && + account == null && + balance == null && + transfersCount == null && + firstLevel == null && + firstTime == null && + lastLevel == null && + lastTime == null; + public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("account", account), ("ticket", ticket), ("balance", balance), ("firstLevel", firstLevel), - ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime)); + ("id", id), ("ticket", ticket), ("account", account), ("balance", balance), ("transfersCount", transfersCount), + ("firstLevel", firstLevel), ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime)); } } } diff --git a/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs b/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs index 024e3a562..269a6fd16 100644 --- a/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs +++ b/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs @@ -5,16 +5,22 @@ namespace Tzkt.Api public class TicketBalanceShortFilter : INormalizable { /// - /// Filter by account address. + /// Filter by internal TzKT id. /// Click on the parameter to expand more details. /// - public AccountParameter account { get; set; } + public Int64Parameter id { get; set; } /// /// Filter by ticket. /// Click on the parameter to expand more details. /// - public TicketInfoFilter ticket { get; set; } + public TicketInfoShortFilter ticket { get; set; } + + /// + /// Filter by account address. + /// Click on the parameter to expand more details. + /// + public AccountParameter account { get; set; } /// /// Filter by balance. @@ -22,10 +28,16 @@ public class TicketBalanceShortFilter : INormalizable /// public NatParameter balance { get; set; } + public bool Empty => + id == null && + (ticket == null || ticket.Empty) && + account == null && + balance == null; + public string Normalize(string name) { - return ResponseCacheService.BuildKey("", - ("account", account), ("ticket", ticket), ("balance", balance)); + return ResponseCacheService.BuildKey("", + ("id", id), ("ticket", ticket), ("account", account), ("balance", balance)); } } } diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs index 55be2b28f..462caae0e 100644 --- a/Tzkt.Api/Parameters/TicketFilter.cs +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -1,12 +1,11 @@ -using System.Text.Json.Serialization; -using Tzkt.Api.Services; +using Tzkt.Api.Services; namespace Tzkt.Api { public class TicketFilter : INormalizable { /// - /// Filter by internal TzKT id. Note, this is not the same as `ticketId` nat value. + /// Filter by internal TzKT id. /// Click on the parameter to expand more details. /// public Int64Parameter id { get; set; } @@ -18,61 +17,73 @@ public class TicketFilter : INormalizable public AccountParameter ticketer { get; set; } /// - /// Filter by address of the first minter. + /// Filter by content. + /// Note, this parameter supports the following format: `content{.path?}{.mode?}=...`, + /// so you can specify a path to a particular field to filter by (for example, `?content.in=red,green`). /// Click on the parameter to expand more details. /// - public AccountParameter firstMinter { get; set; } + public JsonParameter content { get; set; } /// - /// Filter by level of the block where the ticket was first seen. + /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). /// Click on the parameter to expand more details. /// - public Int32Parameter firstLevel { get; set; } + public Int32Parameter typeHash { get; set; } /// - /// Filter by timestamp (ISO 8601) of the block where the ticket was first seen. + /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). /// Click on the parameter to expand more details. /// - public TimestampParameter firstTime { get; set; } + public Int32Parameter contentHash { get; set; } /// - /// Filter by level of the block where the ticket was last seen. + /// Filter by address of the first minter. /// Click on the parameter to expand more details. /// - public Int32Parameter lastLevel { get; set; } + public AccountParameter firstMinter { get; set; } /// - /// Filter by timestamp (ISO 8601) of the block where the ticket was last seen. + /// Filter by level of the block where the ticket was first seen. /// Click on the parameter to expand more details. /// - public TimestampParameter lastTime { get; set; } - + public Int32Parameter firstLevel { get; set; } + /// - /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). + /// Filter by timestamp (ISO 8601) of the block where the ticket was first seen. /// Click on the parameter to expand more details. /// - public Int32Parameter contentHash { get; set; } + public TimestampParameter firstTime { get; set; } /// - /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). + /// Filter by level of the block where the ticket was last seen. /// Click on the parameter to expand more details. /// - public Int32Parameter typeHash { get; set; } + public Int32Parameter lastLevel { get; set; } /// - /// Filter by content. - /// Note, this parameter supports the following format: `content{.path?}{.mode?}=...`, - /// so you can specify a path to a particular field to filter by (for example, `?content.in=red,green`). + /// Filter by timestamp (ISO 8601) of the block where the ticket was last seen. /// Click on the parameter to expand more details. /// - public JsonParameter content { get; set; } + public TimestampParameter lastTime { get; set; } + + public bool Empty => + id == null && + ticketer == null && + content == null && + typeHash == null && + contentHash == null && + firstMinter == null && + firstLevel == null && + firstTime == null && + lastLevel == null && + lastTime == null; public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("ticketer", ticketer), ("firstMinter", firstMinter), ("firstLevel", firstLevel), - ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime), ("contentHash", contentHash), - ("typeHash", typeHash), ("content", content)); + ("id", id), ("ticketer", ticketer), ("content", content), ("typeHash", typeHash), ("contentHash", contentHash), + ("firstMinter", firstMinter), ("firstLevel", firstLevel), ("firstTime", firstTime), ("lastLevel", lastLevel), + ("lastTime", lastTime)); } } } diff --git a/Tzkt.Api/Parameters/TicketInfoFilter.cs b/Tzkt.Api/Parameters/TicketInfoFilter.cs index 454e24402..c25194412 100644 --- a/Tzkt.Api/Parameters/TicketInfoFilter.cs +++ b/Tzkt.Api/Parameters/TicketInfoFilter.cs @@ -1,5 +1,4 @@ -using Newtonsoft.Json; -using Tzkt.Api.Services; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -16,23 +15,29 @@ public class TicketInfoFilter : INormalizable /// Click on the parameter to expand more details. /// public AccountParameter ticketer { get; set; } - + /// - /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). + /// Filter by 32-bit hash of ticket content type. /// Click on the parameter to expand more details. /// - public Int32Parameter contentHash { get; set; } + public Int32Parameter typeHash { get; set; } /// - /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). + /// Filter by 32-bit hash of ticket content. /// Click on the parameter to expand more details. /// - public Int32Parameter typeHash { get; set; } + public Int32Parameter contentHash { get; set; } + + public bool Empty => + id == null && + ticketer == null && + typeHash == null && + contentHash == null; public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("ticketer", ticketer), ("contentHash", contentHash), ("typeHash", typeHash)); + ("id", id), ("ticketer", ticketer), ("typeHash", typeHash), ("contentHash", contentHash)); } } } diff --git a/Tzkt.Api/Parameters/TicketInfoShortFilter.cs b/Tzkt.Api/Parameters/TicketInfoShortFilter.cs new file mode 100644 index 000000000..ec2beee47 --- /dev/null +++ b/Tzkt.Api/Parameters/TicketInfoShortFilter.cs @@ -0,0 +1,29 @@ +using Tzkt.Api.Services; + +namespace Tzkt.Api +{ + public class TicketInfoShortFilter : INormalizable + { + /// + /// Filter by internal TzKT id. + /// Click on the parameter to expand more details. + /// + public Int64Parameter id { get; set; } + + /// + /// Filter by ticketer address. + /// Click on the parameter to expand more details. + /// + public AccountParameter ticketer { get; set; } + + public bool Empty => + id == null && + ticketer == null; + + public string Normalize(string name) + { + return ResponseCacheService.BuildKey("", + ("id", id), ("ticketer", ticketer)); + } + } +} diff --git a/Tzkt.Api/Parameters/TicketTransferFilter.cs b/Tzkt.Api/Parameters/TicketTransferFilter.cs index f7e9f2d48..a06bcc19b 100644 --- a/Tzkt.Api/Parameters/TicketTransferFilter.cs +++ b/Tzkt.Api/Parameters/TicketTransferFilter.cs @@ -1,5 +1,4 @@ -using System.Text.Json.Serialization; -using Tzkt.Api.Services; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -73,6 +72,19 @@ public class TicketTransferFilter : INormalizable /// public Int64NullParameter smartRollupExecuteId { get; set; } + public bool Empty => + id == null && + level == null && + timestamp == null && + (ticket == null || ticket.Empty) && + anyof == null && + from == null && + to == null && + amount == null && + transactionId == null && + transferTicketId == null && + smartRollupExecuteId == null; + public string Normalize(string name) { return ResponseCacheService.BuildKey("", diff --git a/Tzkt.Api/Repositories/AccountRepository.Contracts.cs b/Tzkt.Api/Repositories/AccountRepository.Contracts.cs index 57106ed6e..acf45d54d 100644 --- a/Tzkt.Api/Repositories/AccountRepository.Contracts.cs +++ b/Tzkt.Api/Repositories/AccountRepository.Contracts.cs @@ -45,8 +45,8 @@ async Task> QueryContractsAsync(bool includeStorage, Contra case "tokensCount": columns.Add(@"c.""TokensCount"""); break; case "tokenBalancesCount": columns.Add(@"c.""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"c.""TokenTransfersCount"""); break; - case "activeTicketsCount": columns.Add(@"c.""ActiveTicketsCount"""); break; case "ticketsCount": columns.Add(@"c.""TicketsCount"""); break; + case "activeTicketsCount": columns.Add(@"c.""ActiveTicketsCount"""); break; case "ticketBalancesCount": columns.Add(@"c.""TicketBalancesCount"""); break; case "ticketTransfersCount": columns.Add(@"c.""TicketTransfersCount"""); break; case "numDelegations": columns.Add(@"c.""DelegationsCount"""); break; @@ -166,8 +166,8 @@ public async Task GetContract(string address, bool legacy) ActiveTokensCount = contract.ActiveTokensCount, TokenBalancesCount = contract.TokenBalancesCount, TokenTransfersCount = contract.TokenTransfersCount, - ActiveTicketsCount = contract.ActiveTicketsCount, TicketsCount = contract.TicketsCount, + ActiveTicketsCount = contract.ActiveTicketsCount, TicketBalancesCount = contract.TicketBalancesCount, TicketTransfersCount = contract.TicketTransfersCount, NumDelegations = contract.DelegationsCount, @@ -259,10 +259,10 @@ public async Task> GetContracts(bool includeStorage, Contr ActiveTokensCount = row.ActiveTokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, + TicketsCount = row.TicketsCount, ActiveTicketsCount = row.ActiveTicketsCount, TicketBalancesCount = row.TicketBalancesCount, TicketTransfersCount = row.TicketTransfersCount, - TicketsCount = row.TicketsCount, NumDelegations = row.DelegationsCount, NumOriginations = row.OriginationsCount, NumReveals = row.RevealsCount, @@ -414,14 +414,14 @@ public async Task GetContracts(bool includeStorage, ContractFilter f foreach (var row in rows) result[j++][i] = row.TokenTransfersCount; break; - case "activeTicketsCount": - foreach (var row in rows) - result[j++][i] = row.ActiveTicketsCount; - break; case "ticketsCount": foreach (var row in rows) result[j++][i] = row.TicketsCount; break; + case "activeTicketsCount": + foreach (var row in rows) + result[j++][i] = row.ActiveTicketsCount; + break; case "ticketBalancesCount": foreach (var row in rows) result[j++][i] = row.TicketBalancesCount; diff --git a/Tzkt.Api/Repositories/AccountRepository.cs b/Tzkt.Api/Repositories/AccountRepository.cs index aa7f93b34..64b1327e5 100644 --- a/Tzkt.Api/Repositories/AccountRepository.cs +++ b/Tzkt.Api/Repositories/AccountRepository.cs @@ -242,8 +242,8 @@ public async Task Get(string address, bool legacy) TokensCount = contract.TokensCount, TokenBalancesCount = contract.TokenBalancesCount, TokenTransfersCount = contract.TokenTransfersCount, - ActiveTicketsCount = contract.ActiveTicketsCount, TicketsCount = contract.TicketsCount, + ActiveTicketsCount = contract.ActiveTicketsCount, TicketBalancesCount = contract.TicketBalancesCount, TicketTransfersCount = contract.TicketTransfersCount, NumDelegations = contract.DelegationsCount, @@ -612,8 +612,8 @@ public async Task> Get( TokensCount = row.TokensCount, TokenBalancesCount = row.TokenBalancesCount, TokenTransfersCount = row.TokenTransfersCount, - ActiveTicketsCount = row.ActiveTicketsCount, TicketsCount = row.TicketsCount, + ActiveTicketsCount = row.ActiveTicketsCount, TicketBalancesCount = row.TicketBalancesCount, TicketTransfersCount = row.TicketTransfersCount, NumDelegations = row.DelegationsCount, @@ -775,7 +775,6 @@ public async Task Get( case "tokenBalancesCount": columns.Add(@"""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"""TokenTransfersCount"""); break; case "activeTicketsCount": columns.Add(@"""ActiveTicketsCount"""); break; - case "ticketsCount": columns.Add(@"""TicketsCount"""); break; case "ticketBalancesCount": columns.Add(@"""TicketBalancesCount"""); break; case "ticketTransfersCount": columns.Add(@"""TicketTransfersCount"""); break; case "numDelegators": columns.Add(@"""DelegatorsCount"""); break; @@ -834,6 +833,7 @@ public async Task Get( case "manager": columns.Add(@"""ManagerId"""); break; case "tokensCount": columns.Add(@"""TokensCount"""); break; case "eventsCount": columns.Add(@"""EventsCount"""); break; + case "ticketsCount": columns.Add(@"""TicketsCount"""); break; case "pvmKind": columns.Add(@"""PvmKind"""); break; case "genesisCommitment": columns.Add(@"""GenesisCommitment"""); break; @@ -995,10 +995,6 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.ActiveTicketsCount; break; - case "ticketsCount": - foreach (var row in rows) - result[j++][i] = row.TicketsCount; - break; case "ticketBalancesCount": foreach (var row in rows) result[j++][i] = row.TicketBalancesCount; @@ -1246,6 +1242,10 @@ public async Task Get( foreach (var row in rows) result[j++][i] = row.EventsCount; break; + case "ticketsCount": + foreach (var row in rows) + result[j++][i] = row.TicketsCount; + break; case "pvmKind": foreach (var row in rows) result[j++][i] = PvmKinds.ToString((int)row.PvmKind); @@ -1341,7 +1341,6 @@ public async Task Get( case "tokenBalancesCount": columns.Add(@"""TokenBalancesCount"""); break; case "tokenTransfersCount": columns.Add(@"""TokenTransfersCount"""); break; case "activeTicketsCount": columns.Add(@"""ActiveTicketsCount"""); break; - case "ticketsCount": columns.Add(@"""TicketsCount"""); break; case "ticketBalancesCount": columns.Add(@"""TicketBalancesCount"""); break; case "ticketTransfersCount": columns.Add(@"""TicketTransfersCount"""); break; case "numDelegators": columns.Add(@"""DelegatorsCount"""); break; @@ -1400,6 +1399,7 @@ public async Task Get( case "manager": columns.Add(@"""ManagerId"""); break; case "tokensCount": columns.Add(@"""TokensCount"""); break; case "eventsCount": columns.Add(@"""EventsCount"""); break; + case "ticketsCount": columns.Add(@"""TicketsCount"""); break; case "pvmKind": columns.Add(@"""PvmKind"""); break; case "genesisCommitment": columns.Add(@"""GenesisCommitment"""); break; @@ -1557,10 +1557,6 @@ public async Task Get( foreach (var row in rows) result[j++] = row.ActiveTicketsCount; break; - case "ticketsCount": - foreach (var row in rows) - result[j++] = row.TicketsCount; - break; case "ticketBalancesCount": foreach (var row in rows) result[j++] = row.TicketBalancesCount; @@ -1808,6 +1804,10 @@ public async Task Get( foreach (var row in rows) result[j++] = row.EventsCount; break; + case "ticketsCount": + foreach (var row in rows) + result[j++] = row.TicketsCount; + break; case "pvmKind": foreach (var row in rows) result[j++] = PvmKinds.ToString((int)row.PvmKind); diff --git a/Tzkt.Api/Repositories/OperationRepository.Migrations.cs b/Tzkt.Api/Repositories/OperationRepository.Migrations.cs index e90599114..16e08482b 100644 --- a/Tzkt.Api/Repositories/OperationRepository.Migrations.cs +++ b/Tzkt.Api/Repositories/OperationRepository.Migrations.cs @@ -65,7 +65,6 @@ INNER JOIN ""Blocks"" as b Storage = row.StorageId == null ? null : storages?[row.StorageId], Diffs = row.BigMapUpdates == null ? null : diffs?[row.Id], TokenTransfersCount = row.TokenTransfers, - TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }).FirstOrDefault(); } @@ -130,7 +129,6 @@ public async Task> GetMigrations( Storage = row.StorageId == null ? null : storages?[row.StorageId], Diffs = row.BigMapUpdates == null ? null : diffs?[row.Id], TokenTransfersCount = row.TokenTransfers, - TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }); } @@ -172,7 +170,6 @@ public async Task GetMigrations( columns.Add(@"o.""BigMapUpdates"""); break; case "tokenTransfersCount": columns.Add(@"o.""TokenTransfers"""); break; - case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "quote": columns.Add(@"o.""Level"""); break; } } @@ -253,10 +250,6 @@ public async Task GetMigrations( foreach (var row in rows) result[j++][i] = row.TokenTransfers; break; - case "ticketTransfersCount": - foreach (var row in rows) - result[j++][i] = row.TicketTransfers; - break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); @@ -302,7 +295,6 @@ public async Task GetMigrations( columns.Add(@"o.""BigMapUpdates"""); break; case "tokenTransfersCount": columns.Add(@"o.""TokenTransfers"""); break; - case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "quote": columns.Add(@"o.""Level"""); break; } @@ -380,10 +372,6 @@ public async Task GetMigrations( foreach (var row in rows) result[j++] = row.TokenTransfers; break; - case "ticketTransfersCount": - foreach (var row in rows) - result[j++] = row.TicketTransfers; - break; case "quote": foreach (var row in rows) result[j++] = Quotes.Get(quote, row.Level); diff --git a/Tzkt.Api/Repositories/OperationRepository.SmartRollupExecuteOperation.cs b/Tzkt.Api/Repositories/OperationRepository.SmartRollupExecuteOperation.cs index 855883e99..1a29224e3 100644 --- a/Tzkt.Api/Repositories/OperationRepository.SmartRollupExecuteOperation.cs +++ b/Tzkt.Api/Repositories/OperationRepository.SmartRollupExecuteOperation.cs @@ -47,7 +47,7 @@ async Task> QuerySmartRollupExecuteOps(SrOperationFilter fi o."SmartRollupId", o."CommitmentId" as "cId", o."Errors", - o."Level", + o."TicketTransfers", c."InitiatorId" as "cInitiatorId", c."InboxLevel" as "cInboxLevel", @@ -105,6 +105,7 @@ async Task> QuerySmartRollupExecuteOps(SrOperationFilter fi } break; case "errors": columns.Add(@"o.""Errors"""); break; + case "ticketTransfersCount": columns.Add(@"o.""TicketTransfers"""); break; case "quote": columns.Add(@"o.""Level"""); break; } } @@ -163,6 +164,7 @@ public async Task> GetSmartRollupExecut FirstTime = Times[row.cFirstLevel], }, Errors = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null, + TicketTransfersCount = row.TicketTransfers, Quote = Quotes.Get(quote, row.Level) }); } @@ -313,6 +315,10 @@ public async Task GetSmartRollupExecuteOps(SrOperationFilter filter, foreach (var row in rows) result[j++][i] = row.Errors != null ? OperationErrorSerializer.Deserialize(row.Errors) : null; break; + case "ticketTransfersCount": + foreach (var row in rows) + result[j++][i] = row.TicketTransfers; + break; case "quote": foreach (var row in rows) result[j++][i] = Quotes.Get(quote, row.Level); diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index 8aa071779..bdac3a23f 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -17,7 +17,7 @@ public TicketsRepository(AccountsCache accounts, TimeCache times, IConfiguration } #region tickets - async Task> QueryTicketsAsync(TicketFilter filter, Pagination pagination, MichelineFormat format, List fields = null) + async Task> QueryTicketsAsync(TicketFilter filter, Pagination pagination, List fields = null) { var select = "*"; if (fields != null) @@ -30,6 +30,21 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati { case "id": columns.Add(@"""Id"""); break; case "ticketer": columns.Add(@"""TicketerId"""); break; + case "rawType": columns.Add(@"""RawType"""); break; + case "rawContent": columns.Add(@"""RawContent"""); break; + case "content": + if (field.Path == null) + { + columns.Add(@"""JsonContent"""); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"""JsonContent"" #> '{{{field.PathString}}}' as {field.Column}"); + } + break; + case "typeHash": columns.Add(@"""TypeHash"""); break; + case "contentHash": columns.Add(@"""ContentHash"""); break; case "firstMinter": columns.Add(@"""FirstMinterId"""); break; case "firstLevel": columns.Add(@"""FirstLevel"""); break; case "firstTime": columns.Add(@"""FirstLevel"""); break; @@ -41,25 +56,6 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati case "totalMinted": columns.Add(@"""TotalMinted"""); break; case "totalBurned": columns.Add(@"""TotalBurned"""); break; case "totalSupply": columns.Add(@"""TotalSupply"""); break; - case "contentHash": columns.Add(@"o.""ContentHash"""); break; - case "typeHash": columns.Add(@"o.""TypeHash"""); break; - case "type": columns.Add(@"""RawType"""); break; - case "content": - if (field.Path == null) - { - columns.Add(format <= MichelineFormat.JsonString ? @"""JsonContent""" : @"""RawContent"""); - } - else if (format <= MichelineFormat.JsonString) - { - field.Column = $"c{counter++}"; - columns.Add($@"""JsonContent"" #> '{{{field.PathString}}}' as {field.Column}"); - } - else - { - field.Column = $"c{counter++}"; - columns.Add($@"NULL as {field.Column}"); - } - break; } } @@ -72,24 +68,21 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati var sql = new SqlBuilder($@"SELECT {select} FROM ""Tickets""") .Filter("Id", filter.id) .Filter("TicketerId", filter.ticketer) + .Filter("JsonContent", filter.content) + .Filter("TypeHash", filter.typeHash) + .Filter("ContentHash", filter.contentHash) .Filter("FirstMinterId", filter.firstMinter) .Filter("FirstLevel", filter.firstLevel) .Filter("FirstLevel", filter.firstTime) .Filter("LastLevel", filter.lastLevel) .Filter("LastLevel", filter.lastTime) - .Filter("TypeHash", filter.typeHash) - .Filter("ContentHash", filter.contentHash) - .Filter("JsonContent", filter.content) .Take(pagination, x => x switch { - "ticketerId" => (@"""TicketerId""::numeric", @"""TicketerId""::numeric"), + "firstLevel" => (@"""FirstLevel""", @"""FirstLevel"""), + "lastLevel" => (@"""LastLevel""", @"""LastLevel"""), "transfersCount" => (@"""TransfersCount""", @"""TransfersCount"""), - "holdersCount" => (@"""HoldersCount""", @"""HoldersCount"""), "balancesCount" => (@"""BalancesCount""", @"""BalancesCount"""), - "firstLevel" => (@"""Id""", @"""FirstLevel"""), - "lastLevel" => (@"""LastLevel""", @"""LastLevel"""), - "contentHash" => (@"""ContentHash""", @"""ContentHash"""), - "typeHash" => (@"""TypeHash""", @"""TypeHash"""), + "holdersCount" => (@"""HoldersCount""", @"""HoldersCount"""), _ => (@"""Id""", @"""Id""") }); @@ -102,47 +95,48 @@ public async Task GetTicketsCount(TicketFilter filter) var sql = new SqlBuilder(@"SELECT COUNT(*) FROM ""Tickets""") .Filter("Id", filter.id) .Filter("TicketerId", filter.ticketer) + .Filter("JsonContent", filter.content) + .Filter("TypeHash", filter.typeHash) + .Filter("ContentHash", filter.contentHash) .Filter("FirstMinterId", filter.firstMinter) .Filter("FirstLevel", filter.firstLevel) .Filter("FirstLevel", filter.firstTime) .Filter("LastLevel", filter.lastLevel) - .Filter("LastLevel", filter.lastTime) - .Filter("TypeHash", filter.typeHash) - .Filter("ContentHash", filter.contentHash) - .Filter("JsonContent", filter.content); + .Filter("LastLevel", filter.lastTime); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); } - public async Task> GetTickets(TicketFilter filter, Pagination pagination, MichelineFormat format) + public async Task> GetTickets(TicketFilter filter, Pagination pagination) { - var rows = await QueryTicketsAsync(filter, pagination, format); + var rows = await QueryTicketsAsync(filter, pagination); return rows.Select(row => new Ticket { - Ticketer = Accounts.GetAlias(row.TicketerId), Id = row.Id, - BalancesCount = row.BalancesCount, + Ticketer = Accounts.GetAlias(row.TicketerId), + RawType = Micheline.FromBytes((byte[])row.RawType), + RawContent = Micheline.FromBytes((byte[])row.RawContent), + Content = (RawJson)row.JsonContent, + TypeHash = row.TypeHash, + ContentHash = row.ContentHash, FirstMinter = Accounts.GetAlias(row.FirstMinterId), FirstLevel = row.FirstLevel, FirstTime = Times[row.FirstLevel], - HoldersCount = row.HoldersCount, LastLevel = row.LastLevel, LastTime = Times[row.LastLevel], - TotalBurned = row.TotalBurned, - TotalMinted = row.TotalMinted, - TotalSupply = row.TotalSupply, TransfersCount = row.TransfersCount, - Type = Micheline.FromBytes((byte[])row.RawType), - Content = FormatContent(row, format), - ContentHash = row.ContentHash, - TypeHash = row.TypeHash + BalancesCount = row.BalancesCount, + HoldersCount = row.HoldersCount, + TotalMinted = row.TotalMinted, + TotalBurned = row.TotalBurned, + TotalSupply = row.TotalSupply }); } - public async Task GetTickets(TicketFilter filter, Pagination pagination, MichelineFormat format, List fields) + public async Task GetTickets(TicketFilter filter, Pagination pagination, List fields) { - var rows = await QueryTicketsAsync(filter, pagination, format, fields); + var rows = await QueryTicketsAsync(filter, pagination, fields); var result = new object[rows.Count()][]; for (int i = 0; i < result.Length; i++) @@ -168,13 +162,17 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat foreach (var row in rows) result[j++][i] = Accounts.GetAlias(row.TicketerId).Address; break; - case "type": + case "rawType": foreach (var row in rows) result[j++][i] = Micheline.FromBytes((byte[])row.RawType); break; + case "rawContent": + foreach (var row in rows) + result[j++][i] = Micheline.FromBytes((byte[])row.RawContent); + break; case "content": foreach (var row in rows) - result[j++][i] = FormatContent(row, format); + result[j++][i] = (RawJson)row.JsonContent; break; case "typeHash": foreach (var row in rows) @@ -244,22 +242,22 @@ public async Task GetTickets(TicketFilter filter, Pagination paginat #endregion #region ticket balances - async Task> QueryTicketBalancesAsync(TicketBalanceFilter filter, Pagination pagination, MichelineFormat format, List fields = null) + async Task> QueryTicketBalancesAsync(TicketBalanceFilter filter, Pagination pagination, List fields = null) { var select = @" tb.""Id"", tb.""AccountId"", tb.""Balance"", + tb.""TransfersCount"", tb.""FirstLevel"", tb.""LastLevel"", - tb.""TransfersCount"", tb.""TicketId"" as ""tId"", tb.""TicketerId"" as ""tTicketerId"", - t.""JsonContent"" as ""JsonContent"", - t.""RawContent"" as ""RawContent"", - t.""RawType"" as ""RawType"", - t.""ContentHash"" as ""ContentHash"", - t.""TypeHash"" as ""TypeHash"", + t.""RawType"" as ""tRawType"", + t.""RawContent"" as ""tRawContent"", + t.""JsonContent"" as ""tJsonContent"", + t.""TypeHash"" as ""tTypeHash"", + t.""ContentHash"" as ""tContentHash"", t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { @@ -270,22 +268,51 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi switch (field.Field) { case "id": columns.Add(@"tb.""Id"""); break; + case "ticket": + if (field.Path == null) + { + columns.Add(@"tb.""TicketId"" as ""tId"""); + columns.Add(@"tb.""TicketerId"" as ""tTicketerId"""); + columns.Add(@"t.""RawType"" as ""tRawType"""); + columns.Add(@"t.""RawContent"" as ""tRawContent"""); + columns.Add(@"t.""JsonContent"" as ""tJsonContent"""); + columns.Add(@"t.""TypeHash"" as ""tTypeHash"""); + columns.Add(@"t.""ContentHash"" as ""tContentHash"""); + columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); + } + else + { + var subField = field.SubField(); + switch (subField.Field) + { + case "id": columns.Add(@"tb.""TicketId"" as ""tId"""); break; + case "ticketer": columns.Add(@"tb.""TicketerId"" as ""tTicketerId"""); break; + case "rawType": columns.Add(@"t.""RawType"" as ""tRawType"""); break; + case "rawContent": columns.Add(@"t.""RawContent"" as ""tRawContent"""); break; + case "content": + if (subField.Path == null) + { + columns.Add(@"t.""JsonContent"" as ""tJsonContent"""); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"t.""JsonContent"" #> '{{{subField.PathString}}}' as {field.Column}"); + } + break; + case "typeHash": columns.Add(@"t.""TypeHash"" as ""tTypeHash"""); break; + case "contentHash": columns.Add(@"t.""ContentHash"" as ""tContentHash"""); break; + case "totalSupply": columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); break; + } + } + break; case "account": columns.Add(@"tb.""AccountId"""); break; case "balance": columns.Add(@"tb.""Balance"""); break; + case "transfersCount": columns.Add(@"tb.""TransfersCount"""); break; case "firstLevel": columns.Add(@"tb.""FirstLevel"""); break; case "firstTime": columns.Add(@"tb.""FirstLevel"""); break; case "lastLevel": columns.Add(@"tb.""LastLevel"""); break; case "lastTime": columns.Add(@"tb.""LastLevel"""); break; - case "transfersCount": columns.Add(@"tb.""TransfersCount"""); break; - case "ticket": - columns.Add(@"tb.""TicketId"" as ""tId"""); - columns.Add(@"tb.""TicketerId"" as ""tTicketerId"""); - columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); - columns.Add(FormatContentQuery(format)); - columns.Add(@"t.""RawType"" as ""RawType"""); - columns.Add(@"t.""ContentHash"" as ""ContentHash"""); - columns.Add(@"t.""TypeHash"" as ""TypeHash"""); - break; } } @@ -301,14 +328,15 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi .FilterA(@"tb.""Id""", filter.id) .FilterA(@"tb.""AccountId""", filter.account) .FilterA(@"tb.""Balance""", filter.balance) + .FilterA(@"tb.""TransfersCount""", filter.transfersCount) .FilterA(@"tb.""FirstLevel""", filter.firstLevel) .FilterA(@"tb.""FirstLevel""", filter.firstTime) .FilterA(@"tb.""LastLevel""", filter.lastLevel) .FilterA(@"tb.""LastLevel""", filter.lastTime) .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) .Take(pagination, x => x switch { "balance" => (@"tb.""Balance""::numeric", @"tb.""Balance""::numeric"), @@ -330,48 +358,50 @@ SELECT COUNT(*) FROM ""TicketBalances"" as tb .FilterA(@"tb.""Id""", filter.id) .FilterA(@"tb.""AccountId""", filter.account) .FilterA(@"tb.""Balance""", filter.balance) + .FilterA(@"tb.""TransfersCount""", filter.transfersCount) .FilterA(@"tb.""FirstLevel""", filter.firstLevel) .FilterA(@"tb.""FirstLevel""", filter.firstTime) .FilterA(@"tb.""LastLevel""", filter.lastLevel) .FilterA(@"tb.""LastLevel""", filter.lastTime) .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""TypeHash""", filter.ticket.typeHash); + .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); } - public async Task> GetTicketBalances(TicketBalanceFilter filter, Pagination pagination, MichelineFormat format) + public async Task> GetTicketBalances(TicketBalanceFilter filter, Pagination pagination) { - var rows = await QueryTicketBalancesAsync(filter, pagination, format); + var rows = await QueryTicketBalancesAsync(filter, pagination); return rows.Select(row => new TicketBalance { Id = row.Id, + Ticket = new TicketInfo + { + Id = row.tId, + Ticketer = Accounts.GetAlias(row.tTicketerId), + RawType = Micheline.FromBytes((byte[])row.tRawType), + RawContent = Micheline.FromBytes((byte[])row.tRawContent), + Content = (RawJson)row.tJsonContent, + TypeHash = row.tTypeHash, + ContentHash = row.tContentHash, + TotalSupply = row.tTotalSupply + }, Account = Accounts.GetAlias(row.AccountId), Balance = row.Balance, + TransfersCount = row.TransfersCount, FirstLevel = row.FirstLevel, FirstTime = Times[row.FirstLevel], LastLevel = row.LastLevel, - LastTime = Times[row.LastLevel], - TransfersCount = row.TransfersCount, - Ticket = new TicketInfo - { - Id = row.tId, - Ticketer = Accounts.GetAlias(row.tTicketerId), - TotalSupply = row.tTotalSupply, - Type = Micheline.FromBytes((byte[])row.RawType), - Content = FormatContent(row, format), - ContentHash = row.ContentHash, - TypeHash = row.TypeHash - } + LastTime = Times[row.LastLevel] }); } - public async Task GetTicketBalances(TicketBalanceFilter filter, Pagination pagination, MichelineFormat format, List fields) + public async Task GetTicketBalances(TicketBalanceFilter filter, Pagination pagination, List fields) { - var rows = await QueryTicketBalancesAsync(filter, pagination, format, fields); + var rows = await QueryTicketBalancesAsync(filter, pagination, fields); var result = new object[rows.Count()][]; for (int i = 0; i < result.Length; i++) @@ -401,6 +431,10 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi foreach (var row in rows) result[j++][i] = row.Balance; break; + case "transfersCount": + foreach (var row in rows) + result[j++][i] = row.TransfersCount; + break; case "firstLevel": foreach (var row in rows) result[j++][i] = row.FirstLevel; @@ -417,21 +451,18 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi foreach (var row in rows) result[j++][i] = Times[row.LastLevel]; break; - case "transfersCount": - foreach (var row in rows) - result[j++][i] = row.TransfersCount; - break; case "ticket": foreach (var row in rows) result[j++][i] = new TicketInfo { Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), - TotalSupply = row.tTotalSupply, - Type = Micheline.FromBytes((byte[])row.RawType), - Content = FormatContent(row, format), - ContentHash = row.ContentHash, - TypeHash = row.TypeHash + RawType = Micheline.FromBytes((byte[])row.tRawType), + RawContent = Micheline.FromBytes((byte[])row.tRawContent), + Content = (RawJson)row.tJsonContent, + TypeHash = row.tTypeHash, + ContentHash = row.tContentHash, + TotalSupply = row.tTotalSupply }; break; case "ticket.id": @@ -450,25 +481,34 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi foreach (var row in rows) result[j++][i] = Accounts.GetAlias(row.tTicketerId).Address; break; - case "ticket.totalSupply": + case "ticket.rawType": foreach (var row in rows) - result[j++][i] = row.tTotalSupply; + result[j++][i] = Micheline.FromBytes((byte[])row.tRawType); + break; + case "ticket.rawContent": + foreach (var row in rows) + result[j++][i] = Micheline.FromBytes((byte[])row.tRawContent); break; case "ticket.content": foreach (var row in rows) - result[j++][i] = FormatContent(row, format); + result[j++][i] = (RawJson)row.tJsonContent; break; - case "ticket.type": + case "ticket.typeHash": foreach (var row in rows) - result[j++][i] = Micheline.FromBytes((byte[])row.RawType); + result[j++][i] = row.tTypeHash; break; case "ticket.contentHash": foreach (var row in rows) - result[j++][i] = row.ContentHash; + result[j++][i] = row.tContentHash; break; - case "ticket.typeHash": + case "ticket.totalSupply": foreach (var row in rows) - result[j++][i] = row.TypeHash; + result[j++][i] = row.tTotalSupply; + break; + default: + if (fields[i].Full.StartsWith("ticket.content.")) + foreach (var row in rows) + result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); break; } } @@ -478,7 +518,7 @@ public async Task GetTicketBalances(TicketBalanceFilter filter, Pagi #endregion #region ticket transfers - async Task> QueryTicketTransfersAsync(TicketTransferFilter filter, Pagination pagination, MichelineFormat format, List fields = null) + async Task> QueryTicketTransfersAsync(TicketTransferFilter filter, Pagination pagination, List fields = null) { var select = @" tr.""Id"", @@ -491,11 +531,11 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter tr.""SmartRollupExecuteId"", tr.""TicketId"" as ""tId"", tr.""TicketerId"" as ""tTicketerId"", - t.""JsonContent"" as ""JsonContent"", - t.""RawContent"" as ""RawContent"", - t.""RawType"" as ""RawType"", - t.""ContentHash"" as ""ContentHash"", - t.""TypeHash"" as ""TypeHash"", + t.""RawType"" as ""tRawType"", + t.""RawContent"" as ""tRawContent"", + t.""JsonContent"" as ""tJsonContent"", + t.""TypeHash"" as ""tTypeHash"", + t.""ContentHash"" as ""tContentHash"", t.""TotalSupply"" as ""tTotalSupply"""; if (fields != null) { @@ -508,21 +548,50 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter case "id": columns.Add(@"tr.""Id"""); break; case "level": columns.Add(@"tr.""Level"""); break; case "timestamp": columns.Add(@"tr.""Level"""); break; + case "ticket": + if (field.Path == null) + { + columns.Add(@"tr.""TicketId"" as ""tId"""); + columns.Add(@"tr.""TicketerId"" as ""tTicketerId"""); + columns.Add(@"t.""RawType"" as ""tRawType"""); + columns.Add(@"t.""RawContent"" as ""tRawContent"""); + columns.Add(@"t.""JsonContent"" as ""tJsonContent"""); + columns.Add(@"t.""TypeHash"" as ""tTypeHash"""); + columns.Add(@"t.""ContentHash"" as ""tContentHash"""); + columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); + } + else + { + var subField = field.SubField(); + switch (subField.Field) + { + case "id": columns.Add(@"tr.""TicketId"" as ""tId"""); break; + case "ticketer": columns.Add(@"tr.""TicketerId"" as ""tTicketerId"""); break; + case "rawType": columns.Add(@"t.""RawType"" as ""tRawType"""); break; + case "rawContent": columns.Add(@"t.""RawContent"" as ""tRawContent"""); break; + case "content": + if (subField.Path == null) + { + columns.Add(@"t.""JsonContent"" as ""tJsonContent"""); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"t.""JsonContent"" #> '{{{subField.PathString}}}' as {field.Column}"); + } + break; + case "typeHash": columns.Add(@"t.""TypeHash"" as ""tTypeHash"""); break; + case "contentHash": columns.Add(@"t.""ContentHash"" as ""tContentHash"""); break; + case "totalSupply": columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); break; + } + } + break; case "from": columns.Add(@"tr.""FromId"""); break; case "to": columns.Add(@"tr.""ToId"""); break; case "amount": columns.Add(@"tr.""Amount"""); break; case "transactionId": columns.Add(@"tr.""TransactionId"""); break; case "transferTicketId": columns.Add(@"tr.""TransferTicketId"""); break; case "smartRollupExecuteId": columns.Add(@"tr.""SmartRollupExecuteId"""); break; - case "ticket": - columns.Add(@"tr.""TicketId"" as ""tId"""); - columns.Add(@"tr.""TicketerId"" as ""tTicketerId"""); - columns.Add(@"t.""TotalSupply"" as ""tTotalSupply"""); - columns.Add(FormatContentQuery(format)); - columns.Add(@"t.""RawType"" as ""RawType"""); - columns.Add(@"t.""ContentHash"" as ""ContentHash"""); - columns.Add(@"t.""TypeHash"" as ""TypeHash"""); - break; } } @@ -547,8 +616,8 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) .Take(pagination, x => x switch { "level" => (@"tr.""Level""", @"tr.""Level"""), @@ -577,43 +646,44 @@ SELECT COUNT(*) FROM ""TicketTransfers"" as tr .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""TypeHash""", filter.ticket.typeHash); + .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) + .FilterA(@"t.""ContentHash""", filter.ticket.contentHash); using var db = GetConnection(); return await db.QueryFirstAsync(sql.Query, sql.Params); } - public async Task> GetTicketTransfers(TicketTransferFilter filter, Pagination pagination, MichelineFormat format) + public async Task> GetTicketTransfers(TicketTransferFilter filter, Pagination pagination) { - var rows = await QueryTicketTransfersAsync(filter, pagination, format); + var rows = await QueryTicketTransfersAsync(filter, pagination); return rows.Select(row => new TicketTransfer { Id = row.Id, Level = row.Level, Timestamp = Times[row.Level], + Ticket = new TicketInfo + { + Id = row.tId, + Ticketer = Accounts.GetAlias(row.tTicketerId), + RawType = Micheline.FromBytes((byte[])row.tRawType), + RawContent = Micheline.FromBytes((byte[])row.tRawContent), + Content = (RawJson)row.tJsonContent, + TypeHash = row.tTypeHash, + ContentHash = row.tContentHash, + TotalSupply = row.tTotalSupply + }, From = row.FromId == null ? null : Accounts.GetAlias(row.FromId), To = row.ToId == null ? null : Accounts.GetAlias(row.ToId), Amount = row.Amount, TransactionId = row.TransactionId, TransferTicketId = row.TransferTicketId, - SmartRollupExecuteId = row.SmartRollupExecuteId, - Ticket = new TicketInfo - { - Id = row.tId, - Ticketer = Accounts.GetAlias(row.tTicketerId), - TotalSupply = row.tTotalSupply, - Type = Micheline.FromBytes((byte[])row.RawType), - Content = FormatContent(row, format), - ContentHash = row.ContentHash, - TypeHash = row.TypeHash - } + SmartRollupExecuteId = row.SmartRollupExecuteId }); } - public async Task GetTicketTransfers(TicketTransferFilter filter, Pagination pagination, MichelineFormat format, List fields) + public async Task GetTicketTransfers(TicketTransferFilter filter, Pagination pagination, List fields) { - var rows = await QueryTicketTransfersAsync(filter, pagination, format, fields); + var rows = await QueryTicketTransfersAsync(filter, pagination, fields); var result = new object[rows.Count()][]; for (int i = 0; i < result.Length; i++) @@ -681,11 +751,12 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa { Id = row.tId, Ticketer = Accounts.GetAlias(row.tTicketerId), - TotalSupply = row.tTotalSupply, - Type = Micheline.FromBytes((byte[])row.RawType), - Content = FormatContent(row, format), - ContentHash = row.ContentHash, - TypeHash = row.TypeHash + RawType = Micheline.FromBytes((byte[])row.tRawType), + RawContent = Micheline.FromBytes((byte[])row.tRawContent), + Content = (RawJson)row.tJsonContent, + TypeHash = row.tTypeHash, + ContentHash = row.tContentHash, + TotalSupply = row.tTotalSupply }; break; case "ticket.id": @@ -704,25 +775,34 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa foreach (var row in rows) result[j++][i] = Accounts.GetAlias(row.tTicketerId).Address; break; - case "ticket.totalSupply": + case "ticket.rawType": foreach (var row in rows) - result[j++][i] = row.tTotalSupply; + result[j++][i] = Micheline.FromBytes((byte[])row.tRawType); + break; + case "ticket.rawContent": + foreach (var row in rows) + result[j++][i] = Micheline.FromBytes((byte[])row.tRawContent); break; case "ticket.content": foreach (var row in rows) - result[j++][i] = FormatContent(row, format); + result[j++][i] = (RawJson)row.tJsonContent; break; - case "ticket.type": + case "ticket.typeHash": foreach (var row in rows) - result[j++][i] = Micheline.FromBytes((byte[])row.RawType); + result[j++][i] = row.tTypeHash; break; case "ticket.contentHash": foreach (var row in rows) - result[j++][i] = row.ContentHash; + result[j++][i] = row.tContentHash; break; - case "ticket.typeHash": + case "ticket.totalSupply": foreach (var row in rows) - result[j++][i] = row.TypeHash; + result[j++][i] = row.tTotalSupply; + break; + default: + if (fields[i].Full.StartsWith("ticket.content.")) + foreach (var row in rows) + result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); break; } } @@ -732,13 +812,19 @@ public async Task GetTicketTransfers(TicketTransferFilter filter, Pa #endregion #region historical balances - async Task> QueryHistoricalTicketBalancesAsync(int level, TicketBalanceShortFilter filter, Pagination pagination, MichelineFormat format, List fields = null) + async Task> QueryHistoricalTicketBalancesAsync(int level, TicketBalanceShortFilter filter, Pagination pagination, List fields = null) { var select = @" + tb.""Id"", tb.""AccountId"", tb.""Balance"", tb.""TicketId"" as ""tId"", - t.""TicketerId"" as ""tTicketerId"""; + tb.""TicketerId"" as ""tTicketerId"", + t.""RawType"" as ""tRawType"", + t.""RawContent"" as ""tRawContent"", + t.""JsonContent"" as ""tJsonContent"", + t.""TypeHash"" as ""tTypeHash"", + t.""ContentHash"" as ""tContentHash"""; if (fields != null) { var counter = 0; @@ -747,12 +833,45 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T { switch (field.Field) { - case "account": columns.Add(@"tb.""AccountId"""); break; - case "balance": columns.Add(@"tb.""Balance"""); break; + case "id": columns.Add(@"tb.""Id"""); break; case "ticket": - columns.Add(@"tb.""TicketId"" as ""tId"""); - columns.Add(@"t.""TicketerId"" as ""tTicketerId"""); + if (field.Path == null) + { + columns.Add(@"tb.""TicketId"" as ""tId"""); + columns.Add(@"tb.""TicketerId"" as ""tTicketerId"""); + columns.Add(@"t.""RawType"" as ""tRawType"""); + columns.Add(@"t.""RawContent"" as ""tRawContent"""); + columns.Add(@"t.""JsonContent"" as ""tJsonContent"""); + columns.Add(@"t.""TypeHash"" as ""tTypeHash"""); + columns.Add(@"t.""ContentHash"" as ""tContentHash"""); + } + else + { + var subField = field.SubField(); + switch (subField.Field) + { + case "id": columns.Add(@"tb.""TicketId"" as ""tId"""); break; + case "ticketer": columns.Add(@"tb.""TicketerId"" as ""tTicketerId"""); break; + case "rawType": columns.Add(@"t.""RawType"" as ""tRawType"""); break; + case "rawContent": columns.Add(@"t.""RawContent"" as ""tRawContent"""); break; + case "content": + if (subField.Path == null) + { + columns.Add(@"t.""JsonContent"" as ""tJsonContent"""); + } + else + { + field.Column = $"c{counter++}"; + columns.Add($@"t.""JsonContent"" #> '{{{subField.PathString}}}' as {field.Column}"); + } + break; + case "typeHash": columns.Add(@"t.""TypeHash"" as ""tTypeHash"""); break; + case "contentHash": columns.Add(@"t.""ContentHash"" as ""tContentHash"""); break; + } + } break; + case "account": columns.Add(@"tb.""AccountId"""); break; + case "balance": columns.Add(@"tb.""Balance"""); break; } } @@ -764,61 +883,62 @@ async Task> QueryHistoricalTicketBalancesAsync(int level, T var sql = new SqlBuilder() .Append($@"SELECT {select} FROM (") - .Append(@"SELECT ROW_NUMBER() over (ORDER BY ""TicketId"", ""AccountId"") as ""Id"", ""TicketId"", ""AccountId"", SUM(""Amount"")::text AS ""Balance"" FROM (") + .Append(@"SELECT ROW_NUMBER() over (ORDER BY ""TicketId"", ""AccountId"") as ""Id"", ""TicketId"", ""TicketerId"", ""AccountId"", SUM(""Amount"")::text AS ""Balance"" FROM (") - .Append(@"SELECT tr.""TicketId"", tr.""FromId"" AS ""AccountId"", -tr.""Amount""::numeric AS ""Amount"" FROM ""TicketTransfers"" as tr") - .Append(@"INNER JOIN ""Tickets"" AS t ON t.""Id"" = tr.""TicketId""") - .Filter($@"tr.""Level"" <= {level}") - .Filter($@"tr.""FromId"" IS NOT NULL") - .FilterA(@"tr.""FromId""", filter.account) - .FilterA(@"tr.""TicketId""", filter.ticket.id) - .FilterA(@"t.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) - .ResetFilters() + .Append(@"SELECT ""TicketId"", ""TicketerId"", ""FromId"" AS ""AccountId"", -""Amount""::numeric AS ""Amount"" FROM ""TicketTransfers""") + .Filter($@"""Level"" <= {level}") + .Filter($@"""FromId"" IS NOT NULL") + .FilterA(@"""FromId""", filter.account) + .FilterA(@"""TicketId""", filter.ticket.id) + .FilterA(@"""TicketerId""", filter.ticket.ticketer) + .ResetFilters() .Append("UNION ALL") - .Append(@"SELECT tr.""TicketId"", tr.""ToId"" AS ""AccountId"", tr.""Amount""::numeric AS ""Amount"" FROM ""TicketTransfers"" as tr") - .Append(@"INNER JOIN ""Tickets"" AS t ON t.""Id"" = tr.""TicketId""") - .Filter($@"tr.""Level"" <= {level}") - .Filter($@"tr.""ToId"" IS NOT NULL") - .FilterA(@"tr.""ToId""", filter.account) - .FilterA(@"tr.""TicketId""", filter.ticket.id) - .FilterA(@"t.""TicketerId""", filter.ticket.ticketer) - .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) - .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) + .Append(@"SELECT ""TicketId"", ""TicketerId"", ""ToId"" AS ""AccountId"", ""Amount""::numeric AS ""Amount"" FROM ""TicketTransfers""") + .Filter($@"""Level"" <= {level}") + .Filter($@"""ToId"" IS NOT NULL") + .FilterA(@"""ToId""", filter.account) + .FilterA(@"""TicketId""", filter.ticket.id) + .FilterA(@"""TicketerId""", filter.ticket.ticketer) .ResetFilters() .Append(") as tb") - .Append(@"GROUP BY tb.""TicketId"", tb.""AccountId""") + .Append(@"GROUP BY tb.""TicketId"", tb.""TicketerId"", tb.""AccountId""") .Append(") as tb") .Append(@"INNER JOIN ""Tickets"" AS t ON t.""Id"" = tb.""TicketId""") + .FilterA(@"tb.""Id""", filter.id) .FilterA(@"tb.""Balance""", filter.balance) - .Take(pagination, _ => (@"""Balance""::numeric", @"""Balance""::numeric"), @"tb.""Id"""); + .Take(pagination, _ => (@"tb.""Id""", @"tb.""Id"""), @"tb.""Id"""); using var db = GetConnection(); return await db.QueryAsync(sql.Query, sql.Params); } - public async Task> GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination, MichelineFormat format) + public async Task> GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination) { - var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination, format); + var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination); return rows.Select(row => new TicketBalanceShort { + Id = row.Id, Account = Accounts.GetAlias(row.AccountId), Balance = row.Balance, - Ticket = new TicketInfo + Ticket = new TicketInfoShort { Id = row.tId, - Ticketer = Accounts.GetAlias(row.tTicketerId) + Ticketer = Accounts.GetAlias(row.tTicketerId), + RawType = Micheline.FromBytes((byte[])row.tRawType), + RawContent = Micheline.FromBytes((byte[])row.tRawContent), + Content = (RawJson)row.tJsonContent, + TypeHash = row.tTypeHash, + ContentHash = row.tContentHash } }); } - public async Task GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination, MichelineFormat format, List fields) + public async Task GetHistoricalTicketBalances(int level, TicketBalanceShortFilter filter, Pagination pagination, List fields) { - var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination, format, fields); + var rows = await QueryHistoricalTicketBalancesAsync(level, filter, pagination, fields); var result = new object[rows.Count()][]; for (int i = 0; i < result.Length; i++) @@ -828,6 +948,10 @@ public async Task GetHistoricalTicketBalances(int level, TicketBalan { switch (fields[i].Full) { + case "id": + foreach (var row in rows) + result[j++][i] = row.Id; + break; case "account": foreach (var row in rows) result[j++][i] = Accounts.GetAlias(row.AccountId); @@ -846,10 +970,15 @@ public async Task GetHistoricalTicketBalances(int level, TicketBalan break; case "ticket": foreach (var row in rows) - result[j++][i] = new TicketInfo + result[j++][i] = new TicketInfoShort { Id = row.tId, - Ticketer = Accounts.GetAlias(row.tTicketerId) + Ticketer = Accounts.GetAlias(row.tTicketerId), + RawType = Micheline.FromBytes((byte[])row.tRawType), + RawContent = Micheline.FromBytes((byte[])row.tRawContent), + Content = (RawJson)row.tJsonContent, + TypeHash = row.tTypeHash, + ContentHash = row.tContentHash }; break; case "ticket.id": @@ -868,29 +997,36 @@ public async Task GetHistoricalTicketBalances(int level, TicketBalan foreach (var row in rows) result[j++][i] = Accounts.GetAlias(row.tTicketerId).Address; break; + case "ticket.rawType": + foreach (var row in rows) + result[j++][i] = Micheline.FromBytes((byte[])row.tRawType); + break; + case "ticket.rawContent": + foreach (var row in rows) + result[j++][i] = Micheline.FromBytes((byte[])row.tRawContent); + break; + case "ticket.content": + foreach (var row in rows) + result[j++][i] = (RawJson)row.tJsonContent; + break; + case "ticket.typeHash": + foreach (var row in rows) + result[j++][i] = row.tTypeHash; + break; + case "ticket.contentHash": + foreach (var row in rows) + result[j++][i] = row.tContentHash; + break; + default: + if (fields[i].Full.StartsWith("ticket.content.")) + foreach (var row in rows) + result[j++][i] = (RawJson)((row as IDictionary)[fields[i].Column] as string); + break; } } return result; } #endregion - - static object FormatContent(dynamic row, MichelineFormat format) => format switch - { - MichelineFormat.Json => (RawJson)row.JsonContent, - MichelineFormat.JsonString => row.JsonContent, - MichelineFormat.Raw => (RawJson)Micheline.ToJson(row.RawContent), - MichelineFormat.RawString => Micheline.ToJson(row.RawContent), - _ => null - }; - - static string FormatContentQuery(MichelineFormat format) => format switch - { - MichelineFormat.Json => @"t.""JsonContent"" as ""JsonContent""", - MichelineFormat.JsonString => @"t.""JsonContent"" as ""JsonContent""", - MichelineFormat.Raw => @"t.""RawContent"" as ""RawContent""", - MichelineFormat.RawString => @"t.""RawContent"" as ""RawContent""", - _ => throw new Exception("Invalid MichelineFormat value") - }; } } diff --git a/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs b/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs index fd1cfc549..69721e121 100644 --- a/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/TicketBalancesProcessor.cs @@ -81,7 +81,7 @@ public async Task OnStateChanged() #region load ticket balances Logger.LogDebug("Fetching ticket balances from {valid} to {current}", State.ValidLevel, State.Current.Level); - var params1 = new TicketBalanceFilter + var param = new TicketBalanceFilter { lastLevel = State.Current.Level == State.ValidLevel + 1 ? new Int32Parameter @@ -97,9 +97,8 @@ public async Task OnStateChanged() ticket = new() }; var limit = 1_000_000; - var format = MichelineFormat.Json; - var balances = await Repo.GetTicketBalances(params1, new() { limit = limit }, format); + var balances = await Repo.GetTicketBalances(param, new() { limit = limit }); var count = balances.Count(); Logger.LogDebug("{cnt} ticket balances fetched", count); @@ -354,39 +353,12 @@ public void Unsubscribe(string connectionId) } } - private static void TryAdd(Dictionary> subs, TSubKey key, string connectionId) - { - if (!subs.TryGetValue(key, out var set)) - { - set = new(4); - subs.Add(key, set); - } - - if (set.Add(connectionId)) - Limits[connectionId] = Limits.GetValueOrDefault(connectionId) + 1; - } - private static void TryAdd(HashSet set, string connectionId) { if (set.Add(connectionId)) Limits[connectionId] = Limits.GetValueOrDefault(connectionId) + 1; } - private static Dictionary> TryRemove(Dictionary> subs, string connectionId) - { - if (subs == null) return null; - foreach (var (key, value) in subs) - { - if (value.Remove(connectionId)) - Limits[connectionId]--; - - if (value.Count == 0) - subs.Remove(key); - } - if (subs.Count == 0) return null; - return subs; - } - private static HashSet TryRemove(HashSet set, string connectionId) { if (set == null) return null; diff --git a/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs b/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs index e5fae5cce..884bef3d2 100644 --- a/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs +++ b/Tzkt.Api/Websocket/Processors/TicketTransfersProcessor.cs @@ -81,7 +81,7 @@ public async Task OnStateChanged() #region load ticket transfers Logger.LogDebug("Fetching ticket transfers from block {valid} to block {current}", State.ValidLevel, State.Current.Level); - var params1 = new TicketTransferFilter + var param = new TicketTransferFilter { level = State.Current.Level == State.ValidLevel + 1 ? new Int32Parameter @@ -96,10 +96,9 @@ public async Task OnStateChanged() ticket = new() }; var limit = 1_000_000; - var format = MichelineFormat.Json; - var transfers = (await Repo.GetTicketTransfers(params1, new() { limit = limit }, format)); + var transfers = await Repo.GetTicketTransfers(param, new() { limit = limit }); var count = transfers.Count(); Logger.LogDebug("{cnt} ticket transfers fetched", count); @@ -374,39 +373,12 @@ public void Unsubscribe(string connectionId) } } - private static void TryAdd(Dictionary> subs, TSubKey key, string connectionId) - { - if (!subs.TryGetValue(key, out var set)) - { - set = new(4); - subs.Add(key, set); - } - - if (set.Add(connectionId)) - Limits[connectionId] = Limits.GetValueOrDefault(connectionId) + 1; - } - private static void TryAdd(HashSet set, string connectionId) { if (set.Add(connectionId)) Limits[connectionId] = Limits.GetValueOrDefault(connectionId) + 1; } - private static Dictionary> TryRemove(Dictionary> subs, string connectionId) - { - if (subs == null) return null; - foreach (var (key, value) in subs) - { - if (value.Remove(connectionId)) - Limits[connectionId]--; - - if (value.Count == 0) - subs.Remove(key); - } - if (subs.Count == 0) return null; - return subs; - } - private static HashSet TryRemove(HashSet set, string connectionId) { if (set == null) return null; From 344ff72588aa2f2d4fb958e4d6cd34a2ad57a955 Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Thu, 31 Aug 2023 17:17:56 +0300 Subject: [PATCH 50/51] More strict ticket transfers recognition --- Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs index cad18ed83..08e2c0b0c 100644 --- a/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs +++ b/Tzkt.Sync/Protocols/Handlers/Proto16/Commits/TicketsCommit.cs @@ -123,7 +123,7 @@ static bool IsTransfersSequence(List<(ManagerOperation Op, TicketUpdate Update)> return false; for (int i = 0; i < updates.Count; i += 2) - if (updates[i].Update.Amount != -updates[i + 1].Update.Amount) + if (updates[i].Update.Amount > 0 || updates[i].Update.Amount != -updates[i + 1].Update.Amount) return false; return true; From 4b7e5d95434fbc2e34e2ba9e4425881787c037ca Mon Sep 17 00:00:00 2001 From: Maksim Strebkov <257byte@gmail.com> Date: Fri, 1 Sep 2023 14:56:01 +0300 Subject: [PATCH 51/51] Add MichelineParameter, improve docs --- Tzkt.Api/Controllers/TicketsController.cs | 2 +- .../ModelBindingContextExtension.cs | 63 ++++++++++++++++ Tzkt.Api/Models/Tickets/Ticket.cs | 10 +-- Tzkt.Api/Models/Tickets/TicketBalanceShort.cs | 3 +- Tzkt.Api/Models/Tickets/TicketInfo.cs | 12 +--- Tzkt.Api/Models/Tickets/TicketInfoShort.cs | 4 +- Tzkt.Api/Models/Tickets/TicketTransfer.cs | 12 ++-- .../Parameters/Binders/MichelineBinder.cs | 44 ++++++++++++ Tzkt.Api/Parameters/MichelineParameter.cs | 71 +++++++++++++++++++ Tzkt.Api/Parameters/TicketBalanceFilter.cs | 6 +- .../Parameters/TicketBalanceShortFilter.cs | 4 +- Tzkt.Api/Parameters/TicketFilter.cs | 32 ++++++--- Tzkt.Api/Parameters/TicketInfoFilter.cs | 30 +++++++- Tzkt.Api/Parameters/TicketInfoShortFilter.cs | 4 +- Tzkt.Api/Parameters/TicketTransferFilter.cs | 12 ++-- Tzkt.Api/Repositories/TicketsRepository.cs | 18 ++++- Tzkt.Api/Utils/RawJson.cs | 5 +- Tzkt.Api/Utils/SqlBuilder.cs | 39 ++++++++++ 18 files changed, 321 insertions(+), 50 deletions(-) create mode 100644 Tzkt.Api/Parameters/Binders/MichelineBinder.cs create mode 100644 Tzkt.Api/Parameters/MichelineParameter.cs diff --git a/Tzkt.Api/Controllers/TicketsController.cs b/Tzkt.Api/Controllers/TicketsController.cs index b6d6b94b9..c894915ca 100644 --- a/Tzkt.Api/Controllers/TicketsController.cs +++ b/Tzkt.Api/Controllers/TicketsController.cs @@ -263,7 +263,7 @@ public async Task>> GetTicketTransfers( /// Selection /// [HttpGet("historical_balances/{level:int}")] - public async Task>> GetTicketBalances(int level, + public async Task>> GetHistoricalTicketBalances(int level, [FromQuery] TicketBalanceShortFilter filter, [FromQuery] Pagination pagination, [FromQuery] Selection selection) diff --git a/Tzkt.Api/Extensions/ModelBindingContextExtension.cs b/Tzkt.Api/Extensions/ModelBindingContextExtension.cs index 2cc11532c..883317f22 100644 --- a/Tzkt.Api/Extensions/ModelBindingContextExtension.cs +++ b/Tzkt.Api/Extensions/ModelBindingContextExtension.cs @@ -4,6 +4,7 @@ using System.Text.Json; using System.Text.RegularExpressions; using Microsoft.AspNetCore.Mvc.ModelBinding; +using Netezos.Encoding; namespace Tzkt.Api { @@ -189,6 +190,68 @@ public static bool TryGetInt64List(this ModelBindingContext bindingContext, stri return true; } + public static bool TryGetMicheline(this ModelBindingContext bindingContext, string name, ref bool hasValue, out IMicheline result) + { + result = null; + var valueObject = bindingContext.ValueProvider.GetValue(name); + + if (valueObject != ValueProviderResult.None) + { + bindingContext.ModelState.SetModelValue(name, valueObject); + if (!string.IsNullOrEmpty(valueObject.FirstValue)) + { + try + { + result = Micheline.FromJson(valueObject.FirstValue); + hasValue = true; + } + catch + { + bindingContext.ModelState.TryAddModelError(name, "Invalid Micheline value."); + return false; + } + } + } + + return true; + } + + public static bool TryGetMichelineList(this ModelBindingContext bindingContext, string name, ref bool hasValue, out List result) + { + result = null; + var valueObject = bindingContext.ValueProvider.GetValue(name); + + if (valueObject != ValueProviderResult.None) + { + bindingContext.ModelState.SetModelValue(name, valueObject); + if (!string.IsNullOrEmpty(valueObject.FirstValue)) + { + try + { + var json = valueObject.FirstValue.Trim(); + if (json[0] != '[') json = $"[{json}]"; + var values = JsonSerializer.Deserialize>(json); + + if (values.Count == 0) + { + bindingContext.ModelState.TryAddModelError(name, "List should contain at least one item."); + return false; + } + + hasValue = true; + result = values; + } + catch + { + bindingContext.ModelState.TryAddModelError(name, "List contains invalid Micheline value(s)."); + return false; + } + } + } + + return true; + } + public static bool TryGetDateTime(this ModelBindingContext bindingContext, string name, ref bool hasValue, out DateTime? result) { result = null; diff --git a/Tzkt.Api/Models/Tickets/Ticket.cs b/Tzkt.Api/Models/Tickets/Ticket.cs index 1126dcd30..b8ba4670f 100644 --- a/Tzkt.Api/Models/Tickets/Ticket.cs +++ b/Tzkt.Api/Models/Tickets/Ticket.cs @@ -1,5 +1,4 @@ using Netezos.Encoding; -using NJsonSchema.Annotations; namespace Tzkt.Api.Models { @@ -18,20 +17,17 @@ public class Ticket /// /// Ticket content type in Micheline format. - /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// public IMicheline RawType { get; set; } /// /// Ticket content in Micheline format. - /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// public IMicheline RawContent { get; set; } /// /// Ticket content in JSON format. /// - [JsonSchemaType(typeof(object), IsNullable = true)] public RawJson Content { get; set; } /// @@ -90,17 +86,17 @@ public class Ticket public int HoldersCount { get; set; } /// - /// Total number of minted tickets (raw value, not divided by `decimals`). + /// Total amount minted. /// public string TotalMinted { get; set; } /// - /// Total number of burned tickets (raw value, not divided by `decimals`). + /// Total amount burned. /// public string TotalBurned { get; set; } /// - /// Total number of existing tickets (raw value, not divided by `decimals`). + /// Total amount exists. /// public string TotalSupply { get; set; } } diff --git a/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs b/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs index 06039895e..8116d6c7e 100644 --- a/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs +++ b/Tzkt.Api/Models/Tickets/TicketBalanceShort.cs @@ -21,8 +21,7 @@ public class TicketBalanceShort public Alias Account { get; set; } /// - /// Balance (raw value, not divided by `decimals`). - /// **[sortable]** + /// Balance. /// public string Balance { get; set; } } diff --git a/Tzkt.Api/Models/Tickets/TicketInfo.cs b/Tzkt.Api/Models/Tickets/TicketInfo.cs index c0d4cdc73..d35fb23ae 100644 --- a/Tzkt.Api/Models/Tickets/TicketInfo.cs +++ b/Tzkt.Api/Models/Tickets/TicketInfo.cs @@ -1,5 +1,4 @@ using Netezos.Encoding; -using NJsonSchema.Annotations; namespace Tzkt.Api.Models { @@ -11,42 +10,37 @@ public class TicketInfo public long Id { get; set; } /// - /// Contract, created the ticket. + /// Contract, issued the ticket. /// public Alias Ticketer { get; set; } /// /// Ticket content type in Micheline format. - /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// public IMicheline RawType { get; set; } /// /// Ticket content in Micheline format. - /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// public IMicheline RawContent { get; set; } /// /// Ticket content in JSON format. /// - [JsonSchemaType(typeof(object), IsNullable = true)] public RawJson Content { get; set; } - + /// /// 32-bit hash of the ticket content type. - /// This field can be used for searching similar tickets (which have the same type). /// public int TypeHash { get; set; } /// /// 32-bit hash of the ticket content. - /// This field can be used for searching same tickets (which have the same content). /// public int ContentHash { get; set; } /// - /// Total amount of existing tickets. + /// Total amount exists. /// public string TotalSupply { get; set; } } diff --git a/Tzkt.Api/Models/Tickets/TicketInfoShort.cs b/Tzkt.Api/Models/Tickets/TicketInfoShort.cs index ecc387b5c..aca108074 100644 --- a/Tzkt.Api/Models/Tickets/TicketInfoShort.cs +++ b/Tzkt.Api/Models/Tickets/TicketInfoShort.cs @@ -11,19 +11,17 @@ public class TicketInfoShort public long Id { get; set; } /// - /// Contract, created the ticket. + /// Contract, issued the ticket. /// public Alias Ticketer { get; set; } /// /// Ticket content type in Micheline format. - /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// public IMicheline RawType { get; set; } /// /// Ticket content in Micheline format. - /// This field is omitted by default and must be explicitly selected via `?select=` parameter. /// public IMicheline RawContent { get; set; } diff --git a/Tzkt.Api/Models/Tickets/TicketTransfer.cs b/Tzkt.Api/Models/Tickets/TicketTransfer.cs index 559c6c50d..34713d958 100644 --- a/Tzkt.Api/Models/Tickets/TicketTransfer.cs +++ b/Tzkt.Api/Models/Tickets/TicketTransfer.cs @@ -9,13 +9,13 @@ public class TicketTransfer public long Id { get; set; } /// - /// Level of the block, at which the ticket transfer was made. + /// Level of the block, at which the transfer was made. /// **[sortable]** /// public int Level { get; set; } /// - /// Timestamp of the block, at which the ticket transfer was made. + /// Timestamp of the block, at which the transfer was made. /// public DateTime Timestamp { get; set; } @@ -32,13 +32,13 @@ public class TicketTransfer public Alias From { get; set; } /// - /// Target account. + /// Recepient account. /// Click on the field to expand more details. /// public Alias To { get; set; } /// - /// Amount of tickets transferred (raw value, not divided by `decimals`). + /// Amount of tickets transferred. /// **[sortable]** /// public string Amount { get; set; } @@ -49,12 +49,12 @@ public class TicketTransfer public long? TransactionId { get; set; } /// - /// Internal TzKT id of the transfer ticket operation, caused the ticket transfer. + /// Internal TzKT id of the transfer_ticket operation, caused the ticket transfer. /// public long? TransferTicketId { get; set; } /// - /// Internal TzKT id of the smart rollup execute operation, caused the ticket transfer. + /// Internal TzKT id of the smart_rollup_execute operation, caused the ticket transfer. /// public long? SmartRollupExecuteId { get; set; } } diff --git a/Tzkt.Api/Parameters/Binders/MichelineBinder.cs b/Tzkt.Api/Parameters/Binders/MichelineBinder.cs new file mode 100644 index 000000000..67789b7e4 --- /dev/null +++ b/Tzkt.Api/Parameters/Binders/MichelineBinder.cs @@ -0,0 +1,44 @@ +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace Tzkt.Api +{ + public class MichelineBinder : IModelBinder + { + public Task BindModelAsync(ModelBindingContext bindingContext) + { + var model = bindingContext.ModelName; + var hasValue = false; + + if (!bindingContext.TryGetMicheline($"{model}", ref hasValue, out var value)) + return Task.CompletedTask; + + if (!bindingContext.TryGetMicheline($"{model}.eq", ref hasValue, out var eq)) + return Task.CompletedTask; + + if (!bindingContext.TryGetMicheline($"{model}.ne", ref hasValue, out var ne)) + return Task.CompletedTask; + + if (!bindingContext.TryGetMichelineList($"{model}.in", ref hasValue, out var @in)) + return Task.CompletedTask; + + if (!bindingContext.TryGetMichelineList($"{model}.ni", ref hasValue, out var ni)) + return Task.CompletedTask; + + if (!hasValue) + { + bindingContext.Result = ModelBindingResult.Success(null); + return Task.CompletedTask; + } + + bindingContext.Result = ModelBindingResult.Success(new MichelineParameter + { + Eq = value ?? eq, + Ne = ne, + In = @in, + Ni = ni + }); + + return Task.CompletedTask; + } + } +} diff --git a/Tzkt.Api/Parameters/MichelineParameter.cs b/Tzkt.Api/Parameters/MichelineParameter.cs new file mode 100644 index 000000000..e11152880 --- /dev/null +++ b/Tzkt.Api/Parameters/MichelineParameter.cs @@ -0,0 +1,71 @@ +using System.Text; +using Microsoft.AspNetCore.Mvc; +using Netezos.Encoding; +using NJsonSchema.Annotations; + +namespace Tzkt.Api +{ + [ModelBinder(BinderType = typeof(MichelineBinder))] + [JsonSchemaExtensionData("x-tzkt-extension", "query-parameter")] + public class MichelineParameter : INormalizable + { + /// + /// **Equal** filter mode (optional, i.e. `param.eq=123` is the same as `param=123`). \ + /// Specify Micheline JSON value to get items where the specified field is equal to the specified value. + /// + /// Example: `?type={"prim":"string"}`. + /// + public IMicheline Eq { get; set; } + + /// + /// **Not equal** filter mode. \ + /// Specify Micheline JSON value to get items where the specified field is not equal to the specified value. + /// + /// Example: `?balance.ne={"prim":"string"}`. + /// + public IMicheline Ne { get; set; } + + /// + /// **In list** (any of) filter mode. \ + /// Specify a comma-separated list of Micheline JSON values where the specified field is equal to one of the specified values. + /// + /// Example: `?type.in={"prim":"string"},{"prim":"nat"}`. + /// + public List In { get; set; } + + /// + /// **Not in list** (none of) filter mode. \ + /// Specify a comma-separated list of Micheline JSON values where the specified field is not equal to all the specified values. + /// + /// Example: `?type.ni={"prim":"string"},{"prim":"nat"}`. + /// + public List Ni { get; set; } + + public string Normalize(string name) + { + var sb = new StringBuilder(); + + if (Eq != null) + { + sb.Append($"{name}.eq={Hex.Convert(Eq.ToBytes())}&"); + } + + if (Ne != null) + { + sb.Append($"{name}.ne={Hex.Convert(Ne.ToBytes())}&"); + } + + if (In?.Count > 0) + { + sb.Append($"{name}.in={string.Join(",", In.Select(x => Hex.Convert(x.ToBytes())).OrderBy(x => x))}&"); + } + + if (Ni?.Count > 0) + { + sb.Append($"{name}.ni={string.Join(",", Ni.Select(x => Hex.Convert(x.ToBytes())).OrderBy(x => x))}&"); + } + + return sb.ToString(); + } + } +} diff --git a/Tzkt.Api/Parameters/TicketBalanceFilter.cs b/Tzkt.Api/Parameters/TicketBalanceFilter.cs index 38c3d0304..c5bba356a 100644 --- a/Tzkt.Api/Parameters/TicketBalanceFilter.cs +++ b/Tzkt.Api/Parameters/TicketBalanceFilter.cs @@ -1,4 +1,5 @@ -using Tzkt.Api.Services; +using NSwag.Annotations; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -47,7 +48,7 @@ public class TicketBalanceFilter : INormalizable public TimestampParameter firstTime { get; set; } /// - /// Filter by level of the block where the balance was last seen. + /// Filter by level of the block where the balance was last changed. /// Click on the parameter to expand more details. /// public Int32Parameter lastLevel { get; set; } @@ -58,6 +59,7 @@ public class TicketBalanceFilter : INormalizable /// public TimestampParameter lastTime { get; set; } + [OpenApiIgnore] public bool Empty => id == null && (ticket == null || ticket.Empty) && diff --git a/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs b/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs index 269a6fd16..042a647ef 100644 --- a/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs +++ b/Tzkt.Api/Parameters/TicketBalanceShortFilter.cs @@ -1,4 +1,5 @@ -using Tzkt.Api.Services; +using NSwag.Annotations; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -28,6 +29,7 @@ public class TicketBalanceShortFilter : INormalizable /// public NatParameter balance { get; set; } + [OpenApiIgnore] public bool Empty => id == null && (ticket == null || ticket.Empty) && diff --git a/Tzkt.Api/Parameters/TicketFilter.cs b/Tzkt.Api/Parameters/TicketFilter.cs index 462caae0e..a06ea9184 100644 --- a/Tzkt.Api/Parameters/TicketFilter.cs +++ b/Tzkt.Api/Parameters/TicketFilter.cs @@ -1,4 +1,5 @@ -using Tzkt.Api.Services; +using NSwag.Annotations; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -17,21 +18,33 @@ public class TicketFilter : INormalizable public AccountParameter ticketer { get; set; } /// - /// Filter by content. + /// Filter by ticket content type in Micheline format. + /// Click on the parameter to expand more details. + /// + public MichelineParameter rawType { get; set; } + + /// + /// Filter by ticket content in Micheline format. + /// Click on the parameter to expand more details. + /// + public MichelineParameter rawContent { get; set; } + + /// + /// Filter by ticket content in JSON format. /// Note, this parameter supports the following format: `content{.path?}{.mode?}=...`, - /// so you can specify a path to a particular field to filter by (for example, `?content.in=red,green`). + /// so you can specify a path to a particular field to filter by (for example, `?content.color.in=red,green`). /// Click on the parameter to expand more details. /// public JsonParameter content { get; set; } /// - /// Filter by 32-bit hash of ticket content type (helpful for searching same tickets). + /// Filter by 32-bit hash of ticket content type. /// Click on the parameter to expand more details. /// public Int32Parameter typeHash { get; set; } /// - /// Filter by 32-bit hash of ticket content (helpful for searching similar tickets). + /// Filter by 32-bit hash of ticket content. /// Click on the parameter to expand more details. /// public Int32Parameter contentHash { get; set; } @@ -66,9 +79,12 @@ public class TicketFilter : INormalizable /// public TimestampParameter lastTime { get; set; } + [OpenApiIgnore] public bool Empty => id == null && ticketer == null && + rawType == null && + rawContent == null && content == null && typeHash == null && contentHash == null && @@ -81,9 +97,9 @@ public class TicketFilter : INormalizable public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("ticketer", ticketer), ("content", content), ("typeHash", typeHash), ("contentHash", contentHash), - ("firstMinter", firstMinter), ("firstLevel", firstLevel), ("firstTime", firstTime), ("lastLevel", lastLevel), - ("lastTime", lastTime)); + ("id", id), ("ticketer", ticketer), ("rawType", rawType), ("rawContent", rawContent), ("content", content), + ("typeHash", typeHash), ("contentHash", contentHash), ("firstMinter", firstMinter), ("firstLevel", firstLevel), + ("firstTime", firstTime), ("lastLevel", lastLevel), ("lastTime", lastTime)); } } } diff --git a/Tzkt.Api/Parameters/TicketInfoFilter.cs b/Tzkt.Api/Parameters/TicketInfoFilter.cs index c25194412..0c8defed4 100644 --- a/Tzkt.Api/Parameters/TicketInfoFilter.cs +++ b/Tzkt.Api/Parameters/TicketInfoFilter.cs @@ -1,4 +1,5 @@ -using Tzkt.Api.Services; +using NSwag.Annotations; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -16,6 +17,26 @@ public class TicketInfoFilter : INormalizable /// public AccountParameter ticketer { get; set; } + /// + /// Filter by ticket content type in Micheline format. + /// Click on the parameter to expand more details. + /// + public MichelineParameter rawType { get; set; } + + /// + /// Filter by ticket content in Micheline format. + /// Click on the parameter to expand more details. + /// + public MichelineParameter rawContent { get; set; } + + /// + /// Filter by ticket content in JSON format. + /// Note, this parameter supports the following format: `content{.path?}{.mode?}=...`, + /// so you can specify a path to a particular field to filter by (for example, `?content.color.in=red,green`). + /// Click on the parameter to expand more details. + /// + public JsonParameter content { get; set; } + /// /// Filter by 32-bit hash of ticket content type. /// Click on the parameter to expand more details. @@ -28,16 +49,21 @@ public class TicketInfoFilter : INormalizable /// public Int32Parameter contentHash { get; set; } + [OpenApiIgnore] public bool Empty => id == null && ticketer == null && + rawType == null && + rawContent == null && + content == null && typeHash == null && contentHash == null; public string Normalize(string name) { return ResponseCacheService.BuildKey("", - ("id", id), ("ticketer", ticketer), ("typeHash", typeHash), ("contentHash", contentHash)); + ("id", id), ("ticketer", ticketer), ("rawType", rawType), ("rawContent", rawContent), + ("content", content), ("typeHash", typeHash), ("contentHash", contentHash)); } } } diff --git a/Tzkt.Api/Parameters/TicketInfoShortFilter.cs b/Tzkt.Api/Parameters/TicketInfoShortFilter.cs index ec2beee47..0812f01d7 100644 --- a/Tzkt.Api/Parameters/TicketInfoShortFilter.cs +++ b/Tzkt.Api/Parameters/TicketInfoShortFilter.cs @@ -1,4 +1,5 @@ -using Tzkt.Api.Services; +using NSwag.Annotations; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -16,6 +17,7 @@ public class TicketInfoShortFilter : INormalizable /// public AccountParameter ticketer { get; set; } + [OpenApiIgnore] public bool Empty => id == null && ticketer == null; diff --git a/Tzkt.Api/Parameters/TicketTransferFilter.cs b/Tzkt.Api/Parameters/TicketTransferFilter.cs index a06bcc19b..ec026bd50 100644 --- a/Tzkt.Api/Parameters/TicketTransferFilter.cs +++ b/Tzkt.Api/Parameters/TicketTransferFilter.cs @@ -1,4 +1,5 @@ -using Tzkt.Api.Services; +using NSwag.Annotations; +using Tzkt.Api.Services; namespace Tzkt.Api { @@ -37,13 +38,13 @@ public class TicketTransferFilter : INormalizable public AnyOfParameter anyof { get; set; } /// - /// Filter by sender account address. + /// Filter by sender address. /// Click on the parameter to expand more details. /// public AccountParameter from { get; set; } /// - /// Filter by target account address. + /// Filter by recepient address. /// Click on the parameter to expand more details. /// public AccountParameter to { get; set; } @@ -61,17 +62,18 @@ public class TicketTransferFilter : INormalizable public Int64NullParameter transactionId { get; set; } /// - /// Filter by id of the transfer ticket operation, caused the ticket transfer. + /// Filter by id of the transfer_ticket operation, caused the ticket transfer. /// Click on the parameter to expand more details. /// public Int64NullParameter transferTicketId { get; set; } /// - /// Filter by id of the smart rollup execute operation, caused the ticket transfer. + /// Filter by id of the smart_rollup_execute operation, caused the ticket transfer. /// Click on the parameter to expand more details. /// public Int64NullParameter smartRollupExecuteId { get; set; } + [OpenApiIgnore] public bool Empty => id == null && level == null && diff --git a/Tzkt.Api/Repositories/TicketsRepository.cs b/Tzkt.Api/Repositories/TicketsRepository.cs index bdac3a23f..0714cdca5 100644 --- a/Tzkt.Api/Repositories/TicketsRepository.cs +++ b/Tzkt.Api/Repositories/TicketsRepository.cs @@ -68,6 +68,8 @@ async Task> QueryTicketsAsync(TicketFilter filter, Paginati var sql = new SqlBuilder($@"SELECT {select} FROM ""Tickets""") .Filter("Id", filter.id) .Filter("TicketerId", filter.ticketer) + .Filter("RawType", filter.rawType) + .Filter("RawContent", filter.rawContent) .Filter("JsonContent", filter.content) .Filter("TypeHash", filter.typeHash) .Filter("ContentHash", filter.contentHash) @@ -95,6 +97,8 @@ public async Task GetTicketsCount(TicketFilter filter) var sql = new SqlBuilder(@"SELECT COUNT(*) FROM ""Tickets""") .Filter("Id", filter.id) .Filter("TicketerId", filter.ticketer) + .Filter("RawType", filter.rawType) + .Filter("RawContent", filter.rawContent) .Filter("JsonContent", filter.content) .Filter("TypeHash", filter.typeHash) .Filter("ContentHash", filter.contentHash) @@ -335,13 +339,16 @@ async Task> QueryTicketBalancesAsync(TicketBalanceFilter fi .FilterA(@"tb.""LastLevel""", filter.lastTime) .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""RawType""", filter.ticket.rawType) + .FilterA(@"t.""RawContent""", filter.ticket.rawContent) + .FilterA(@"t.""JsonContent""", filter.ticket.content) .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) .Take(pagination, x => x switch { "balance" => (@"tb.""Balance""::numeric", @"tb.""Balance""::numeric"), "transfersCount" => (@"tb.""TransfersCount""", @"tb.""TransfersCount"""), - "firstLevel" => (@"tb.""Id""", @"tb.""FirstLevel"""), + "firstLevel" => (@"tb.""FirstLevel""", @"tb.""FirstLevel"""), "lastLevel" => (@"tb.""LastLevel""", @"tb.""LastLevel"""), _ => (@"tb.""Id""", @"tb.""Id""") }, @"tb.""Id"""); @@ -365,6 +372,9 @@ SELECT COUNT(*) FROM ""TicketBalances"" as tb .FilterA(@"tb.""LastLevel""", filter.lastTime) .FilterA(@"tb.""TicketId""", filter.ticket.id) .FilterA(@"tb.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""RawType""", filter.ticket.rawType) + .FilterA(@"t.""RawContent""", filter.ticket.rawContent) + .FilterA(@"t.""JsonContent""", filter.ticket.content) .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash); @@ -616,6 +626,9 @@ async Task> QueryTicketTransfersAsync(TicketTransferFilter .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""RawType""", filter.ticket.rawType) + .FilterA(@"t.""RawContent""", filter.ticket.rawContent) + .FilterA(@"t.""JsonContent""", filter.ticket.content) .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash) .Take(pagination, x => x switch @@ -646,6 +659,9 @@ SELECT COUNT(*) FROM ""TicketTransfers"" as tr .FilterA(@"tr.""SmartRollupExecuteId""", filter.smartRollupExecuteId) .FilterA(@"tr.""TicketId""", filter.ticket.id) .FilterA(@"tr.""TicketerId""", filter.ticket.ticketer) + .FilterA(@"t.""RawType""", filter.ticket.rawType) + .FilterA(@"t.""RawContent""", filter.ticket.rawContent) + .FilterA(@"t.""JsonContent""", filter.ticket.content) .FilterA(@"t.""TypeHash""", filter.ticket.typeHash) .FilterA(@"t.""ContentHash""", filter.ticket.contentHash); diff --git a/Tzkt.Api/Utils/RawJson.cs b/Tzkt.Api/Utils/RawJson.cs index 377f06c0b..00beb536a 100644 --- a/Tzkt.Api/Utils/RawJson.cs +++ b/Tzkt.Api/Utils/RawJson.cs @@ -1,10 +1,11 @@ -using System; -using System.Text.Json; +using System.Text.Json; using System.Text.Json.Serialization; +using NJsonSchema.Annotations; namespace Tzkt.Api { [JsonConverter(typeof(RawJsonConverter))] + [JsonSchemaType(typeof(object), IsNullable = true)] public class RawJson { string Json { get; } diff --git a/Tzkt.Api/Utils/SqlBuilder.cs b/Tzkt.Api/Utils/SqlBuilder.cs index 86b00bb46..237a6ee82 100644 --- a/Tzkt.Api/Utils/SqlBuilder.cs +++ b/Tzkt.Api/Utils/SqlBuilder.cs @@ -4,6 +4,7 @@ using System.Text; using System.Text.RegularExpressions; using Dapper; +using Netezos.Encoding; using Tzkt.Api.Utils; namespace Tzkt.Api @@ -1626,6 +1627,44 @@ public SqlBuilder FilterA(string column, BoolParameter value, Func map = null) + { + if (value == null) return this; + + if (value.Eq != null) + AppendFilter($@"""{column}"" = {Param(value.Eq.ToBytes())}"); + + if (value.Ne != null) + AppendFilter($@"""{column}"" != {Param(value.Ne.ToBytes())}"); + + if (value.In != null) + AppendFilter($@"""{column}"" = ANY ({Param(value.In.Select(x => x.ToBytes()).ToArray())})"); + + if (value.Ni != null) + AppendFilter($@"NOT (""{column}"" = ANY ({Param(value.Ni.Select(x => x.ToBytes()).ToArray())}))"); + + return this; + } + + public SqlBuilder FilterA(string column, MichelineParameter value, Func map = null) + { + if (value == null) return this; + + if (value.Eq != null) + AppendFilter($"{column} = {Param(value.Eq.ToBytes())}"); + + if (value.Ne != null) + AppendFilter($"{column} != {Param(value.Ne.ToBytes())}"); + + if (value.In != null) + AppendFilter($"{column} = ANY ({Param(value.In.Select(x => x.ToBytes()).ToArray())})"); + + if (value.Ni != null) + AppendFilter($"NOT ({column} = ANY ({Param(value.Ni.Select(x => x.ToBytes()).ToArray())}))"); + + return this; + } + public SqlBuilder Filter(string column, DateTimeParameter value, Func map = null) { if (value == null) return this;