diff --git a/src/RadixDlt.CoreApiSdk/Model/TypeInfoModuleFieldTypeInfoSubstate.cs b/src/RadixDlt.CoreApiSdk/Model/TypeInfoModuleFieldTypeInfoSubstate.cs index 32050791a..521441d0f 100644 --- a/src/RadixDlt.CoreApiSdk/Model/TypeInfoModuleFieldTypeInfoSubstate.cs +++ b/src/RadixDlt.CoreApiSdk/Model/TypeInfoModuleFieldTypeInfoSubstate.cs @@ -63,6 +63,7 @@ */ using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; namespace RadixDlt.CoreApiSdk.Model; @@ -78,4 +79,30 @@ public IEnumerable GetEntityAddresses() return Enumerable.Empty(); } + + public bool TryGetObjectInstanceSchema([NotNullWhen(true)] out InstanceSchema instanceSchema) + { + instanceSchema = null; + + if (Value.Details is ObjectTypeInfoDetails objectTypeInfoDetails && objectTypeInfoDetails.InstanceSchema != null) + { + instanceSchema = objectTypeInfoDetails.InstanceSchema; + return true; + } + + return false; + } + + public bool TryGetKeyValueStoreSchema([NotNullWhen(true)] out KeyValueStoreSchema keyValueStoreSchema) + { + keyValueStoreSchema = null; + + if (Value.Details is KeyValueStoreTypeInfoDetails keyValueStoreTypeInfoDetails && keyValueStoreTypeInfoDetails.KeyValueStoreInfo.KvStoreSchema != null) + { + keyValueStoreSchema = keyValueStoreTypeInfoDetails.KeyValueStoreInfo.KvStoreSchema; + return true; + } + + return false; + } } diff --git a/src/RadixDlt.NetworkGateway.Abstractions/Model/Extensions.cs b/src/RadixDlt.NetworkGateway.Abstractions/Model/Extensions.cs index 2d6b91f17..3ec6a56ed 100644 --- a/src/RadixDlt.NetworkGateway.Abstractions/Model/Extensions.cs +++ b/src/RadixDlt.NetworkGateway.Abstractions/Model/Extensions.cs @@ -81,12 +81,12 @@ public static ObjectModuleId ToInternalModel(this CoreModel.ObjectModuleId objec }; } - public static KeyTypeKind ToInternalModel(this CoreModel.LocalTypeIndex.KindEnum indexKind) + public static SborTypeKind ToInternalModel(this CoreModel.LocalTypeIndex.KindEnum indexKind) { return indexKind switch { - CoreModel.LocalTypeIndex.KindEnum.SchemaLocal => KeyTypeKind.SchemaLocal, - CoreModel.LocalTypeIndex.KindEnum.WellKnown => KeyTypeKind.WellKnown, + CoreModel.LocalTypeIndex.KindEnum.SchemaLocal => SborTypeKind.SchemaLocal, + CoreModel.LocalTypeIndex.KindEnum.WellKnown => SborTypeKind.WellKnown, _ => throw new UnreachableException($"Didn't expect {indexKind} value"), }; } diff --git a/src/RadixDlt.NetworkGateway.Abstractions/Model/KeyTypeKind.cs b/src/RadixDlt.NetworkGateway.Abstractions/Model/SborTypeKind.cs similarity index 99% rename from src/RadixDlt.NetworkGateway.Abstractions/Model/KeyTypeKind.cs rename to src/RadixDlt.NetworkGateway.Abstractions/Model/SborTypeKind.cs index d1024da2d..09608fa7d 100644 --- a/src/RadixDlt.NetworkGateway.Abstractions/Model/KeyTypeKind.cs +++ b/src/RadixDlt.NetworkGateway.Abstractions/Model/SborTypeKind.cs @@ -64,7 +64,7 @@ namespace RadixDlt.NetworkGateway.Abstractions.Model; -public enum KeyTypeKind +public enum SborTypeKind { WellKnown, SchemaLocal, diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index e9ab0ee91..dc5c09faa 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -897,11 +897,11 @@ components: type: object required: - raw_hex - - json + - programmatic_json properties: raw_hex: type: string - json: + programmatic_json: type: object EntityMetadataCollection: diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs index 4dcf71337..56f40e6f8 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs @@ -169,7 +169,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.HasPostgresEnum(); modelBuilder.HasPostgresEnum(); modelBuilder.HasPostgresEnum(); - modelBuilder.HasPostgresEnum(); + modelBuilder.HasPostgresEnum(); HookupTransactions(modelBuilder); HookupPendingTransactions(modelBuilder); @@ -362,7 +362,7 @@ private static void HookupHistory(ModelBuilder modelBuilder) .HasIndex(e => new { e.EntityId, e.FromStateVersion }); modelBuilder.Entity() - .HasIndex(e => new { e.EntityId, e.FromStateVersion }); + .HasIndex(e => new { EntityId = e.ValidatorEntityId, e.FromStateVersion }); modelBuilder.Entity() .HasIndex(e => new { e.PackageEntityId, e.FromStateVersion }); @@ -392,7 +392,7 @@ private static void HookupHistory(ModelBuilder modelBuilder) .HasIndex(e => new { e.KeyValueStoreEntityId, e.Key, e.FromStateVersion }); modelBuilder.Entity() - .HasIndex(e => new { e.EntityId, e.FromStateVersion }); + .HasIndex(e => new { EntityId = e.KeyValueStoreEntityId, e.FromStateVersion }); modelBuilder.Entity() .HasIndex(e => new { e.EntityId, e.FromStateVersion }); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/CustomTypes.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/CustomTypes.cs index 1a59bf3ec..816b6d5b9 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/CustomTypes.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/CustomTypes.cs @@ -108,7 +108,7 @@ public static void EnsureConfigured() NpgsqlConnection.GlobalTypeMapper.MapEnum(); NpgsqlConnection.GlobalTypeMapper.MapEnum(); NpgsqlConnection.GlobalTypeMapper.MapEnum(); - NpgsqlConnection.GlobalTypeMapper.MapEnum(); + NpgsqlConnection.GlobalTypeMapper.MapEnum(); #pragma warning restore CS0618 _configured = true; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index af97c8772..91ef59df1 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -548,25 +548,6 @@ private async Task ProcessTransactions(ReadWriteDbContext db ledgerTransaction.CreatedTimestamp = summary.CreatedTimestamp; ledgerTransaction.NormalizedRoundTimestamp = summary.NormalizedRoundTimestamp; ledgerTransaction.RawPayload = committedTransaction.LedgerTransaction.GetUnwrappedPayloadBytes(); - - var eventsTuple = committedTransaction.Receipt.Events? - .Select(x => - { - if (x.Type.TypePointer is not CoreModel.PackageTypePointer packageTypePointer) - { - throw new UnreachableException("All events are expected to be package type pointer."); - } - - return new - { - typeIndex = packageTypePointer.LocalTypeIndex.Index, - typeKind = packageTypePointer.LocalTypeIndex.Kind.ToInternalModel(), - schemaHash = packageTypePointer.SchemaHash.ConvertFromHex(), - data = x.Data.GetDataBytes(), - }; - }) - .ToArray(); - ledgerTransaction.EngineReceipt = new TransactionReceipt { StateUpdates = committedTransaction.Receipt.StateUpdates.ToJson(), @@ -575,10 +556,18 @@ private async Task ProcessTransactions(ReadWriteDbContext db ErrorMessage = committedTransaction.Receipt.ErrorMessage, Output = committedTransaction.Receipt.Output != null ? JsonConvert.SerializeObject(committedTransaction.Receipt.Output) : null, NextEpoch = committedTransaction.Receipt.NextEpoch?.ToJson(), - EventsSbor = eventsTuple?.Select(x => x.data).ToArray(), - EventsSchemaHash = eventsTuple?.Select(x => x.schemaHash).ToArray(), - EventsTypeIndex = eventsTuple?.Select(x => x.typeIndex).ToArray(), - EventsTypeKind = eventsTuple?.Select(x => x.typeKind).ToArray(), + EventsSbor = committedTransaction.Receipt.Events != null ? + committedTransaction.Receipt.Events.Select(x => x.Data.GetDataBytes()).ToArray() + : Array.Empty(), + EventsSchemaHash = committedTransaction.Receipt.Events != null ? + committedTransaction.Receipt.Events.Select(x => ((CoreModel.PackageTypePointer)x.Type.TypePointer).SchemaHash.ConvertFromHex()).ToArray() + : Array.Empty(), + EventsTypeIndex = committedTransaction.Receipt.Events != null ? + committedTransaction.Receipt.Events.Select(x => ((CoreModel.PackageTypePointer)x.Type.TypePointer).LocalTypeIndex.Index).ToArray() + : Array.Empty(), + EventsSborTypeKind = committedTransaction.Receipt.Events != null ? + committedTransaction.Receipt.Events.Select(x => ((CoreModel.PackageTypePointer)x.Type.TypePointer).LocalTypeIndex.Kind.ToInternalModel()).ToArray().ToArray() + : Array.Empty(), }; ledgerTransactionsToAdd.Add(ledgerTransaction); @@ -895,7 +884,7 @@ private async Task ProcessTransactions(ReadWriteDbContext db { Id = sequences.ValidatorStateHistorySequence++, FromStateVersion = stateVersion, - EntityId = referencedEntities.Get((EntityAddress)substateId.EntityAddress).DatabaseId, + ValidatorEntityId = referencedEntities.Get((EntityAddress)substateId.EntityAddress).DatabaseId, State = validator.Value.ToJson(), }); } @@ -1075,9 +1064,9 @@ private async Task ProcessTransactions(ReadWriteDbContext db if (substateData is CoreModel.TypeInfoModuleFieldTypeInfoSubstate typeInfoSubstate) { - if (typeInfoSubstate.Value.Details is CoreModel.ObjectTypeInfoDetails { InstanceSchema: not null } objectTypeInfoDetails) + if (typeInfoSubstate.TryGetObjectInstanceSchema(out var instanceSchema)) { - if (objectTypeInfoDetails.InstanceSchema.ProvidedTypes.Count != 1) + if (instanceSchema.ProvidedTypes.Count != 1) { throw new NotSupportedException("Expected non fungible data with only one data type entry."); } @@ -1087,24 +1076,24 @@ private async Task ProcessTransactions(ReadWriteDbContext db Id = sequences.NonFungibleDataSchemaHistorySequence++, FromStateVersion = stateVersion, EntityId = referencedEntity.DatabaseId, - Schema = objectTypeInfoDetails.InstanceSchema.Schema.SborData.Hex.ConvertFromHex(), - TypeKind = objectTypeInfoDetails.InstanceSchema.ProvidedTypes[0].Kind.ToInternalModel(), - TypeIndex = objectTypeInfoDetails.InstanceSchema.ProvidedTypes[0].Index, + Schema = instanceSchema.Schema.SborData.Hex.ConvertFromHex(), + SborTypeKind = instanceSchema.ProvidedTypes[0].Kind.ToInternalModel(), + TypeIndex = instanceSchema.ProvidedTypes[0].Index, }); } - if (typeInfoSubstate.Value.Details is CoreModel.KeyValueStoreTypeInfoDetails { KeyValueStoreInfo.KvStoreSchema.Schema: not null } kvStoreSchema ) + if (typeInfoSubstate.TryGetKeyValueStoreSchema(out var keyValueStoreSchema)) { keyVaulueStoreSchemaHistoryToAdd.Add(new KeyValueStoreSchemaHistory { Id = sequences.NonFungibleDataSchemaHistorySequence++, FromStateVersion = stateVersion, - EntityId = referencedEntity.DatabaseId, - Schema = kvStoreSchema.KeyValueStoreInfo.KvStoreSchema.Schema.SborData.Hex.ConvertFromHex(), - KeyTypeKind = kvStoreSchema.KeyValueStoreInfo.KvStoreSchema.KeyType.Kind.ToInternalModel(), - KeyTypeIndex = kvStoreSchema.KeyValueStoreInfo.KvStoreSchema.KeyType.Index, - ValueTypeKind = kvStoreSchema.KeyValueStoreInfo.KvStoreSchema.ValueType.Kind.ToInternalModel(), - ValueTypeIndex = kvStoreSchema.KeyValueStoreInfo.KvStoreSchema.ValueType.Index, + KeyValueStoreEntityId = referencedEntity.DatabaseId, + Schema = keyValueStoreSchema.Schema.SborData.Hex.ConvertFromHex(), + KeySborTypeKind = keyValueStoreSchema.KeyType.Kind.ToInternalModel(), + KeyTypeIndex = keyValueStoreSchema.KeyType.Index, + ValueSborTypeKind = keyValueStoreSchema.ValueType.Kind.ToInternalModel(), + ValueTypeIndex = keyValueStoreSchema.ValueType.Index, }); } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs index 629e675fe..8acb93ad5 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs @@ -179,7 +179,7 @@ public async Task CopyLedgerTransaction(ICollection enti return 0; } - await using var writer = await _connection.BeginBinaryImportAsync("COPY ledger_transactions (state_version, message, epoch, round_in_epoch, index_in_epoch, index_in_round, is_end_of_epoch, fee_paid, tip_paid, affected_global_entities, round_timestamp, created_timestamp, normalized_round_timestamp, raw_payload, receipt_state_updates, receipt_status, receipt_fee_summary, receipt_error_message, receipt_output, receipt_next_epoch, receipt_events_sbor, receipt_events_schema_hash, receipt_events_type_index, receipt_events_type_kind, discriminator, payload_hash, intent_hash, signed_intent_hash) FROM STDIN (FORMAT BINARY)", token); + await using var writer = await _connection.BeginBinaryImportAsync("COPY ledger_transactions (state_version, message, epoch, round_in_epoch, index_in_epoch, index_in_round, is_end_of_epoch, fee_paid, tip_paid, affected_global_entities, round_timestamp, created_timestamp, normalized_round_timestamp, raw_payload, receipt_state_updates, receipt_status, receipt_fee_summary, receipt_error_message, receipt_output, receipt_next_epoch, receipt_events_sbor, receipt_events_schema_hash, receipt_events_type_index, receipt_events_sbor_type_kind, discriminator, payload_hash, intent_hash, signed_intent_hash) FROM STDIN (FORMAT BINARY)", token); foreach (var lt in entities) { @@ -210,7 +210,7 @@ public async Task CopyLedgerTransaction(ICollection enti await writer.WriteAsync(lt.EngineReceipt.EventsSbor, NpgsqlDbType.Array | NpgsqlDbType.Bytea, token); await writer.WriteAsync(lt.EngineReceipt.EventsSchemaHash, NpgsqlDbType.Array | NpgsqlDbType.Bytea, token); await writer.WriteAsync(lt.EngineReceipt.EventsTypeIndex, NpgsqlDbType.Array | NpgsqlDbType.Integer, token); - await writer.WriteAsync(lt.EngineReceipt.EventsTypeKind, "key_type_kind[]", token); + await writer.WriteAsync(lt.EngineReceipt.EventsSborTypeKind, "sbor_type_kind[]", token); await writer.WriteAsync(discriminator, "ledger_transaction_type", token); switch (lt) @@ -431,14 +431,14 @@ public async Task CopyValidatorStateHistory(ICollection CopyNonFungibleDataSchemaHistory(ICollection CopyNonFungibleDataSchemaHistory(ICollection CopyKeyValueStoreSchemaHistory(ICollection @@ -95,7 +95,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "account_default_deposit_rule", new[] { "accept", "reject", "allow_existing" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "account_resource_deposit_rule", new[] { "neither", "allowed", "disallowed" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "global_consensus_manager", "global_fungible_resource", "global_non_fungible_resource", "global_generic_component", "internal_generic_component", "global_account_component", "internal_account_component", "global_package", "internal_key_value_store", "internal_fungible_vault", "internal_non_fungible_vault", "global_validator", "global_access_controller", "global_identity", "global_one_resource_pool", "global_two_resource_pool", "global_multi_resource_pool", "global_transaction_tracker" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "key_type_kind", new[] { "well_known", "schema_local" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_event_type", new[] { "withdrawal", "deposit" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_operation_type", new[] { "resource_in_use", "account_deposited_into", "account_withdrawn_from" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_origin_type", new[] { "user", "epoch_change" }); @@ -108,6 +107,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "pending_transaction_status", new[] { "submitted_or_known_in_node_mempool", "missing", "rejected_temporarily", "rejected_permanently", "committed_success", "committed_failure" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "public_key_type", new[] { "ecdsa_secp256k1", "eddsa_ed25519" }); NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "resource_type", new[] { "fungible", "non_fungible" }); + NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "sbor_type_kind", new[] { "well_known", "schema_local" }); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountDefaultDepositRuleHistory", b => @@ -684,38 +684,38 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - b.Property("FromStateVersion") .HasColumnType("bigint") .HasColumnName("from_state_version"); + b.Property("KeySborTypeKind") + .HasColumnType("sbor_type_kind") + .HasColumnName("key_sbor_type_kind"); + b.Property("KeyTypeIndex") .HasColumnType("integer") .HasColumnName("key_type_index"); - b.Property("KeyTypeKind") - .HasColumnType("key_type_kind") - .HasColumnName("key_type_kind"); + b.Property("KeyValueStoreEntityId") + .HasColumnType("bigint") + .HasColumnName("key_value_store_entity_id"); b.Property("Schema") .IsRequired() .HasColumnType("bytea") .HasColumnName("schema"); + b.Property("ValueSborTypeKind") + .HasColumnType("sbor_type_kind") + .HasColumnName("value_sbor_type_kind"); + b.Property("ValueTypeIndex") .HasColumnType("integer") .HasColumnName("value_type_index"); - b.Property("ValueTypeKind") - .HasColumnType("key_type_kind") - .HasColumnName("value_type_kind"); - b.HasKey("Id"); - b.HasIndex("EntityId", "FromStateVersion"); + b.HasIndex("KeyValueStoreEntityId", "FromStateVersion"); b.ToTable("key_value_store_schema_history"); }); @@ -885,6 +885,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("bigint") .HasColumnName("from_state_version"); + b.Property("SborTypeKind") + .HasColumnType("sbor_type_kind") + .HasColumnName("sbor_type_kind"); + b.Property("Schema") .IsRequired() .HasColumnType("bytea") @@ -894,10 +898,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("integer") .HasColumnName("type_index"); - b.Property("TypeKind") - .HasColumnType("key_type_kind") - .HasColumnName("type_kind"); - b.HasKey("Id"); b.HasIndex("EntityId", "FromStateVersion"); @@ -1371,10 +1371,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - b.Property("FromStateVersion") .HasColumnType("bigint") .HasColumnName("from_state_version"); @@ -1384,9 +1380,13 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("jsonb") .HasColumnName("state"); + b.Property("ValidatorEntityId") + .HasColumnType("bigint") + .HasColumnName("validator_entity_id"); + b.HasKey("Id"); - b.HasIndex("EntityId", "FromStateVersion"); + b.HasIndex("ValidatorEntityId", "FromStateVersion"); b.ToTable("validator_state_history"); }); @@ -1984,21 +1984,25 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnName("receipt_error_message"); b1.Property("EventsSbor") + .IsRequired() .HasColumnType("bytea[]") .HasColumnName("receipt_events_sbor"); + b1.Property("EventsSborTypeKind") + .IsRequired() + .HasColumnType("sbor_type_kind[]") + .HasColumnName("receipt_events_sbor_type_kind"); + b1.Property("EventsSchemaHash") + .IsRequired() .HasColumnType("bytea[]") .HasColumnName("receipt_events_schema_hash"); b1.Property("EventsTypeIndex") + .IsRequired() .HasColumnType("integer[]") .HasColumnName("receipt_events_type_index"); - b1.Property("EventsTypeKind") - .HasColumnType("key_type_kind[]") - .HasColumnName("receipt_events_type_kind"); - b1.Property("FeeSummary") .IsRequired() .HasColumnType("jsonb") diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20230727115506_InitialCreate.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20230728093452_InitialCreate.cs similarity index 97% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20230727115506_InitialCreate.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20230728093452_InitialCreate.cs index 3d6391990..1af06c7cf 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20230727115506_InitialCreate.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20230728093452_InitialCreate.cs @@ -85,7 +85,6 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:Enum:account_default_deposit_rule", "accept,reject,allow_existing") .Annotation("Npgsql:Enum:account_resource_deposit_rule", "neither,allowed,disallowed") .Annotation("Npgsql:Enum:entity_type", "global_consensus_manager,global_fungible_resource,global_non_fungible_resource,global_generic_component,internal_generic_component,global_account_component,internal_account_component,global_package,internal_key_value_store,internal_fungible_vault,internal_non_fungible_vault,global_validator,global_access_controller,global_identity,global_one_resource_pool,global_two_resource_pool,global_multi_resource_pool,global_transaction_tracker") - .Annotation("Npgsql:Enum:key_type_kind", "well_known,schema_local") .Annotation("Npgsql:Enum:ledger_transaction_marker_event_type", "withdrawal,deposit") .Annotation("Npgsql:Enum:ledger_transaction_marker_operation_type", "resource_in_use,account_deposited_into,account_withdrawn_from") .Annotation("Npgsql:Enum:ledger_transaction_marker_origin_type", "user,epoch_change") @@ -97,7 +96,8 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:Enum:package_vm_type", "native,scrypto_v1") .Annotation("Npgsql:Enum:pending_transaction_status", "submitted_or_known_in_node_mempool,missing,rejected_temporarily,rejected_permanently,committed_success,committed_failure") .Annotation("Npgsql:Enum:public_key_type", "ecdsa_secp256k1,eddsa_ed25519") - .Annotation("Npgsql:Enum:resource_type", "fungible,non_fungible"); + .Annotation("Npgsql:Enum:resource_type", "fungible,non_fungible") + .Annotation("Npgsql:Enum:sbor_type_kind", "well_known,schema_local"); migrationBuilder.CreateTable( name: "account_default_deposit_rule_history", @@ -376,11 +376,11 @@ protected override void Up(MigrationBuilder migrationBuilder) id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), from_state_version = table.Column(type: "bigint", nullable: false), - entity_id = table.Column(type: "bigint", nullable: false), + key_value_store_entity_id = table.Column(type: "bigint", nullable: false), schema = table.Column(type: "bytea", nullable: false), - key_type_kind = table.Column(type: "key_type_kind", nullable: false), + key_sbor_type_kind = table.Column(type: "sbor_type_kind", nullable: false), key_type_index = table.Column(type: "integer", nullable: false), - value_type_kind = table.Column(type: "key_type_kind", nullable: false), + value_sbor_type_kind = table.Column(type: "sbor_type_kind", nullable: false), value_type_index = table.Column(type: "integer", nullable: false) }, constraints: table => @@ -432,10 +432,10 @@ protected override void Up(MigrationBuilder migrationBuilder) receipt_next_epoch = table.Column(type: "jsonb", nullable: true), receipt_output = table.Column(type: "jsonb", nullable: true), receipt_error_message = table.Column(type: "text", nullable: true), - receipt_events_sbor = table.Column(type: "bytea[]", nullable: true), - receipt_events_schema_hash = table.Column(type: "bytea[]", nullable: true), - receipt_events_type_index = table.Column(type: "integer[]", nullable: true), - receipt_events_type_kind = table.Column(type: "key_type_kind[]", nullable: true), + receipt_events_sbor = table.Column(type: "bytea[]", nullable: false), + receipt_events_schema_hash = table.Column(type: "bytea[]", nullable: false), + receipt_events_type_index = table.Column(type: "integer[]", nullable: false), + receipt_events_sbor_type_kind = table.Column(type: "sbor_type_kind[]", nullable: false), discriminator = table.Column(type: "ledger_transaction_type", nullable: false), payload_hash = table.Column(type: "bytea", nullable: true), intent_hash = table.Column(type: "bytea", nullable: true), @@ -473,7 +473,7 @@ protected override void Up(MigrationBuilder migrationBuilder) from_state_version = table.Column(type: "bigint", nullable: false), entity_id = table.Column(type: "bigint", nullable: false), schema = table.Column(type: "bytea", nullable: false), - type_kind = table.Column(type: "key_type_kind", nullable: false), + sbor_type_kind = table.Column(type: "sbor_type_kind", nullable: false), type_index = table.Column(type: "integer", nullable: false) }, constraints: table => @@ -666,7 +666,7 @@ protected override void Up(MigrationBuilder migrationBuilder) id = table.Column(type: "bigint", nullable: false) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), from_state_version = table.Column(type: "bigint", nullable: false), - entity_id = table.Column(type: "bigint", nullable: false), + validator_entity_id = table.Column(type: "bigint", nullable: false), state = table.Column(type: "jsonb", nullable: false) }, constraints: table => @@ -782,9 +782,9 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: new[] { "key_value_store_entity_id", "key", "from_state_version" }); migrationBuilder.CreateIndex( - name: "IX_key_value_store_schema_history_entity_id_from_state_version", + name: "IX_key_value_store_schema_history_key_value_store_entity_id_fr~", table: "key_value_store_schema_history", - columns: new[] { "entity_id", "from_state_version" }); + columns: new[] { "key_value_store_entity_id", "from_state_version" }); migrationBuilder.CreateIndex( name: "IX_ledger_transaction_markers_entity_id_state_version", @@ -922,9 +922,9 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: new[] { "validator_entity_id", "key_type", "key" }); migrationBuilder.CreateIndex( - name: "IX_validator_state_history_entity_id_from_state_version", + name: "IX_validator_state_history_validator_entity_id_from_state_vers~", table: "validator_state_history", - columns: new[] { "entity_id", "from_state_version" }); + columns: new[] { "validator_entity_id", "from_state_version" }); } /// diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs deleted file mode 100644 index aac645a80..000000000 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs +++ /dev/null @@ -1,2046 +0,0 @@ -/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands). - * - * Licensed under the Radix License, Version 1.0 (the "License"); you may not use this - * file except in compliance with the License. You may obtain a copy of the License at: - * - * radixfoundation.org/licenses/LICENSE-v1 - * - * The Licensor hereby grants permission for the Canonical version of the Work to be - * published, distributed and used under or by reference to the Licensor’s trademark - * Radix ® and use of any unregistered trade names, logos or get-up. - * - * The Licensor provides the Work (and each Contributor provides its Contributions) on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, - * including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, - * MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. - * - * Whilst the Work is capable of being deployed, used and adopted (instantiated) to create - * a distributed ledger it is your responsibility to test and validate the code, together - * with all logic and performance of that code under all foreseeable scenarios. - * - * The Licensor does not make or purport to make and hereby excludes liability for all - * and any representation, warranty or undertaking in any form whatsoever, whether express - * or implied, to any entity or person, including any representation, warranty or - * undertaking, as to the functionality security use, value or other characteristics of - * any distributed ledger nor in respect the functioning or value of any tokens which may - * be created stored or transferred using the Work. The Licensor does not warrant that the - * Work or any use of the Work complies with any law or regulation in any territory where - * it may be implemented or used or that it will be appropriate for any specific purpose. - * - * Neither the licensor nor any current or former employees, officers, directors, partners, - * trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor - * shall be liable for any direct or indirect, special, incidental, consequential or other - * losses of any kind, in tort, contract or otherwise (including but not limited to loss - * of revenue, income or profits, or loss of use or data, or loss of reputation, or loss - * of any economic or other opportunity of whatsoever nature or howsoever arising), arising - * out of or in connection with (without limitation of any use, misuse, of any ledger system - * or use made or its functionality or any performance or operation of any code or protocol - * caused by bugs or programming or logic errors or otherwise); - * - * A. any offer, purchase, holding, use, sale, exchange or transmission of any - * cryptographic keys, tokens or assets created, exchanged, stored or arising from any - * interaction with the Work; - * - * B. any failure in a transmission or loss of any token or assets keys or other digital - * artefacts due to errors in transmission; - * - * C. bugs, hacks, logic errors or faults in the Work or any communication; - * - * D. system software or apparatus including but not limited to losses caused by errors - * in holding or transmitting tokens by any third-party; - * - * E. breaches or failure of security including hacker attacks, loss or disclosure of - * password, loss of private key, unauthorised use or misuse of such passwords or keys; - * - * F. any losses including loss of anticipated savings or other benefits resulting from - * use of the Work or any changes to the Work (however implemented). - * - * You are solely responsible for; testing, validating and evaluation of all operation - * logic, functionality, security and appropriateness of using the Work for any commercial - * or non-commercial purpose and for any reproduction or redistribution by You of the - * Work. You assume all risks associated with Your use of the Work and the exercise of - * permissions under this License. - */ - -// -using System; -using System.Collections.Generic; -using System.Numerics; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; -using RadixDlt.NetworkGateway.Abstractions.Addressing; -using RadixDlt.NetworkGateway.Abstractions.Model; -using RadixDlt.NetworkGateway.PostgresIntegration; -using RadixDlt.NetworkGateway.PostgresIntegration.Models; - -#nullable disable - -namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations -{ - [DbContext(typeof(MigrationsDbContext))] - partial class MigrationsDbContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.9") - .HasAnnotation("Relational:MaxIdentifierLength", 63); - - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "account_default_deposit_rule", new[] { "accept", "reject", "allow_existing" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "account_resource_deposit_rule", new[] { "neither", "allowed", "disallowed" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "entity_type", new[] { "global_consensus_manager", "global_fungible_resource", "global_non_fungible_resource", "global_generic_component", "internal_generic_component", "global_account_component", "internal_account_component", "global_package", "internal_key_value_store", "internal_fungible_vault", "internal_non_fungible_vault", "global_validator", "global_access_controller", "global_identity", "global_one_resource_pool", "global_two_resource_pool", "global_multi_resource_pool", "global_transaction_tracker" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "key_type_kind", new[] { "well_known", "schema_local" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_event_type", new[] { "withdrawal", "deposit" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_operation_type", new[] { "resource_in_use", "account_deposited_into", "account_withdrawn_from" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_origin_type", new[] { "user", "epoch_change" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_marker_type", new[] { "origin", "event", "manifest_address", "affected_global_entity" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_status", new[] { "succeeded", "failed" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "ledger_transaction_type", new[] { "genesis", "user", "round_update" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "non_fungible_id_type", new[] { "string", "integer", "bytes", "ruid" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "object_module_id", new[] { "main", "metadata", "royalty", "access_rules" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "package_vm_type", new[] { "native", "scrypto_v1" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "pending_transaction_status", new[] { "submitted_or_known_in_node_mempool", "missing", "rejected_temporarily", "rejected_permanently", "committed_success", "committed_failure" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "public_key_type", new[] { "ecdsa_secp256k1", "eddsa_ed25519" }); - NpgsqlModelBuilderExtensions.HasPostgresEnum(modelBuilder, "resource_type", new[] { "fungible", "non_fungible" }); - NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountDefaultDepositRuleHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountEntityId") - .HasColumnType("bigint") - .HasColumnName("account_entity_id"); - - b.Property("DefaultDepositRule") - .HasColumnType("account_default_deposit_rule") - .HasColumnName("default_deposit_rule"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.HasKey("Id"); - - b.HasIndex("AccountEntityId", "FromStateVersion"); - - b.ToTable("account_default_deposit_rule_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AccountResourceDepositRuleHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AccountEntityId") - .HasColumnType("bigint") - .HasColumnName("account_entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("ResourceDepositRule") - .HasColumnType("account_resource_deposit_rule") - .HasColumnName("deposit_rule"); - - b.Property("ResourceEntityId") - .HasColumnType("bigint") - .HasColumnName("resource_entity_id"); - - b.HasKey("Id"); - - b.HasIndex("AccountEntityId", "ResourceEntityId", "FromStateVersion"); - - b.ToTable("account_resource_deposit_rule_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ComponentMethodRoyaltyEntryHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("IsLocked") - .HasColumnType("boolean") - .HasColumnName("is_locked"); - - b.Property("MethodName") - .IsRequired() - .HasColumnType("text") - .HasColumnName("method_name"); - - b.Property("RoyaltyAmount") - .HasColumnType("jsonb") - .HasColumnName("royalty_amount"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.HasIndex("EntityId", "MethodName", "FromStateVersion"); - - b.ToTable("component_method_royalty_entry_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Address") - .IsRequired() - .HasColumnType("text") - .HasColumnName("address"); - - b.Property>("AncestorIds") - .HasColumnType("bigint[]") - .HasColumnName("ancestor_ids"); - - b.Property>("CorrelatedEntities") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("correlated_entities"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("GlobalAncestorId") - .HasColumnType("bigint") - .HasColumnName("global_ancestor_id"); - - b.Property("IsGlobal") - .HasColumnType("boolean") - .HasColumnName("is_global"); - - b.Property("OwnerAncestorId") - .HasColumnType("bigint") - .HasColumnName("owner_ancestor_id"); - - b.Property("ParentAncestorId") - .HasColumnType("bigint") - .HasColumnName("parent_ancestor_id"); - - b.Property("discriminator") - .HasColumnType("entity_type"); - - b.HasKey("Id"); - - b.HasIndex("Address"); - - b.ToTable("entities"); - - b.HasDiscriminator("discriminator"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityMetadataAggregateHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property>("MetadataIds") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("metadata_ids"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.ToTable("entity_metadata_aggregate_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityMetadataHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("IsLocked") - .HasColumnType("boolean") - .HasColumnName("is_locked"); - - b.Property("Key") - .IsRequired() - .HasColumnType("text") - .HasColumnName("key"); - - b.Property("Value") - .HasColumnType("bytea") - .HasColumnName("value"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "Key", "FromStateVersion"); - - b.ToTable("entity_metadata_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceAggregateHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property>("FungibleResourceEntityIds") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("fungible_resource_entity_ids"); - - b.Property>("FungibleResourceSignificantUpdateStateVersions") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("fungible_resource_significant_update_state_versions"); - - b.Property>("NonFungibleResourceEntityIds") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("non_fungible_resource_entity_ids"); - - b.Property>("NonFungibleResourceSignificantUpdateStateVersions") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("non_fungible_resource_significant_update_state_versions"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.ToTable("entity_resource_aggregate_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceAggregatedVaultsHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("ResourceEntityId") - .HasColumnType("bigint") - .HasColumnName("resource_entity_id"); - - b.Property("TmpTmpRemoveMeOnceTxEventsBecomeAvailable") - .IsRequired() - .HasColumnType("text") - .HasColumnName("tmp_tmp_remove_me_once_tx_events_become_available"); - - b.Property("discriminator") - .HasColumnType("resource_type"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "ResourceEntityId", "FromStateVersion"); - - b.ToTable("entity_resource_aggregated_vaults_history"); - - b.HasDiscriminator("discriminator"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceVaultAggregateHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("ResourceEntityId") - .HasColumnType("bigint") - .HasColumnName("resource_entity_id"); - - b.Property>("VaultEntityIds") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("vault_entity_ids"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "ResourceEntityId", "FromStateVersion"); - - b.ToTable("entity_resource_vault_aggregate_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityRoleAssignmentsAggregateHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property>("EntryIds") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("entry_ids"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("OwnerRoleId") - .HasColumnType("bigint") - .HasColumnName("owner_role_id"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.ToTable("entity_role_assignments_aggregate_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityRoleAssignmentsEntryHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("KeyModule") - .HasColumnType("object_module_id") - .HasColumnName("key_module"); - - b.Property("KeyRole") - .IsRequired() - .HasColumnType("text") - .HasColumnName("key_role"); - - b.Property("RoleAssignments") - .HasColumnType("jsonb") - .HasColumnName("role_assignments"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "KeyRole", "KeyModule", "FromStateVersion"); - - b.ToTable("entity_role_assignments_entry_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityRoleAssignmentsOwnerRoleHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("RoleAssignments") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("role_assignments"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.ToTable("entity_role_assignments_owner_role_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityStateHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("State") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("state"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.ToTable("entity_state_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityVaultHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("GlobalEntityId") - .HasColumnType("bigint") - .HasColumnName("global_entity_id"); - - b.Property("OwnerEntityId") - .HasColumnType("bigint") - .HasColumnName("owner_entity_id"); - - b.Property("ResourceEntityId") - .HasColumnType("bigint") - .HasColumnName("resource_entity_id"); - - b.Property("VaultEntityId") - .HasColumnType("bigint") - .HasColumnName("vault_entity_id"); - - b.Property("discriminator") - .HasColumnType("resource_type"); - - b.HasKey("Id"); - - b.HasIndex("GlobalEntityId", "VaultEntityId", "FromStateVersion"); - - b.HasIndex("OwnerEntityId", "VaultEntityId", "FromStateVersion"); - - b.ToTable("entity_vault_history"); - - b.HasDiscriminator("discriminator"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.KeyValueStoreEntryHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("IsLocked") - .HasColumnType("boolean") - .HasColumnName("is_locked"); - - b.Property("Key") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("key"); - - b.Property("KeyValueStoreEntityId") - .HasColumnType("bigint") - .HasColumnName("key_value_store_entity_id"); - - b.Property("Value") - .HasColumnType("bytea") - .HasColumnName("value"); - - b.HasKey("Id"); - - b.HasIndex("KeyValueStoreEntityId", "Key", "FromStateVersion"); - - b.ToTable("key_value_store_entry_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.KeyValueStoreSchemaHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("KeyTypeIndex") - .HasColumnType("integer") - .HasColumnName("key_type_index"); - - b.Property("KeyTypeKind") - .HasColumnType("key_type_kind") - .HasColumnName("key_type_kind"); - - b.Property("Schema") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("schema"); - - b.Property("ValueTypeIndex") - .HasColumnType("integer") - .HasColumnName("value_type_index"); - - b.Property("ValueTypeKind") - .HasColumnType("key_type_kind") - .HasColumnName("value_type_kind"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.ToTable("key_value_store_schema_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction", b => - { - b.Property("StateVersion") - .HasColumnType("bigint") - .HasColumnName("state_version"); - - b.Property("AffectedGlobalEntities") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("affected_global_entities"); - - b.Property("CreatedTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("created_timestamp"); - - b.Property("Epoch") - .HasColumnType("bigint") - .HasColumnName("epoch"); - - b.Property("FeePaid") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("fee_paid"); - - b.Property("IndexInEpoch") - .HasColumnType("bigint") - .HasColumnName("index_in_epoch"); - - b.Property("IndexInRound") - .HasColumnType("bigint") - .HasColumnName("index_in_round"); - - b.Property("IsEndOfEpoch") - .HasColumnType("boolean") - .HasColumnName("is_end_of_epoch"); - - b.Property("Message") - .HasColumnType("bytea") - .HasColumnName("message"); - - b.Property("NormalizedRoundTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("normalized_round_timestamp"); - - b.Property("RawPayload") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("raw_payload"); - - b.Property("RoundInEpoch") - .HasColumnType("bigint") - .HasColumnName("round_in_epoch"); - - b.Property("RoundTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("round_timestamp"); - - b.Property("TipPaid") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("tip_paid"); - - b.Property("discriminator") - .HasColumnType("ledger_transaction_type"); - - b.HasKey("StateVersion"); - - b.HasIndex("RoundTimestamp"); - - b.HasIndex("Epoch", "RoundInEpoch") - .IsUnique() - .HasFilter("index_in_round = 0"); - - b.ToTable("ledger_transactions"); - - b.HasDiscriminator("discriminator"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("StateVersion") - .HasColumnType("bigint") - .HasColumnName("state_version"); - - b.Property("discriminator") - .HasColumnType("ledger_transaction_marker_type"); - - b.HasKey("Id"); - - b.ToTable("ledger_transaction_markers"); - - b.HasDiscriminator("discriminator"); - - b.UseTphMappingStrategy(); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NetworkConfiguration", b => - { - b.Property("Id") - .HasColumnType("integer") - .HasColumnName("id"); - - b.Property("AddressTypeDefinitions") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("address_type_definitions"); - - b.Property("GenesisEpoch") - .HasColumnType("bigint") - .HasColumnName("genesis_epoch"); - - b.Property("GenesisRound") - .HasColumnType("bigint") - .HasColumnName("genesis_round"); - - b.Property("HrpDefinition") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("hrp_definition"); - - b.Property("NetworkId") - .HasColumnType("smallint") - .HasColumnName("network_id"); - - b.Property("NetworkName") - .IsRequired() - .HasColumnType("text") - .HasColumnName("network_name"); - - b.Property("WellKnownAddresses") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("well_known_addresses"); - - b.HasKey("Id"); - - b.ToTable("network_configuration"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleDataSchemaHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("Schema") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("schema"); - - b.Property("TypeIndex") - .HasColumnType("integer") - .HasColumnName("type_index"); - - b.Property("TypeKind") - .HasColumnType("key_type_kind") - .HasColumnName("type_kind"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.ToTable("non_fungible_data_schema_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleIdData", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("NonFungibleId") - .IsRequired() - .HasColumnType("text") - .HasColumnName("non_fungible_id"); - - b.Property("NonFungibleResourceEntityId") - .HasColumnType("bigint") - .HasColumnName("non_fungible_resource_entity_id"); - - b.HasKey("Id"); - - b.HasIndex("NonFungibleResourceEntityId", "FromStateVersion"); - - b.HasIndex("NonFungibleResourceEntityId", "NonFungibleId", "FromStateVersion") - .IsUnique(); - - b.ToTable("non_fungible_id_data"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleIdDataHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Data") - .HasColumnType("bytea") - .HasColumnName("data"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("IsDeleted") - .HasColumnType("boolean") - .HasColumnName("is_deleted"); - - b.Property("IsLocked") - .HasColumnType("boolean") - .HasColumnName("is_locked"); - - b.Property("NonFungibleIdDataId") - .HasColumnType("bigint") - .HasColumnName("non_fungible_id_data_id"); - - b.HasKey("Id"); - - b.HasIndex("NonFungibleIdDataId", "FromStateVersion"); - - b.ToTable("non_fungible_id_data_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleIdStoreHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property>("NonFungibleIdDataIds") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("non_fungible_id_data_ids"); - - b.Property("NonFungibleResourceEntityId") - .HasColumnType("bigint") - .HasColumnName("non_fungible_resource_entity_id"); - - b.HasKey("Id"); - - b.HasIndex("NonFungibleResourceEntityId", "FromStateVersion"); - - b.ToTable("non_fungible_id_store_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PackageBlueprintHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("AuthTemplate") - .HasColumnType("jsonb") - .HasColumnName("auth_template"); - - b.Property("AuthTemplateIsLocked") - .HasColumnType("boolean") - .HasColumnName("auth_template_is_locked"); - - b.Property("Definition") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("definition"); - - b.Property>("DependantEntityIds") - .HasColumnType("bigint[]") - .HasColumnName("dependant_entity_ids"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("Name") - .IsRequired() - .HasColumnType("text") - .HasColumnName("name"); - - b.Property("PackageEntityId") - .HasColumnType("bigint") - .HasColumnName("package_entity_id"); - - b.Property("RoyaltyConfig") - .HasColumnType("jsonb") - .HasColumnName("royalty_config"); - - b.Property("RoyaltyConfigIsLocked") - .HasColumnType("boolean") - .HasColumnName("royalty_config_is_locked"); - - b.Property("Version") - .IsRequired() - .HasColumnType("text") - .HasColumnName("version"); - - b.HasKey("Id"); - - b.HasIndex("PackageEntityId", "FromStateVersion"); - - b.ToTable("package_blueprint_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PackageCodeHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Code") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("code"); - - b.Property("CodeHash") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("code_hash"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("PackageEntityId") - .HasColumnType("bigint") - .HasColumnName("package_entity_id"); - - b.HasKey("Id"); - - b.HasIndex("PackageEntityId", "FromStateVersion"); - - b.ToTable("package_code_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PackageSchemaHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("PackageEntityId") - .HasColumnType("bigint") - .HasColumnName("package_entity_id"); - - b.Property("Schema") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("schema"); - - b.Property("SchemaHash") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("schema_hash"); - - b.HasKey("Id"); - - b.HasIndex("PackageEntityId", "FromStateVersion"); - - b.HasIndex("SchemaHash", "FromStateVersion"); - - b.ToTable("package_schema_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.PendingTransaction", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("CommitTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("commit_timestamp"); - - b.Property("FirstSeenInMempoolTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("first_seen_in_mempool_timestamp"); - - b.Property("FirstSubmittedToGatewayTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("first_submitted_to_gateway_timestamp"); - - b.Property("IntentHash") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("intent_hash"); - - b.Property("LastDroppedOutOfMempoolTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_missing_from_mempool_timestamp"); - - b.Property("LastFailureReason") - .HasColumnType("text") - .HasColumnName("last_failure_reason"); - - b.Property("LastFailureTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_failure_timestamp"); - - b.Property("LastSubmittedToGatewayTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_submitted_to_gateway_timestamp"); - - b.Property("LastSubmittedToNodeName") - .HasColumnType("text") - .HasColumnName("last_submitted_to_node_name"); - - b.Property("LastSubmittedToNodeTimestamp") - .HasColumnType("timestamp with time zone") - .HasColumnName("last_submitted_to_node_timestamp"); - - b.Property("NotarizedTransactionBlob") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("notarized_transaction_blob"); - - b.Property("PayloadHash") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("payload_hash"); - - b.Property("Status") - .HasColumnType("pending_transaction_status") - .HasColumnName("status"); - - b.Property("SubmissionToNodesCount") - .HasColumnType("integer") - .HasColumnName("submission_count"); - - b.Property("SubmittedByThisGateway") - .HasColumnType("boolean") - .HasColumnName("submitted_by_this_gateway"); - - b.Property("VersionControl") - .IsConcurrencyToken() - .ValueGeneratedOnAddOrUpdate() - .HasColumnType("xid") - .HasColumnName("xmin"); - - b.HasKey("Id"); - - b.HasIndex("IntentHash"); - - b.HasIndex("PayloadHash") - .IsUnique(); - - b.HasIndex("Status"); - - b.ToTable("pending_transactions"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceEntitySupplyHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("ResourceEntityId") - .HasColumnType("bigint") - .HasColumnName("resource_entity_id"); - - b.Property("TotalBurned") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("total_burned"); - - b.Property("TotalMinted") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("total_minted"); - - b.Property("TotalSupply") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("total_supply"); - - b.HasKey("Id"); - - b.HasIndex("ResourceEntityId", "FromStateVersion"); - - b.ToTable("resource_entity_supply_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorActiveSetHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("Epoch") - .HasColumnType("bigint") - .HasColumnName("epoch"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("Stake") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("stake"); - - b.Property("ValidatorPublicKeyHistoryId") - .HasColumnType("bigint") - .HasColumnName("validator_public_key_history_id"); - - b.HasKey("Id"); - - b.HasIndex("Epoch"); - - b.HasIndex("FromStateVersion"); - - b.HasIndex("ValidatorPublicKeyHistoryId"); - - b.ToTable("validator_active_set_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorEmissionStatistics", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EpochNumber") - .HasColumnType("bigint") - .HasColumnName("epoch_number"); - - b.Property("ProposalsMade") - .HasColumnType("bigint") - .HasColumnName("proposals_made"); - - b.Property("ProposalsMissed") - .HasColumnType("bigint") - .HasColumnName("proposals_missed"); - - b.Property("ValidatorEntityId") - .HasColumnType("bigint") - .HasColumnName("validator_entity_id"); - - b.HasKey("Id"); - - b.ToTable("validator_emission_statistics"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorPublicKeyHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("Key") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("key"); - - b.Property("KeyType") - .HasColumnType("public_key_type") - .HasColumnName("key_type"); - - b.Property("ValidatorEntityId") - .HasColumnType("bigint") - .HasColumnName("validator_entity_id"); - - b.HasKey("Id"); - - b.HasIndex("ValidatorEntityId", "FromStateVersion"); - - b.HasIndex("ValidatorEntityId", "KeyType", "Key"); - - b.ToTable("validator_public_key_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorStateHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("bigint") - .HasColumnName("id"); - - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - - b.Property("EntityId") - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("FromStateVersion") - .HasColumnType("bigint") - .HasColumnName("from_state_version"); - - b.Property("State") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("state"); - - b.HasKey("Id"); - - b.HasIndex("EntityId", "FromStateVersion"); - - b.ToTable("validator_state_history"); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalAccessControllerEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalAccessController); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalAccountEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalAccountComponent); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalConsensusManager", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalConsensusManager); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalFungibleResourceEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("Divisibility") - .HasColumnType("integer") - .HasColumnName("divisibility"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalFungibleResource); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalGenericComponentEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalGenericComponent); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalIdentityEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalIdentity); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalMultiResourcePoolEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalMultiResourcePool); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalNonFungibleResourceEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("NonFungibleIdType") - .HasColumnType("non_fungible_id_type") - .HasColumnName("non_fungible_id_type"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalNonFungibleResource); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalOneResourcePoolEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalOneResourcePool); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalPackageEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.Property("VmType") - .HasColumnType("package_vm_type") - .HasColumnName("vm_type"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalPackage); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalTransactionTrackerEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalTransactionTracker); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalTwoResourcePoolEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalTwoResourcePool); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GlobalValidatorEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("LockedOwnerStakeUnitVault") - .HasColumnType("bigint") - .HasColumnName("locked_owner_stake_unit_vault_entity_id"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.Property("PendingOwnerStakeUnitUnlockVault") - .HasColumnType("bigint") - .HasColumnName("pending_owner_stake_unit_unlock_vault_entity_id"); - - b.Property("PendingXrdWithdrawVault") - .HasColumnType("bigint") - .HasColumnName("pending_xrd_withdraw_vault_entity_id"); - - b.Property("StakeVaultEntityId") - .HasColumnType("bigint") - .HasColumnName("stake_vault_entity_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.GlobalValidator); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalAccountEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.InternalAccountComponent); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalFungibleVaultEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.Property("ResourceEntityId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("resource_entity_id"); - - b.Property("RoyaltyVaultOfEntityId") - .HasColumnType("bigint") - .HasColumnName("royalty_vault_of_entity_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.InternalFungibleVault); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalGenericComponentEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.InternalGenericComponent); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalKeyValueStoreEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.InternalKeyValueStore); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.InternalNonFungibleVaultEntity", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.Entity"); - - b.Property("BlueprintName") - .IsRequired() - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("text") - .HasColumnName("blueprint_name"); - - b.Property("PackageId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("package_id"); - - b.Property("ResourceEntityId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("resource_entity_id"); - - b.ToTable("entities"); - - b.HasDiscriminator().HasValue(EntityType.InternalNonFungibleVault); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityFungibleResourceAggregatedVaultsHistory", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceAggregatedVaultsHistory"); - - b.Property("Balance") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("balance"); - - b.ToTable("entity_resource_aggregated_vaults_history"); - - b.HasDiscriminator().HasValue(ResourceType.Fungible); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityNonFungibleResourceAggregatedVaultsHistory", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityResourceAggregatedVaultsHistory"); - - b.Property("TotalCount") - .HasColumnType("bigint") - .HasColumnName("total_count"); - - b.ToTable("entity_resource_aggregated_vaults_history"); - - b.HasDiscriminator().HasValue(ResourceType.NonFungible); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityFungibleVaultHistory", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityVaultHistory"); - - b.Property("Balance") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("balance"); - - b.Property("IsRoyaltyVault") - .HasColumnType("boolean") - .HasColumnName("is_royalty_vault"); - - b.ToTable("entity_vault_history"); - - b.HasDiscriminator().HasValue(ResourceType.Fungible); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityNonFungibleVaultHistory", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.EntityVaultHistory"); - - b.Property>("NonFungibleIds") - .IsRequired() - .HasColumnType("bigint[]") - .HasColumnName("non_fungible_ids"); - - b.ToTable("entity_vault_history"); - - b.HasDiscriminator().HasValue(ResourceType.NonFungible); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.GenesisLedgerTransaction", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction"); - - b.ToTable("ledger_transactions"); - - b.HasDiscriminator().HasValue(LedgerTransactionType.Genesis); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.RoundUpdateLedgerTransaction", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction"); - - b.ToTable("ledger_transactions"); - - b.HasDiscriminator().HasValue(LedgerTransactionType.RoundUpdate); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.UserLedgerTransaction", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction"); - - b.Property("IntentHash") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("intent_hash"); - - b.Property("PayloadHash") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("payload_hash"); - - b.Property("SignedIntentHash") - .IsRequired() - .HasColumnType("bytea") - .HasColumnName("signed_intent_hash"); - - b.HasIndex("IntentHash") - .HasFilter("intent_hash IS NOT NULL"); - - NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("IntentHash"), "hash"); - - b.ToTable("ledger_transactions"); - - b.HasDiscriminator().HasValue(LedgerTransactionType.User); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.AffectedGlobalEntityTransactionMarker", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); - - b.Property("EntityId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.HasIndex("EntityId", "StateVersion") - .HasFilter("discriminator = 'affected_global_entity'"); - - b.ToTable("ledger_transaction_markers"); - - b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.AffectedGlobalEntity); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.EventLedgerTransactionMarker", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); - - b.Property("EntityId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("EventType") - .HasColumnType("ledger_transaction_marker_event_type") - .HasColumnName("event_type"); - - b.Property("Quantity") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("quantity"); - - b.Property("ResourceEntityId") - .HasColumnType("bigint") - .HasColumnName("resource_entity_id"); - - b.HasIndex("EventType", "EntityId", "StateVersion") - .HasFilter("discriminator = 'event'"); - - b.ToTable("ledger_transaction_markers"); - - b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.Event); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ManifestAddressLedgerTransactionMarker", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); - - b.Property("EntityId") - .ValueGeneratedOnUpdateSometimes() - .HasColumnType("bigint") - .HasColumnName("entity_id"); - - b.Property("OperationType") - .HasColumnType("ledger_transaction_marker_operation_type") - .HasColumnName("operation_type"); - - b.HasIndex("OperationType", "EntityId", "StateVersion") - .HasFilter("discriminator = 'manifest_address'"); - - b.ToTable("ledger_transaction_markers"); - - b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.ManifestAddress); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.OriginLedgerTransactionMarker", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransactionMarker"); - - b.Property("OriginType") - .HasColumnType("ledger_transaction_marker_origin_type") - .HasColumnName("origin_type"); - - b.HasIndex("OriginType", "StateVersion") - .HasFilter("discriminator = 'origin'"); - - b.ToTable("ledger_transaction_markers"); - - b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.Origin); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.LedgerTransaction", b => - { - b.OwnsOne("RadixDlt.NetworkGateway.PostgresIntegration.Models.TransactionReceipt", "EngineReceipt", b1 => - { - b1.Property("LedgerTransactionStateVersion") - .HasColumnType("bigint"); - - b1.Property("ErrorMessage") - .HasColumnType("text") - .HasColumnName("receipt_error_message"); - - b1.Property("EventsSbor") - .HasColumnType("bytea[]") - .HasColumnName("receipt_events_sbor"); - - b1.Property("EventsSchemaHash") - .HasColumnType("bytea[]") - .HasColumnName("receipt_events_schema_hash"); - - b1.Property("EventsTypeIndex") - .HasColumnType("integer[]") - .HasColumnName("receipt_events_type_index"); - - b1.Property("EventsTypeKind") - .HasColumnType("key_type_kind[]") - .HasColumnName("receipt_events_type_kind"); - - b1.Property("FeeSummary") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("receipt_fee_summary"); - - b1.Property("NextEpoch") - .HasColumnType("jsonb") - .HasColumnName("receipt_next_epoch"); - - b1.Property("Output") - .HasColumnType("jsonb") - .HasColumnName("receipt_output"); - - b1.Property("StateUpdates") - .IsRequired() - .HasColumnType("jsonb") - .HasColumnName("receipt_state_updates"); - - b1.Property("Status") - .HasColumnType("ledger_transaction_status") - .HasColumnName("receipt_status"); - - b1.HasKey("LedgerTransactionStateVersion"); - - b1.ToTable("ledger_transactions"); - - b1.WithOwner() - .HasForeignKey("LedgerTransactionStateVersion"); - }); - - b.Navigation("EngineReceipt") - .IsRequired(); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorActiveSetHistory", b => - { - b.HasOne("RadixDlt.NetworkGateway.PostgresIntegration.Models.ValidatorPublicKeyHistory", "PublicKey") - .WithMany() - .HasForeignKey("ValidatorPublicKeyHistoryId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("PublicKey"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/KeyVaulueStoreSchemaHistory.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/KeyVaulueStoreSchemaHistory.cs index 164a0d5e1..414248b44 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/KeyVaulueStoreSchemaHistory.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/KeyVaulueStoreSchemaHistory.cs @@ -78,20 +78,20 @@ internal class KeyValueStoreSchemaHistory [Column("from_state_version")] public long FromStateVersion { get; set; } - [Column("entity_id")] - public long EntityId { get; set; } + [Column("key_value_store_entity_id")] + public long KeyValueStoreEntityId { get; set; } [Column("schema")] public byte[] Schema { get; set; } - [Column("key_type_kind")] - public KeyTypeKind KeyTypeKind { get; set; } + [Column("key_sbor_type_kind")] + public SborTypeKind KeySborTypeKind { get; set; } [Column("key_type_index")] public int KeyTypeIndex { get; set; } - [Column("value_type_kind")] - public KeyTypeKind ValueTypeKind { get; set; } + [Column("value_sbor_type_kind")] + public SborTypeKind ValueSborTypeKind { get; set; } [Column("value_type_index")] public int ValueTypeIndex { get; set; } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/LedgerTransaction.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/LedgerTransaction.cs index cf9abacf4..fdf038dfb 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/LedgerTransaction.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/LedgerTransaction.cs @@ -164,16 +164,16 @@ internal class TransactionReceipt public string? ErrorMessage { get; set; } [Column("receipt_events_sbor")] - public byte[][]? EventsSbor { get; set; } + public byte[][] EventsSbor { get; set; } [Column("receipt_events_schema_hash")] - public byte[][]? EventsSchemaHash { get; set; } + public byte[][] EventsSchemaHash { get; set; } [Column("receipt_events_type_index")] - public int[]? EventsTypeIndex { get; set; } + public int[] EventsTypeIndex { get; set; } - [Column("receipt_events_type_kind")] - public KeyTypeKind[]? EventsTypeKind { get; set; } + [Column("receipt_events_sbor_type_kind")] + public SborTypeKind[] EventsSborTypeKind { get; set; } } internal class GenesisLedgerTransaction : LedgerTransaction diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/NonFungibleDataSchemaHistory.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/NonFungibleDataSchemaHistory.cs index 49e6feec3..037bb1b00 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/NonFungibleDataSchemaHistory.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/NonFungibleDataSchemaHistory.cs @@ -84,8 +84,8 @@ internal class NonFungibleDataSchemaHistory [Column("schema")] public byte[] Schema { get; set; } - [Column("type_kind")] - public KeyTypeKind TypeKind { get; set; } + [Column("sbor_type_kind")] + public SborTypeKind SborTypeKind { get; set; } [Column("type_index")] public int TypeIndex { get; set; } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ValidatorStateHistory.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ValidatorStateHistory.cs index c00e5fd8b..be531880a 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ValidatorStateHistory.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ValidatorStateHistory.cs @@ -77,8 +77,8 @@ internal class ValidatorStateHistory [Column("from_state_version")] public long FromStateVersion { get; set; } - [Column("entity_id")] - public long EntityId { get; set; } + [Column("validator_entity_id")] + public long ValidatorEntityId { get; set; } [Column("state", TypeName = "jsonb")] public string State { get; set; } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/ScryptoSborUtils.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/ScryptoSborUtils.cs index 7e3c4ee60..56b1c9785 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/ScryptoSborUtils.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/ScryptoSborUtils.cs @@ -82,12 +82,12 @@ public static string GetNonFungibleId(string input) return stringNfid; } - public static string DataToProgrammaticJson(byte[] data, byte[] schemaBytes, KeyTypeKind keyTypeKind, int schemaIndex, byte networkId) + public static string DataToProgrammaticJson(byte[] data, byte[] schemaBytes, SborTypeKind keyTypeKind, int schemaIndex, byte networkId) { ToolkitModel.LocalTypeIndex typeIndex = keyTypeKind switch { - KeyTypeKind.SchemaLocal => new ToolkitModel.LocalTypeIndex.SchemaLocalIndex((ulong)schemaIndex), - KeyTypeKind.WellKnown => new ToolkitModel.LocalTypeIndex.WellKnown((byte)schemaIndex), + SborTypeKind.SchemaLocal => new ToolkitModel.LocalTypeIndex.SchemaLocalIndex((ulong)schemaIndex), + SborTypeKind.WellKnown => new ToolkitModel.LocalTypeIndex.WellKnown((byte)schemaIndex), _ => throw new ArgumentOutOfRangeException(nameof(keyTypeKind), keyTypeKind, null), }; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/ServiceCollectionExtensions.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/ServiceCollectionExtensions.cs index 0e43ce9d2..a63fcf7a1 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/ServiceCollectionExtensions.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/ServiceCollectionExtensions.cs @@ -115,7 +115,7 @@ internal static IServiceCollection AddNpgsqlDataSourceHolder(this IServiceCol dataSourceBuilder.MapEnum(); dataSourceBuilder.MapEnum(); dataSourceBuilder.MapEnum(); - dataSourceBuilder.MapEnum(); + dataSourceBuilder.MapEnum(); return new NpgsqlDataSourceHolder(dataSourceBuilder.Build()); }, diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.cs index 9cc6aae09..e5265918a 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.cs @@ -605,7 +605,7 @@ ORDER BY nfid.from_state_version DESC } var programmaticJson = ScryptoSborUtils.DataToProgrammaticJson(vm.Data, nonFungibleDataSchema.Schema, - nonFungibleDataSchema.TypeKind, nonFungibleDataSchema.TypeIndex, _networkConfigurationProvider.GetNetworkId()); + nonFungibleDataSchema.SborTypeKind, nonFungibleDataSchema.TypeIndex, _networkConfigurationProvider.GetNetworkId()); items.Add(new GatewayModel.StateNonFungibleDetailsResponseItem( nonFungibleId: vm.NonFungibleId, @@ -690,7 +690,7 @@ LIMIT 1 INNER JOIN LATERAL ( SELECT state, from_state_version FROM validator_state_history - WHERE entity_id = variables.validator_entity_id AND from_state_version <= @stateVersion + WHERE validator_entity_id = variables.validator_entity_id AND from_state_version <= @stateVersion ORDER BY from_state_version DESC LIMIT 1 ) esh ON true @@ -781,7 +781,7 @@ LIMIT 1 { var keyValueStore = await GetEntity(keyValueStoreAddress, ledgerState, token); var keyValueStoreSchema = await _dbContext.KeyValueStoreSchemaHistory - .Where(x => x.EntityId == keyValueStore.Id && x.FromStateVersion <= ledgerState.StateVersion) + .Where(x => x.KeyValueStoreEntityId == keyValueStore.Id && x.FromStateVersion <= ledgerState.StateVersion) .OrderByDescending(x => x.FromStateVersion) .FirstOrDefaultAsync(token); @@ -817,10 +817,10 @@ LIMIT 1 continue; } - var keyJson = ScryptoSborUtils.DataToProgrammaticJson(e.Key, keyValueStoreSchema.Schema, keyValueStoreSchema.KeyTypeKind, + var keyJson = ScryptoSborUtils.DataToProgrammaticJson(e.Key, keyValueStoreSchema.Schema, keyValueStoreSchema.KeySborTypeKind, keyValueStoreSchema.KeyTypeIndex, _networkConfigurationProvider.GetNetworkId()); - var valueJson = ScryptoSborUtils.DataToProgrammaticJson(e.Value, keyValueStoreSchema.Schema, keyValueStoreSchema.ValueTypeKind, + var valueJson = ScryptoSborUtils.DataToProgrammaticJson(e.Value, keyValueStoreSchema.Schema, keyValueStoreSchema.ValueSborTypeKind, keyValueStoreSchema.ValueTypeIndex, _networkConfigurationProvider.GetNetworkId()); items.Add(new GatewayModel.StateKeyValueStoreDataResponseItem( diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/TransactionQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/TransactionQuerier.cs index 5f1629c3c..d095696ec 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/TransactionQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/TransactionQuerier.cs @@ -335,17 +335,17 @@ public async Task> LookupPendingTransactionsByIn var entityIdToAddressMap = await GetEntityAddresses(transactions.SelectMany(x => x.AffectedGlobalEntities).ToList(), token); var schemaHashes = transactions - .Where(x => x.EngineReceipt.EventsSchemaHash != null) - .SelectMany(x => x.EngineReceipt.EventsSchemaHash!) + .Where(x => x.EngineReceipt.EventsSchemaHash.Any()) + .SelectMany(x => x.EngineReceipt.EventsSchemaHash) .ToList(); - List? schemas = null; + Dictionary schemas = new Dictionary(); if (optIns.ReceiptEvents && schemaHashes.Any()) { schemas = await _dbContext.PackageSchemaHistory .Where(x => schemaHashes.Contains(x.SchemaHash)) - .ToListAsync(token); + .ToDictionaryAsync(x => (ValueBytes)x.SchemaHash, x => x.Schema, token); } List mappedTransactions = new List(); @@ -361,28 +361,16 @@ public async Task> LookupPendingTransactionsByIn { List events = new List(); - for (var i = 0; i < transaction.EngineReceipt.EventsSbor!.Length; ++i) + foreach (var @event in transaction.EngineReceipt.GetEvents()) { - if (transaction.EngineReceipt.EventsSbor?[i] == null || - transaction.EngineReceipt.EventsSchemaHash?[i] == null || - transaction.EngineReceipt.EventsTypeIndex?[i] == null || - transaction.EngineReceipt.EventsTypeKind?[i] == null) - { - throw new UnreachableException("Each event specific array in receipt should have same number of elements."); - } - - var eventData = transaction.EngineReceipt.EventsSbor[i]; - var schemaHash = transaction.EngineReceipt.EventsSchemaHash[i]; - var index = transaction.EngineReceipt.EventsTypeIndex[i]; - var isSchemaLocalIndex = transaction.EngineReceipt.EventsTypeKind[i]; - var schema = schemas?.SingleOrDefault(x => x.SchemaHash.SequenceEqual(schemaHash)); + var schemaFound = schemas.TryGetValue(@event.SchemaHash, out var schema); - if (schema == null) + if (!schemaFound) { - throw new UnreachableException($"Unable to find schema for given hash {Convert.ToHexString(schemaHash)}"); + throw new UnreachableException($"Unable to find schema for given hash {Convert.ToHexString(@event.SchemaHash)}"); } - events.Add(ScryptoSborUtils.DataToProgrammaticJson(eventData, schema.Schema, isSchemaLocalIndex, index, networkId)); + events.Add(ScryptoSborUtils.DataToProgrammaticJson(@event.Data, schema!, @event.KeyTypeKind, @event.TypeIndex, networkId)); } mappedTransactions.Add(transaction.ToGatewayModel(optIns, entityIdToAddressMap, events)); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/TransactionReceiptExtensions.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/TransactionReceiptExtensions.cs new file mode 100644 index 000000000..1144fd977 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/TransactionReceiptExtensions.cs @@ -0,0 +1,91 @@ +/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands). + * + * Licensed under the Radix License, Version 1.0 (the "License"); you may not use this + * file except in compliance with the License. You may obtain a copy of the License at: + * + * radixfoundation.org/licenses/LICENSE-v1 + * + * The Licensor hereby grants permission for the Canonical version of the Work to be + * published, distributed and used under or by reference to the Licensor’s trademark + * Radix ® and use of any unregistered trade names, logos or get-up. + * + * The Licensor provides the Work (and each Contributor provides its Contributions) on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, + * including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, + * MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. + * + * Whilst the Work is capable of being deployed, used and adopted (instantiated) to create + * a distributed ledger it is your responsibility to test and validate the code, together + * with all logic and performance of that code under all foreseeable scenarios. + * + * The Licensor does not make or purport to make and hereby excludes liability for all + * and any representation, warranty or undertaking in any form whatsoever, whether express + * or implied, to any entity or person, including any representation, warranty or + * undertaking, as to the functionality security use, value or other characteristics of + * any distributed ledger nor in respect the functioning or value of any tokens which may + * be created stored or transferred using the Work. The Licensor does not warrant that the + * Work or any use of the Work complies with any law or regulation in any territory where + * it may be implemented or used or that it will be appropriate for any specific purpose. + * + * Neither the licensor nor any current or former employees, officers, directors, partners, + * trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor + * shall be liable for any direct or indirect, special, incidental, consequential or other + * losses of any kind, in tort, contract or otherwise (including but not limited to loss + * of revenue, income or profits, or loss of use or data, or loss of reputation, or loss + * of any economic or other opportunity of whatsoever nature or howsoever arising), arising + * out of or in connection with (without limitation of any use, misuse, of any ledger system + * or use made or its functionality or any performance or operation of any code or protocol + * caused by bugs or programming or logic errors or otherwise); + * + * A. any offer, purchase, holding, use, sale, exchange or transmission of any + * cryptographic keys, tokens or assets created, exchanged, stored or arising from any + * interaction with the Work; + * + * B. any failure in a transmission or loss of any token or assets keys or other digital + * artefacts due to errors in transmission; + * + * C. bugs, hacks, logic errors or faults in the Work or any communication; + * + * D. system software or apparatus including but not limited to losses caused by errors + * in holding or transmitting tokens by any third-party; + * + * E. breaches or failure of security including hacker attacks, loss or disclosure of + * password, loss of private key, unauthorised use or misuse of such passwords or keys; + * + * F. any losses including loss of anticipated savings or other benefits resulting from + * use of the Work or any changes to the Work (however implemented). + * + * You are solely responsible for; testing, validating and evaluation of all operation + * logic, functionality, security and appropriateness of using the Work for any commercial + * or non-commercial purpose and for any reproduction or redistribution by You of the + * Work. You assume all risks associated with Your use of the Work and the exercise of + * permissions under this License. + */ + +using RadixDlt.NetworkGateway.Abstractions.Model; +using RadixDlt.NetworkGateway.PostgresIntegration.Models; +using System.Collections.Generic; + +namespace RadixDlt.NetworkGateway.PostgresIntegration; + +internal record TransactionReceiptEventData(byte[] Data, byte[] SchemaHash, int TypeIndex, SborTypeKind KeyTypeKind); + +internal static class TransactionReceiptExtensions +{ + public static List GetEvents(this TransactionReceipt transactionReceipt) + { + var result = new List(); + + for (var i = 0; i < transactionReceipt.EventsSbor.Length; ++i) + { + var eventData = transactionReceipt.EventsSbor[i]; + var schemaHash = transactionReceipt.EventsSchemaHash[i]; + var index = transactionReceipt.EventsTypeIndex[i]; + var typeKind = transactionReceipt.EventsSborTypeKind[i]; + + result.Add(new TransactionReceiptEventData(eventData, schemaHash, index, typeKind)); + } + + return result; + } +} diff --git a/src/RadixDlt.NetworkGateway.PrometheusIntegration/RadixDlt.NetworkGateway.PrometheusIntegration.csproj b/src/RadixDlt.NetworkGateway.PrometheusIntegration/RadixDlt.NetworkGateway.PrometheusIntegration.csproj index 1c961977e..2d3fc10c3 100644 --- a/src/RadixDlt.NetworkGateway.PrometheusIntegration/RadixDlt.NetworkGateway.PrometheusIntegration.csproj +++ b/src/RadixDlt.NetworkGateway.PrometheusIntegration/RadixDlt.NetworkGateway.PrometheusIntegration.csproj @@ -7,7 +7,6 @@ -