From 967dfe38c1fe82c38d77e3770e43e7ab1f047cd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Thu, 19 Sep 2024 13:16:00 +0200 Subject: [PATCH] fix total_count for validators endpoint. Removed total_count from transaction stream endpoint and cursor mixin for endpoints that aren't using it. --- CHANGELOG.md | 4 + .../gateway-api-schema.yaml | 41 ++-- .../Model/StreamTransactionsResponse.cs | 21 +- .../Model/StreamTransactionsResponseAllOf.cs | 21 +- .../Model/TwoWayLinkedDappsCollection.cs | 40 +--- .../Model/TwoWayLinkedDappsCollectionAllOf.cs | 194 ------------------ .../Model/TwoWayLinkedEntitiesCollection.cs | 40 +--- .../TwoWayLinkedEntitiesCollectionAllOf.cs | 194 ------------------ .../IoC/GatewayApiBuilderExtensions.cs | 1 + .../LedgerExtension/AccountLockerProcessor.cs | 49 +++-- .../Queries/KeyValueStoreQueries.cs | 66 +++++- .../DepositPreValidationQuerier.cs | 10 +- .../Services/AccountLockerQuerier.cs | 9 +- .../Services/ValidatorQuerier.cs | 10 +- 14 files changed, 162 insertions(+), 538 deletions(-) delete mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedDappsCollectionAllOf.cs delete mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedEntitiesCollectionAllOf.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index 349674ee3..f3aadab3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,10 @@ Release built: _not released yet_ > - `/state/entity/page/non-fungibles/` (when using `non_fungible_include_nfids` opt-in) > - `/state/entity/page/non-fungible-vaults/` (when using `non_fungible_include_nfids` opt-in) + +### Bug fixes + +- Added missing `total_count` property to `/state/validators/list` response. ### API Changes - Restored previously removed `total_count` property to `/state/key-value-store/keys` endpoint. diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index 78ffef8eb..bb4806922 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -2317,16 +2317,14 @@ components: TwoWayLinkedDappsCollection: description: A collection of two-way linked (resolved & verified) dApps linked to the entity defining this collection. - allOf: - - $ref: "#/components/schemas/ResultSetCursorMixin" - - type: object - required: - - items - properties: - items: - type: array - items: - $ref: "#/components/schemas/TwoWayLinkedDappsCollectionItem" + type: object + required: + - items + properties: + items: + type: array + items: + $ref: "#/components/schemas/TwoWayLinkedDappsCollectionItem" TwoWayLinkedDappsCollectionItem: type: object required: @@ -2337,16 +2335,14 @@ components: TwoWayLinkedEntitiesCollection: description: A collection of two-way linked (resolved & verified) entities linked to the entity defining this collection. - allOf: - - $ref: "#/components/schemas/ResultSetCursorMixin" - - type: object - required: - - items - properties: - items: - type: array - items: - $ref: "#/components/schemas/TwoWayLinkedEntitiesCollectionItem" + type: object + required: + - items + properties: + items: + type: array + items: + $ref: "#/components/schemas/TwoWayLinkedEntitiesCollectionItem" TwoWayLinkedEntitiesCollectionItem: type: object required: @@ -4055,11 +4051,14 @@ components: StreamTransactionsResponse: allOf: - $ref: "#/components/schemas/LedgerStateMixin" - - $ref: "#/components/schemas/ResultSetCursorMixin" - type: object required: - items properties: + next_cursor: + description: If specified, contains a cursor to query next page of the `items` collection. + type: string + nullable: true items: description: The page of user transactions. type: array diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StreamTransactionsResponse.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StreamTransactionsResponse.cs index 97e4c63c1..5ad534fdb 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StreamTransactionsResponse.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StreamTransactionsResponse.cs @@ -104,10 +104,9 @@ protected StreamTransactionsResponse() { } /// Initializes a new instance of the class. /// /// ledgerState (required). - /// Total number of items in underlying collection, fragment of which is available in `items` collection.. /// If specified, contains a cursor to query next page of the `items` collection.. /// The page of user transactions. (required). - public StreamTransactionsResponse(LedgerState ledgerState = default(LedgerState), long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) + public StreamTransactionsResponse(LedgerState ledgerState = default(LedgerState), string nextCursor = default(string), List items = default(List)) { // to ensure "ledgerState" is required (not null) if (ledgerState == null) @@ -121,7 +120,6 @@ protected StreamTransactionsResponse() { } throw new ArgumentNullException("items is a required property for StreamTransactionsResponse and cannot be null"); } this.Items = items; - this.TotalCount = totalCount; this.NextCursor = nextCursor; } @@ -131,13 +129,6 @@ protected StreamTransactionsResponse() { } [DataMember(Name = "ledger_state", IsRequired = true, EmitDefaultValue = true)] public LedgerState LedgerState { get; set; } - /// - /// Total number of items in underlying collection, fragment of which is available in `items` collection. - /// - /// Total number of items in underlying collection, fragment of which is available in `items` collection. - [DataMember(Name = "total_count", EmitDefaultValue = true)] - public long? TotalCount { get; set; } - /// /// If specified, contains a cursor to query next page of the `items` collection. /// @@ -161,7 +152,6 @@ public override string ToString() StringBuilder sb = new StringBuilder(); sb.Append("class StreamTransactionsResponse {\n"); sb.Append(" LedgerState: ").Append(LedgerState).Append("\n"); - sb.Append(" TotalCount: ").Append(TotalCount).Append("\n"); sb.Append(" NextCursor: ").Append(NextCursor).Append("\n"); sb.Append(" Items: ").Append(Items).Append("\n"); sb.Append("}\n"); @@ -204,11 +194,6 @@ public bool Equals(StreamTransactionsResponse input) (this.LedgerState != null && this.LedgerState.Equals(input.LedgerState)) ) && - ( - this.TotalCount == input.TotalCount || - (this.TotalCount != null && - this.TotalCount.Equals(input.TotalCount)) - ) && ( this.NextCursor == input.NextCursor || (this.NextCursor != null && @@ -235,10 +220,6 @@ public override int GetHashCode() { hashCode = (hashCode * 59) + this.LedgerState.GetHashCode(); } - if (this.TotalCount != null) - { - hashCode = (hashCode * 59) + this.TotalCount.GetHashCode(); - } if (this.NextCursor != null) { hashCode = (hashCode * 59) + this.NextCursor.GetHashCode(); diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StreamTransactionsResponseAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StreamTransactionsResponseAllOf.cs index 0cc7b7ff1..bbe4a36fe 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StreamTransactionsResponseAllOf.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StreamTransactionsResponseAllOf.cs @@ -103,8 +103,9 @@ protected StreamTransactionsResponseAllOf() { } /// /// Initializes a new instance of the class. /// + /// If specified, contains a cursor to query next page of the `items` collection.. /// The page of user transactions. (required). - public StreamTransactionsResponseAllOf(List items = default(List)) + public StreamTransactionsResponseAllOf(string nextCursor = default(string), List items = default(List)) { // to ensure "items" is required (not null) if (items == null) @@ -112,8 +113,16 @@ protected StreamTransactionsResponseAllOf() { } throw new ArgumentNullException("items is a required property for StreamTransactionsResponseAllOf and cannot be null"); } this.Items = items; + this.NextCursor = nextCursor; } + /// + /// If specified, contains a cursor to query next page of the `items` collection. + /// + /// If specified, contains a cursor to query next page of the `items` collection. + [DataMember(Name = "next_cursor", EmitDefaultValue = true)] + public string NextCursor { get; set; } + /// /// The page of user transactions. /// @@ -129,6 +138,7 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class StreamTransactionsResponseAllOf {\n"); + sb.Append(" NextCursor: ").Append(NextCursor).Append("\n"); sb.Append(" Items: ").Append(Items).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -165,6 +175,11 @@ public bool Equals(StreamTransactionsResponseAllOf input) return false; } return + ( + this.NextCursor == input.NextCursor || + (this.NextCursor != null && + this.NextCursor.Equals(input.NextCursor)) + ) && ( this.Items == input.Items || this.Items != null && @@ -182,6 +197,10 @@ public override int GetHashCode() unchecked // Overflow is fine, just wrap { int hashCode = 41; + if (this.NextCursor != null) + { + hashCode = (hashCode * 59) + this.NextCursor.GetHashCode(); + } if (this.Items != null) { hashCode = (hashCode * 59) + this.Items.GetHashCode(); diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedDappsCollection.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedDappsCollection.cs index d7eed451e..f38933200 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedDappsCollection.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedDappsCollection.cs @@ -103,10 +103,8 @@ protected TwoWayLinkedDappsCollection() { } /// /// Initializes a new instance of the class. /// - /// Total number of items in underlying collection, fragment of which is available in `items` collection.. - /// If specified, contains a cursor to query next page of the `items` collection.. /// items (required). - public TwoWayLinkedDappsCollection(long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) + public TwoWayLinkedDappsCollection(List items = default(List)) { // to ensure "items" is required (not null) if (items == null) @@ -114,24 +112,8 @@ protected TwoWayLinkedDappsCollection() { } throw new ArgumentNullException("items is a required property for TwoWayLinkedDappsCollection and cannot be null"); } this.Items = items; - this.TotalCount = totalCount; - this.NextCursor = nextCursor; } - /// - /// Total number of items in underlying collection, fragment of which is available in `items` collection. - /// - /// Total number of items in underlying collection, fragment of which is available in `items` collection. - [DataMember(Name = "total_count", EmitDefaultValue = true)] - public long? TotalCount { get; set; } - - /// - /// If specified, contains a cursor to query next page of the `items` collection. - /// - /// If specified, contains a cursor to query next page of the `items` collection. - [DataMember(Name = "next_cursor", EmitDefaultValue = true)] - public string NextCursor { get; set; } - /// /// Gets or Sets Items /// @@ -146,8 +128,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class TwoWayLinkedDappsCollection {\n"); - sb.Append(" TotalCount: ").Append(TotalCount).Append("\n"); - sb.Append(" NextCursor: ").Append(NextCursor).Append("\n"); sb.Append(" Items: ").Append(Items).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -184,16 +164,6 @@ public bool Equals(TwoWayLinkedDappsCollection input) return false; } return - ( - this.TotalCount == input.TotalCount || - (this.TotalCount != null && - this.TotalCount.Equals(input.TotalCount)) - ) && - ( - this.NextCursor == input.NextCursor || - (this.NextCursor != null && - this.NextCursor.Equals(input.NextCursor)) - ) && ( this.Items == input.Items || this.Items != null && @@ -211,14 +181,6 @@ public override int GetHashCode() unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.TotalCount != null) - { - hashCode = (hashCode * 59) + this.TotalCount.GetHashCode(); - } - if (this.NextCursor != null) - { - hashCode = (hashCode * 59) + this.NextCursor.GetHashCode(); - } if (this.Items != null) { hashCode = (hashCode * 59) + this.Items.GetHashCode(); diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedDappsCollectionAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedDappsCollectionAllOf.cs deleted file mode 100644 index 01d73438a..000000000 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedDappsCollectionAllOf.cs +++ /dev/null @@ -1,194 +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. - */ - -/* - * Radix Gateway API - Babylon - * - * This API is exposed by the Babylon Radix Gateway to enable clients to efficiently query current and historic state on the RadixDLT ledger, and intelligently handle transaction submission. It is designed for use by wallets and explorers, and for light queries from front-end dApps. For exchange/asset integrations, back-end dApp integrations, or simple use cases, you should consider using the Core API on a Node. A Gateway is only needed for reading historic snapshots of ledger states or a more robust set-up. The Gateway API is implemented by the [Network Gateway](https://github.com/radixdlt/babylon-gateway), which is configured to read from [full node(s)](https://github.com/radixdlt/babylon-node) to extract and index data from the network. This document is an API reference documentation, visit [User Guide](https://docs.radixdlt.com/) to learn more about how to run a Gateway of your own. ## Migration guide Please see [the latest release notes](https://github.com/radixdlt/babylon-gateway/releases). ## Integration and forward compatibility guarantees All responses may have additional fields added at any release, so clients are advised to use JSON parsers which ignore unknown fields on JSON objects. When the Radix protocol is updated, new functionality may be added, and so discriminated unions returned by the API may need to be updated to have new variants added, corresponding to the updated data. Clients may need to update in advance to be able to handle these new variants when a protocol update comes out. On the very rare occasions we need to make breaking changes to the API, these will be warned in advance with deprecation notices on previous versions. These deprecation notices will include a safe migration path. Deprecation notes or breaking changes will be flagged clearly in release notes for new versions of the Gateway. The Gateway DB schema is not subject to any compatibility guarantees, and may be changed at any release. DB changes will be flagged in the release notes so clients doing custom DB integrations can prepare. - * - * The version of the OpenAPI document: v1.8.0 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using FileParameter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.FileParameter; -using OpenAPIDateConverter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.OpenAPIDateConverter; - -namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model -{ - /// - /// TwoWayLinkedDappsCollectionAllOf - /// - [DataContract(Name = "TwoWayLinkedDappsCollection_allOf")] - public partial class TwoWayLinkedDappsCollectionAllOf : IEquatable - { - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected TwoWayLinkedDappsCollectionAllOf() { } - /// - /// Initializes a new instance of the class. - /// - /// items (required). - public TwoWayLinkedDappsCollectionAllOf(List items = default(List)) - { - // to ensure "items" is required (not null) - if (items == null) - { - throw new ArgumentNullException("items is a required property for TwoWayLinkedDappsCollectionAllOf and cannot be null"); - } - this.Items = items; - } - - /// - /// Gets or Sets Items - /// - [DataMember(Name = "items", IsRequired = true, EmitDefaultValue = true)] - public List Items { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - StringBuilder sb = new StringBuilder(); - sb.Append("class TwoWayLinkedDappsCollectionAllOf {\n"); - sb.Append(" Items: ").Append(Items).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as TwoWayLinkedDappsCollectionAllOf); - } - - /// - /// Returns true if TwoWayLinkedDappsCollectionAllOf instances are equal - /// - /// Instance of TwoWayLinkedDappsCollectionAllOf to be compared - /// Boolean - public bool Equals(TwoWayLinkedDappsCollectionAllOf input) - { - if (input == null) - { - return false; - } - return - ( - this.Items == input.Items || - this.Items != null && - input.Items != null && - this.Items.SequenceEqual(input.Items) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Items != null) - { - hashCode = (hashCode * 59) + this.Items.GetHashCode(); - } - return hashCode; - } - } - - } - -} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedEntitiesCollection.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedEntitiesCollection.cs index 40461e430..7a46baeec 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedEntitiesCollection.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedEntitiesCollection.cs @@ -103,10 +103,8 @@ protected TwoWayLinkedEntitiesCollection() { } /// /// Initializes a new instance of the class. /// - /// Total number of items in underlying collection, fragment of which is available in `items` collection.. - /// If specified, contains a cursor to query next page of the `items` collection.. /// items (required). - public TwoWayLinkedEntitiesCollection(long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) + public TwoWayLinkedEntitiesCollection(List items = default(List)) { // to ensure "items" is required (not null) if (items == null) @@ -114,24 +112,8 @@ protected TwoWayLinkedEntitiesCollection() { } throw new ArgumentNullException("items is a required property for TwoWayLinkedEntitiesCollection and cannot be null"); } this.Items = items; - this.TotalCount = totalCount; - this.NextCursor = nextCursor; } - /// - /// Total number of items in underlying collection, fragment of which is available in `items` collection. - /// - /// Total number of items in underlying collection, fragment of which is available in `items` collection. - [DataMember(Name = "total_count", EmitDefaultValue = true)] - public long? TotalCount { get; set; } - - /// - /// If specified, contains a cursor to query next page of the `items` collection. - /// - /// If specified, contains a cursor to query next page of the `items` collection. - [DataMember(Name = "next_cursor", EmitDefaultValue = true)] - public string NextCursor { get; set; } - /// /// Gets or Sets Items /// @@ -146,8 +128,6 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class TwoWayLinkedEntitiesCollection {\n"); - sb.Append(" TotalCount: ").Append(TotalCount).Append("\n"); - sb.Append(" NextCursor: ").Append(NextCursor).Append("\n"); sb.Append(" Items: ").Append(Items).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -184,16 +164,6 @@ public bool Equals(TwoWayLinkedEntitiesCollection input) return false; } return - ( - this.TotalCount == input.TotalCount || - (this.TotalCount != null && - this.TotalCount.Equals(input.TotalCount)) - ) && - ( - this.NextCursor == input.NextCursor || - (this.NextCursor != null && - this.NextCursor.Equals(input.NextCursor)) - ) && ( this.Items == input.Items || this.Items != null && @@ -211,14 +181,6 @@ public override int GetHashCode() unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.TotalCount != null) - { - hashCode = (hashCode * 59) + this.TotalCount.GetHashCode(); - } - if (this.NextCursor != null) - { - hashCode = (hashCode * 59) + this.NextCursor.GetHashCode(); - } if (this.Items != null) { hashCode = (hashCode * 59) + this.Items.GetHashCode(); diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedEntitiesCollectionAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedEntitiesCollectionAllOf.cs deleted file mode 100644 index f620b0d05..000000000 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/TwoWayLinkedEntitiesCollectionAllOf.cs +++ /dev/null @@ -1,194 +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. - */ - -/* - * Radix Gateway API - Babylon - * - * This API is exposed by the Babylon Radix Gateway to enable clients to efficiently query current and historic state on the RadixDLT ledger, and intelligently handle transaction submission. It is designed for use by wallets and explorers, and for light queries from front-end dApps. For exchange/asset integrations, back-end dApp integrations, or simple use cases, you should consider using the Core API on a Node. A Gateway is only needed for reading historic snapshots of ledger states or a more robust set-up. The Gateway API is implemented by the [Network Gateway](https://github.com/radixdlt/babylon-gateway), which is configured to read from [full node(s)](https://github.com/radixdlt/babylon-node) to extract and index data from the network. This document is an API reference documentation, visit [User Guide](https://docs.radixdlt.com/) to learn more about how to run a Gateway of your own. ## Migration guide Please see [the latest release notes](https://github.com/radixdlt/babylon-gateway/releases). ## Integration and forward compatibility guarantees All responses may have additional fields added at any release, so clients are advised to use JSON parsers which ignore unknown fields on JSON objects. When the Radix protocol is updated, new functionality may be added, and so discriminated unions returned by the API may need to be updated to have new variants added, corresponding to the updated data. Clients may need to update in advance to be able to handle these new variants when a protocol update comes out. On the very rare occasions we need to make breaking changes to the API, these will be warned in advance with deprecation notices on previous versions. These deprecation notices will include a safe migration path. Deprecation notes or breaking changes will be flagged clearly in release notes for new versions of the Gateway. The Gateway DB schema is not subject to any compatibility guarantees, and may be changed at any release. DB changes will be flagged in the release notes so clients doing custom DB integrations can prepare. - * - * The version of the OpenAPI document: v1.8.0 - * Generated by: https://github.com/openapitools/openapi-generator.git - */ - - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.IO; -using System.Runtime.Serialization; -using System.Text; -using System.Text.RegularExpressions; -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; -using FileParameter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.FileParameter; -using OpenAPIDateConverter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.OpenAPIDateConverter; - -namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model -{ - /// - /// TwoWayLinkedEntitiesCollectionAllOf - /// - [DataContract(Name = "TwoWayLinkedEntitiesCollection_allOf")] - public partial class TwoWayLinkedEntitiesCollectionAllOf : IEquatable - { - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected TwoWayLinkedEntitiesCollectionAllOf() { } - /// - /// Initializes a new instance of the class. - /// - /// items (required). - public TwoWayLinkedEntitiesCollectionAllOf(List items = default(List)) - { - // to ensure "items" is required (not null) - if (items == null) - { - throw new ArgumentNullException("items is a required property for TwoWayLinkedEntitiesCollectionAllOf and cannot be null"); - } - this.Items = items; - } - - /// - /// Gets or Sets Items - /// - [DataMember(Name = "items", IsRequired = true, EmitDefaultValue = true)] - public List Items { get; set; } - - /// - /// Returns the string presentation of the object - /// - /// String presentation of the object - public override string ToString() - { - StringBuilder sb = new StringBuilder(); - sb.Append("class TwoWayLinkedEntitiesCollectionAllOf {\n"); - sb.Append(" Items: ").Append(Items).Append("\n"); - sb.Append("}\n"); - return sb.ToString(); - } - - /// - /// Returns the JSON string presentation of the object - /// - /// JSON string presentation of the object - public virtual string ToJson() - { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); - } - - /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as TwoWayLinkedEntitiesCollectionAllOf); - } - - /// - /// Returns true if TwoWayLinkedEntitiesCollectionAllOf instances are equal - /// - /// Instance of TwoWayLinkedEntitiesCollectionAllOf to be compared - /// Boolean - public bool Equals(TwoWayLinkedEntitiesCollectionAllOf input) - { - if (input == null) - { - return false; - } - return - ( - this.Items == input.Items || - this.Items != null && - input.Items != null && - this.Items.SequenceEqual(input.Items) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Items != null) - { - hashCode = (hashCode * 59) + this.Items.GetHashCode(); - } - return hashCode; - } - } - - } - -} diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/IoC/GatewayApiBuilderExtensions.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/IoC/GatewayApiBuilderExtensions.cs index 7d70f6dff..29ca094c3 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/IoC/GatewayApiBuilderExtensions.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/IoC/GatewayApiBuilderExtensions.cs @@ -71,6 +71,7 @@ using RadixDlt.NetworkGateway.PostgresIntegration.Interceptors; using RadixDlt.NetworkGateway.PostgresIntegration.Queries; using RadixDlt.NetworkGateway.PostgresIntegration.Services; +using RadixDlt.NetworkGateway.PostgresIntegration.Services.AccountDepositSettings; using RadixDlt.NetworkGateway.PostgresIntegration.Services.PendingTransactions; using IPackageQuerier = RadixDlt.NetworkGateway.GatewayApi.Services.IPackageQuerier; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/AccountLockerProcessor.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/AccountLockerProcessor.cs index ca306de1b..7e3c25d14 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/AccountLockerProcessor.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/AccountLockerProcessor.cs @@ -108,14 +108,15 @@ public void VisitUpsert(CoreModel.Substate substateData, ReferencedEntity refere var account = _referencedEntities.Get((EntityAddress)accountLocker.Key.AccountAddress); var keyValueStore = _referencedEntities.Get((EntityAddress)accountLocker.Value.ResourceVaults.EntityAddress); - _definitionsToAdd.Add(new AccountLockerEntryDefinition - { - Id = _context.Sequences.AccountLockerEntryDefinitionSequence++, - FromStateVersion = stateVersion, - AccountLockerEntityId = referencedEntity.DatabaseId, - AccountEntityId = account.DatabaseId, - KeyValueStoreEntityId = keyValueStore.DatabaseId, - }); + _definitionsToAdd.Add( + new AccountLockerEntryDefinition + { + Id = _context.Sequences.AccountLockerEntryDefinitionSequence++, + FromStateVersion = stateVersion, + AccountLockerEntityId = referencedEntity.DatabaseId, + AccountEntityId = account.DatabaseId, + KeyValueStoreEntityId = keyValueStore.DatabaseId, + }); } if (substateData is CoreModel.GenericKeyValueStoreEntrySubstate keyValueStoreEntry) @@ -163,20 +164,24 @@ public async Task LoadDependencies() public void ProcessChanges() { _existingEntryDefinitions.AddRange(_definitionsToAdd.ToDictionary(e => new AccountLockerEntryDbLookup(e.AccountLockerEntityId, e.AccountEntityId))); - _resourceVaultDefinitionsToAdd.AddRange(_observedVaultDefinitions.Select(rv => new AccountLockerEntryResourceVaultDefinition - { - Id = _context.Sequences.AccountLockerEntryResourceVaultDefinitionSequence++, - FromStateVersion = rv.StateVersion, - AccountLockerDefinitionId = _existingEntryDefinitions[new AccountLockerEntryDbLookup(rv.AccountLockerEntityId, rv.AccountEntityId)].Id, - ResourceEntityId = _referencedEntities.Get(rv.ResourceAddress).DatabaseId, - VaultEntityId = _referencedEntities.Get(rv.VaultAddress).DatabaseId, - })); - _touchHistoryToAdd.AddRange(_observedTouchHistory.Select(th => new AccountLockerEntryTouchHistory - { - Id = _context.Sequences.AccountLockerEntryTouchHistorySequence++, - FromStateVersion = th.StateVersion, - AccountLockerDefinitionId = _existingEntryDefinitions[new AccountLockerEntryDbLookup(th.AccountLockerEntityId, th.AccountEntityId)].Id, - })); + _resourceVaultDefinitionsToAdd.AddRange( + _observedVaultDefinitions.Select( + rv => new AccountLockerEntryResourceVaultDefinition + { + Id = _context.Sequences.AccountLockerEntryResourceVaultDefinitionSequence++, + FromStateVersion = rv.StateVersion, + AccountLockerDefinitionId = _existingEntryDefinitions[new AccountLockerEntryDbLookup(rv.AccountLockerEntityId, rv.AccountEntityId)].Id, + ResourceEntityId = _referencedEntities.Get(rv.ResourceAddress).DatabaseId, + VaultEntityId = _referencedEntities.Get(rv.VaultAddress).DatabaseId, + })); + _touchHistoryToAdd.AddRange( + _observedTouchHistory.Select( + th => new AccountLockerEntryTouchHistory + { + Id = _context.Sequences.AccountLockerEntryTouchHistorySequence++, + FromStateVersion = th.StateVersion, + AccountLockerDefinitionId = _existingEntryDefinitions[new AccountLockerEntryDbLookup(th.AccountLockerEntityId, th.AccountEntityId)].Id, + })); } public async Task SaveEntities() diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/KeyValueStoreQueries.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/KeyValueStoreQueries.cs index f91769245..51a7726ed 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/KeyValueStoreQueries.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Queries/KeyValueStoreQueries.cs @@ -1,4 +1,68 @@ -// +/* 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. + */ + +// // Copyright (c) PlaceholderCompany. All rights reserved. // diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/DepositPreValidationQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/DepositPreValidationQuerier.cs index dd29738f3..92edb72b2 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/DepositPreValidationQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountDepositSettings/DepositPreValidationQuerier.cs @@ -76,14 +76,14 @@ using System.Threading.Tasks; using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; -namespace RadixDlt.NetworkGateway.PostgresIntegration.Services; - -internal record DepositPreValidationResourcePreferenceRulesViewModel( - long ResourceEntityId, - AccountResourcePreferenceRule AccountResourcePreferenceRule); +namespace RadixDlt.NetworkGateway.PostgresIntegration.Services.AccountDepositSettings; internal class DepositPreValidationQuerier : IDepositPreValidationQuerier { + private record DepositPreValidationResourcePreferenceRulesViewModel( + long ResourceEntityId, + AccountResourcePreferenceRule AccountResourcePreferenceRule); + private readonly IDapperWrapper _dapperWrapper; private readonly ReadOnlyDbContext _dbContext; private readonly INetworkConfigurationProvider _networkConfigurationProvider; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountLockerQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountLockerQuerier.cs index a605b0b29..0169a6b36 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountLockerQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountLockerQuerier.cs @@ -118,7 +118,14 @@ public AccountLockerQuerier(IEntityQuerier entityQuerier, ReadOnlyDbContext read var cd = new CommandDefinition( commandText: @" -SELECT d.id AS Id, d.from_state_version AS FromStateVersion, re.discriminator AS ResourceDiscriminator, re.address AS ResourceAddress, ve.address AS VaultAddress, vh.from_state_version AS LastUpdatedAtStateVersion, vh.balance AS Balance +SELECT + d.id AS Id, + d.from_state_version AS FromStateVersion, + re.discriminator AS ResourceDiscriminator, + re.address AS ResourceAddress, + ve.address AS VaultAddress, + vh.from_state_version AS LastUpdatedAtStateVersion, + vh.balance AS Balance FROM account_locker_entry_resource_vault_definition d INNER JOIN entities re ON re.id = d.resource_entity_id INNER JOIN entities ve ON ve.id = d.vault_entity_id diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ValidatorQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ValidatorQuerier.cs index 71783ee89..07b219258 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ValidatorQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ValidatorQuerier.cs @@ -179,6 +179,14 @@ LIMIT 1 var validatorsPageSize = _endpointConfiguration.Value.ValidatorsPageSize; var idBoundary = cursor?.IdBoundary ?? 0; + var validatorsCount = await _dbContext + .Entities + .OfType() + .Where(e => e.FromStateVersion <= ledgerState.StateVersion) + .Where(e => e.Id >= idBoundary) + .AnnotateMetricName("GetValidatorsCount") + .CountAsync(token); + var validatorsAndOneMore = await _dbContext .Entities .OfType() @@ -335,6 +343,6 @@ LIMIT 1 ? new GatewayModel.StateValidatorsListCursor(validatorsAndOneMore.Last().Id).ToCursorString() : null; - return new GatewayModel.StateValidatorsListResponse(ledgerState, new GatewayModel.ValidatorCollection(null, nextCursor, items)); + return new GatewayModel.StateValidatorsListResponse(ledgerState, new GatewayModel.ValidatorCollection(validatorsCount, nextCursor, items)); } }