From 2818a485326c56a953987831cb3848b0a756bd21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Tue, 11 Jun 2024 15:00:15 +0200 Subject: [PATCH 01/18] api proposition for resource owners endpoint. --- .../Controllers/StatisticsController.cs | 15 ++ .../gateway-api-schema.yaml | 99 ++++++++ .../generated/Api/StatisticsApi.cs | 161 ++++++++++++ .../Model/ResourceOwnersCollection.cs | 232 ++++++++++++++++++ .../Model/ResourceOwnersCollectionAllOf.cs | 194 +++++++++++++++ ...rceOwnersCollectionFungibleResourceItem.cs | 201 +++++++++++++++ .../Model/ResourceOwnersCollectionItem.cs | 214 ++++++++++++++++ ...OwnersCollectionNonFungibleResourceItem.cs | 191 ++++++++++++++ ...sCollectionNonFungibleResourceItemAllOf.cs | 184 ++++++++++++++ .../generated/Model/ResourceOwnersRequest.cs | 222 +++++++++++++++++ .../Model/ResourceOwnersRequestAllOf.cs | 184 ++++++++++++++ .../Model/ResourceOwnersResourceType.cs | 112 +++++++++ .../generated/Model/ResourceOwnersResponse.cs | 193 +++++++++++++++ .../Model/ResourceOwnersResponseAllOf.cs | 193 +++++++++++++++ .../ResourceOwnersProcessor.cs | 231 +++++++++++++++++ .../Models/ResourceOwners.cs | 19 ++ 16 files changed, 2645 insertions(+) create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs create mode 100644 src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs create mode 100644 src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs diff --git a/apps/GatewayApi/Controllers/StatisticsController.cs b/apps/GatewayApi/Controllers/StatisticsController.cs index 6cc4fb744..564d4f5f3 100644 --- a/apps/GatewayApi/Controllers/StatisticsController.cs +++ b/apps/GatewayApi/Controllers/StatisticsController.cs @@ -64,6 +64,7 @@ using Microsoft.AspNetCore.Mvc; using RadixDlt.NetworkGateway.GatewayApi.Handlers; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; @@ -86,4 +87,18 @@ public StatisticsController(IValidatorHandler validatorHandler) { return await _validatorHandler.Uptime(request, token); } + + [HttpPost("page/resource-owners")] + public async Task ResourceOwnersPage(GatewayModel.ResourceOwnersRequest request, CancellationToken token) + { + await Task.Yield(); + return new GatewayModel.ResourceOwnersResponse( + new GatewayModel.ResourceOwnersCollection( + 200, + null, + new List + { + new GatewayModel.ResourceOwnersCollectionFungibleResourceItem("100", GatewayModel.ResourceOwnersResourceType.FungibleResource, "lol-address"), + })); + } } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index 02d4a9542..803d0c7f9 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -1900,6 +1900,31 @@ paths: "4XX": $ref: "#/components/responses/ErrorResponse" + /statistics/page/resource-owners/: + post: + operationId: ResourceOwnersPage + summary: Get Resource Owners Page + description: | + Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + tags: + - Statistics + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwnersRequest" + responses: + "200": + description: Validators Uptime + content: + application/json: + schema: + $ref: "#/components/schemas/ResourceOwnersResponse" + "4XX": + $ref: "#/components/responses/ErrorResponse" + + components: responses: ErrorResponse: @@ -3115,6 +3140,63 @@ components: type: integer format: int64 + ResourceOwnersCollection: + allOf: + - $ref: "#/components/schemas/ResultSetCursorMixin" + - type: object + required: + - items + properties: + items: + type: array + items: + $ref: "#/components/schemas/ResourceOwnersCollectionItem" + + ResourceOwnersResourceType: + type: string + enum: + - FungibleResource + - NonFungibleResource + ResourceOwnersCollectionItem: + type: object + required: + - type + - owner_address + properties: + type: + $ref: "#/components/schemas/ResourceOwnersResourceType" + owner_address: + $ref: "#/components/schemas/Address" + discriminator: + propertyName: type + mapping: + # Must match ResourceOwnersResourceType + FungibleResource: "#/components/schemas/ResourceOwnersCollectionFungibleResourceItem" + NonFungibleResource: "#/components/schemas/ResourceOwnersCollectionNonFungibleResourceItem" + + ResourceOwnersCollectionFungibleResourceItem: + allOf: + - $ref: "#/components/schemas/ResourceOwnersCollectionItem" + - type: object + required: + - amount + properties: + amount: + $ref: "#/components/schemas/BigDecimal" + + + ResourceOwnersCollectionNonFungibleResourceItem: + allOf: + - $ref: "#/components/schemas/ResourceOwnersCollectionItem" + - type: object + required: + - non_fungible_ids_count + properties: + non_fungible_ids_count: + type: integer + format: int64 + + ValidatorCollection: allOf: - $ref: "#/components/schemas/ResultSetCursorMixin" @@ -4894,6 +4976,23 @@ components: validators: $ref: "#/components/schemas/ValidatorUptimeCollection" + ResourceOwnersRequest: + allOf: + - $ref: "#/components/schemas/CursorLimitMixin" + - type: object + properties: + resource_address: + $ref: "#/components/schemas/Address" + + ResourceOwnersResponse: + allOf: + - type: object + required: + - owners + properties: + owners: + $ref: "#/components/schemas/ResourceOwnersCollection" + # # Errors # diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/StatisticsApi.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/StatisticsApi.cs index 56b3fec6d..fa92491da 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/StatisticsApi.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/StatisticsApi.cs @@ -92,6 +92,27 @@ public interface IStatisticsApiSync : IApiAccessor { #region Synchronous Operations /// + /// Get Resource Owners Page + /// + /// + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// ResourceOwnersResponse + ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceOwnersRequest); + + /// + /// Get Resource Owners Page + /// + /// + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// ApiResponse of ResourceOwnersResponse + ApiResponse ResourceOwnersPageWithHttpInfo(ResourceOwnersRequest resourceOwnersRequest); + /// /// Get Validators Uptime /// /// @@ -122,6 +143,29 @@ public interface IStatisticsApiAsync : IApiAccessor { #region Asynchronous Operations /// + /// Get Resource Owners Page + /// + /// + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ResourceOwnersResponse + System.Threading.Tasks.Task ResourceOwnersPageAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Get Resource Owners Page + /// + /// + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ResourceOwnersResponse) + System.Threading.Tasks.Task> ResourceOwnersPageWithHttpInfoAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// /// Get Validators Uptime /// /// @@ -357,6 +401,123 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ExceptionFactory ExceptionFa set { _exceptionFactory = value; } } + /// + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// ResourceOwnersResponse + public ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceOwnersRequest) + { + RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = ResourceOwnersPageWithHttpInfo(resourceOwnersRequest); + return localVarResponse.Data; + } + + /// + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// ApiResponse of ResourceOwnersResponse + public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse ResourceOwnersPageWithHttpInfo(ResourceOwnersRequest resourceOwnersRequest) + { + // verify the required parameter 'resourceOwnersRequest' is set + if (resourceOwnersRequest == null) + throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceOwnersRequest' when calling StatisticsApi->ResourceOwnersPage"); + + RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions localVarRequestOptions = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/json" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.Data = resourceOwnersRequest; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/statistics/page/resource-owners/", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("ResourceOwnersPage", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ResourceOwnersResponse + public async System.Threading.Tasks.Task ResourceOwnersPageAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = await ResourceOwnersPageWithHttpInfoAsync(resourceOwnersRequest, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ResourceOwnersResponse) + public async System.Threading.Tasks.Task> ResourceOwnersPageWithHttpInfoAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'resourceOwnersRequest' is set + if (resourceOwnersRequest == null) + throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceOwnersRequest' when calling StatisticsApi->ResourceOwnersPage"); + + + RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions localVarRequestOptions = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/json" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.Data = resourceOwnersRequest; + + + // make the HTTP request + + var localVarResponse = await this.AsynchronousClient.PostAsync("/statistics/page/resource-owners/", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("ResourceOwnersPage", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + /// /// Get Validators Uptime Returns validators uptime data for time range limited by `from_state_version` and `at_state_version`. /// diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs new file mode 100644 index 000000000..46ad245e2 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs @@ -0,0 +1,232 @@ +/* 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.6.1 + * 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 +{ + /// + /// ResourceOwnersCollection + /// + [DataContract(Name = "ResourceOwnersCollection")] + public partial class ResourceOwnersCollection : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected ResourceOwnersCollection() { } + /// + /// 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 ResourceOwnersCollection(long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) + { + // to ensure "items" is required (not null) + if (items == null) + { + throw new ArgumentNullException("items is a required property for ResourceOwnersCollection 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 + /// + [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 ResourceOwnersCollection {\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(); + } + + /// + /// 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 ResourceOwnersCollection); + } + + /// + /// Returns true if ResourceOwnersCollection instances are equal + /// + /// Instance of ResourceOwnersCollection to be compared + /// Boolean + public bool Equals(ResourceOwnersCollection input) + { + if (input == null) + { + 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 && + 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.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(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs new file mode 100644 index 000000000..962cce159 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs @@ -0,0 +1,194 @@ +/* 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.6.1 + * 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 +{ + /// + /// ResourceOwnersCollectionAllOf + /// + [DataContract(Name = "ResourceOwnersCollection_allOf")] + public partial class ResourceOwnersCollectionAllOf : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected ResourceOwnersCollectionAllOf() { } + /// + /// Initializes a new instance of the class. + /// + /// items (required). + public ResourceOwnersCollectionAllOf(List items = default(List)) + { + // to ensure "items" is required (not null) + if (items == null) + { + throw new ArgumentNullException("items is a required property for ResourceOwnersCollectionAllOf 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 ResourceOwnersCollectionAllOf {\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 ResourceOwnersCollectionAllOf); + } + + /// + /// Returns true if ResourceOwnersCollectionAllOf instances are equal + /// + /// Instance of ResourceOwnersCollectionAllOf to be compared + /// Boolean + public bool Equals(ResourceOwnersCollectionAllOf 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/ResourceOwnersCollectionFungibleResourceItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs new file mode 100644 index 000000000..3c4fe312f --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs @@ -0,0 +1,201 @@ +/* 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.6.1 + * 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 JsonSubTypes; +using FileParameter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.FileParameter; +using OpenAPIDateConverter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.OpenAPIDateConverter; + +namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model +{ + /// + /// ResourceOwnersCollectionFungibleResourceItem + /// + [DataContract(Name = "ResourceOwnersCollectionFungibleResourceItem")] + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionFungibleResourceItem), "FungibleResource")] + [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionNonFungibleResourceItem), "NonFungibleResource")] + public partial class ResourceOwnersCollectionFungibleResourceItem : ResourceOwnersCollectionItem, IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected ResourceOwnersCollectionFungibleResourceItem() { } + /// + /// Initializes a new instance of the class. + /// + /// String-encoded decimal representing the amount of a related fungible resource. (required). + /// type (required) (default to ResourceOwnersResourceType.FungibleResource). + /// Bech32m-encoded human readable version of the address. (required). + public ResourceOwnersCollectionFungibleResourceItem(string amount = default(string), ResourceOwnersResourceType type = ResourceOwnersResourceType.FungibleResource, string ownerAddress = default(string)) : base(type, ownerAddress) + { + // to ensure "amount" is required (not null) + if (amount == null) + { + throw new ArgumentNullException("amount is a required property for ResourceOwnersCollectionFungibleResourceItem and cannot be null"); + } + this.Amount = amount; + } + + /// + /// String-encoded decimal representing the amount of a related fungible resource. + /// + /// String-encoded decimal representing the amount of a related fungible resource. + [DataMember(Name = "amount", IsRequired = true, EmitDefaultValue = true)] + public string Amount { 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 ResourceOwnersCollectionFungibleResourceItem {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" Amount: ").Append(Amount).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override 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 ResourceOwnersCollectionFungibleResourceItem); + } + + /// + /// Returns true if ResourceOwnersCollectionFungibleResourceItem instances are equal + /// + /// Instance of ResourceOwnersCollectionFungibleResourceItem to be compared + /// Boolean + public bool Equals(ResourceOwnersCollectionFungibleResourceItem input) + { + if (input == null) + { + return false; + } + return base.Equals(input) && + ( + this.Amount == input.Amount || + (this.Amount != null && + this.Amount.Equals(input.Amount)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + if (this.Amount != null) + { + hashCode = (hashCode * 59) + this.Amount.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs new file mode 100644 index 000000000..e80c51715 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs @@ -0,0 +1,214 @@ +/* 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.6.1 + * 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 JsonSubTypes; +using FileParameter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.FileParameter; +using OpenAPIDateConverter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.OpenAPIDateConverter; + +namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model +{ + /// + /// ResourceOwnersCollectionItem + /// + [DataContract(Name = "ResourceOwnersCollectionItem")] + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionFungibleResourceItem), "FungibleResource")] + [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionNonFungibleResourceItem), "NonFungibleResource")] + [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionFungibleResourceItem), "ResourceOwnersCollectionFungibleResourceItem")] + [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionNonFungibleResourceItem), "ResourceOwnersCollectionNonFungibleResourceItem")] + public partial class ResourceOwnersCollectionItem : IEquatable + { + + /// + /// Gets or Sets Type + /// + [DataMember(Name = "type", IsRequired = true, EmitDefaultValue = true)] + public ResourceOwnersResourceType Type { get; set; } + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected ResourceOwnersCollectionItem() { } + /// + /// Initializes a new instance of the class. + /// + /// type (required). + /// Bech32m-encoded human readable version of the address. (required). + public ResourceOwnersCollectionItem(ResourceOwnersResourceType type = default(ResourceOwnersResourceType), string ownerAddress = default(string)) + { + this.Type = type; + // to ensure "ownerAddress" is required (not null) + if (ownerAddress == null) + { + throw new ArgumentNullException("ownerAddress is a required property for ResourceOwnersCollectionItem and cannot be null"); + } + this.OwnerAddress = ownerAddress; + } + + /// + /// Bech32m-encoded human readable version of the address. + /// + /// Bech32m-encoded human readable version of the address. + [DataMember(Name = "owner_address", IsRequired = true, EmitDefaultValue = true)] + public string OwnerAddress { 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 ResourceOwnersCollectionItem {\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append(" OwnerAddress: ").Append(OwnerAddress).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 ResourceOwnersCollectionItem); + } + + /// + /// Returns true if ResourceOwnersCollectionItem instances are equal + /// + /// Instance of ResourceOwnersCollectionItem to be compared + /// Boolean + public bool Equals(ResourceOwnersCollectionItem input) + { + if (input == null) + { + return false; + } + return + ( + this.Type == input.Type || + this.Type.Equals(input.Type) + ) && + ( + this.OwnerAddress == input.OwnerAddress || + (this.OwnerAddress != null && + this.OwnerAddress.Equals(input.OwnerAddress)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Type.GetHashCode(); + if (this.OwnerAddress != null) + { + hashCode = (hashCode * 59) + this.OwnerAddress.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs new file mode 100644 index 000000000..1d6bf272f --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs @@ -0,0 +1,191 @@ +/* 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.6.1 + * 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 JsonSubTypes; +using FileParameter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.FileParameter; +using OpenAPIDateConverter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.OpenAPIDateConverter; + +namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model +{ + /// + /// ResourceOwnersCollectionNonFungibleResourceItem + /// + [DataContract(Name = "ResourceOwnersCollectionNonFungibleResourceItem")] + [JsonConverter(typeof(JsonSubtypes), "type")] + [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionFungibleResourceItem), "FungibleResource")] + [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionNonFungibleResourceItem), "NonFungibleResource")] + public partial class ResourceOwnersCollectionNonFungibleResourceItem : ResourceOwnersCollectionItem, IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected ResourceOwnersCollectionNonFungibleResourceItem() { } + /// + /// Initializes a new instance of the class. + /// + /// nonFungibleIdsCount (required). + /// type (required) (default to ResourceOwnersResourceType.NonFungibleResource). + /// Bech32m-encoded human readable version of the address. (required). + public ResourceOwnersCollectionNonFungibleResourceItem(long nonFungibleIdsCount = default(long), ResourceOwnersResourceType type = ResourceOwnersResourceType.NonFungibleResource, string ownerAddress = default(string)) : base(type, ownerAddress) + { + this.NonFungibleIdsCount = nonFungibleIdsCount; + } + + /// + /// Gets or Sets NonFungibleIdsCount + /// + [DataMember(Name = "non_fungible_ids_count", IsRequired = true, EmitDefaultValue = true)] + public long NonFungibleIdsCount { 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 ResourceOwnersCollectionNonFungibleResourceItem {\n"); + sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); + sb.Append(" NonFungibleIdsCount: ").Append(NonFungibleIdsCount).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public override 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 ResourceOwnersCollectionNonFungibleResourceItem); + } + + /// + /// Returns true if ResourceOwnersCollectionNonFungibleResourceItem instances are equal + /// + /// Instance of ResourceOwnersCollectionNonFungibleResourceItem to be compared + /// Boolean + public bool Equals(ResourceOwnersCollectionNonFungibleResourceItem input) + { + if (input == null) + { + return false; + } + return base.Equals(input) && + ( + this.NonFungibleIdsCount == input.NonFungibleIdsCount || + this.NonFungibleIdsCount.Equals(input.NonFungibleIdsCount) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = base.GetHashCode(); + hashCode = (hashCode * 59) + this.NonFungibleIdsCount.GetHashCode(); + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs new file mode 100644 index 000000000..54c034e42 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs @@ -0,0 +1,184 @@ +/* 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.6.1 + * 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 +{ + /// + /// ResourceOwnersCollectionNonFungibleResourceItemAllOf + /// + [DataContract(Name = "ResourceOwnersCollectionNonFungibleResourceItem_allOf")] + public partial class ResourceOwnersCollectionNonFungibleResourceItemAllOf : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected ResourceOwnersCollectionNonFungibleResourceItemAllOf() { } + /// + /// Initializes a new instance of the class. + /// + /// nonFungibleIdsCount (required). + public ResourceOwnersCollectionNonFungibleResourceItemAllOf(long nonFungibleIdsCount = default(long)) + { + this.NonFungibleIdsCount = nonFungibleIdsCount; + } + + /// + /// Gets or Sets NonFungibleIdsCount + /// + [DataMember(Name = "non_fungible_ids_count", IsRequired = true, EmitDefaultValue = true)] + public long NonFungibleIdsCount { 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 ResourceOwnersCollectionNonFungibleResourceItemAllOf {\n"); + sb.Append(" NonFungibleIdsCount: ").Append(NonFungibleIdsCount).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 ResourceOwnersCollectionNonFungibleResourceItemAllOf); + } + + /// + /// Returns true if ResourceOwnersCollectionNonFungibleResourceItemAllOf instances are equal + /// + /// Instance of ResourceOwnersCollectionNonFungibleResourceItemAllOf to be compared + /// Boolean + public bool Equals(ResourceOwnersCollectionNonFungibleResourceItemAllOf input) + { + if (input == null) + { + return false; + } + return + ( + this.NonFungibleIdsCount == input.NonFungibleIdsCount || + this.NonFungibleIdsCount.Equals(input.NonFungibleIdsCount) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.NonFungibleIdsCount.GetHashCode(); + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs new file mode 100644 index 000000000..281e9510d --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs @@ -0,0 +1,222 @@ +/* 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.6.1 + * 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 +{ + /// + /// ResourceOwnersRequest + /// + [DataContract(Name = "ResourceOwnersRequest")] + public partial class ResourceOwnersRequest : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// This cursor allows forward pagination, by providing the cursor from the previous request.. + /// The page size requested.. + /// Bech32m-encoded human readable version of the address.. + public ResourceOwnersRequest(string cursor = default(string), int? limitPerPage = default(int?), string resourceAddress = default(string)) + { + this.Cursor = cursor; + this.LimitPerPage = limitPerPage; + this.ResourceAddress = resourceAddress; + } + + /// + /// This cursor allows forward pagination, by providing the cursor from the previous request. + /// + /// This cursor allows forward pagination, by providing the cursor from the previous request. + [DataMember(Name = "cursor", EmitDefaultValue = true)] + public string Cursor { get; set; } + + /// + /// The page size requested. + /// + /// The page size requested. + [DataMember(Name = "limit_per_page", EmitDefaultValue = true)] + public int? LimitPerPage { get; set; } + + /// + /// Bech32m-encoded human readable version of the address. + /// + /// Bech32m-encoded human readable version of the address. + [DataMember(Name = "resource_address", EmitDefaultValue = true)] + public string ResourceAddress { 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 ResourceOwnersRequest {\n"); + sb.Append(" Cursor: ").Append(Cursor).Append("\n"); + sb.Append(" LimitPerPage: ").Append(LimitPerPage).Append("\n"); + sb.Append(" ResourceAddress: ").Append(ResourceAddress).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 ResourceOwnersRequest); + } + + /// + /// Returns true if ResourceOwnersRequest instances are equal + /// + /// Instance of ResourceOwnersRequest to be compared + /// Boolean + public bool Equals(ResourceOwnersRequest input) + { + if (input == null) + { + return false; + } + return + ( + this.Cursor == input.Cursor || + (this.Cursor != null && + this.Cursor.Equals(input.Cursor)) + ) && + ( + this.LimitPerPage == input.LimitPerPage || + (this.LimitPerPage != null && + this.LimitPerPage.Equals(input.LimitPerPage)) + ) && + ( + this.ResourceAddress == input.ResourceAddress || + (this.ResourceAddress != null && + this.ResourceAddress.Equals(input.ResourceAddress)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Cursor != null) + { + hashCode = (hashCode * 59) + this.Cursor.GetHashCode(); + } + if (this.LimitPerPage != null) + { + hashCode = (hashCode * 59) + this.LimitPerPage.GetHashCode(); + } + if (this.ResourceAddress != null) + { + hashCode = (hashCode * 59) + this.ResourceAddress.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs new file mode 100644 index 000000000..2d9ca32b5 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs @@ -0,0 +1,184 @@ +/* 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.6.1 + * 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 +{ + /// + /// ResourceOwnersRequestAllOf + /// + [DataContract(Name = "ResourceOwnersRequest_allOf")] + public partial class ResourceOwnersRequestAllOf : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + /// Bech32m-encoded human readable version of the address.. + public ResourceOwnersRequestAllOf(string resourceAddress = default(string)) + { + this.ResourceAddress = resourceAddress; + } + + /// + /// Bech32m-encoded human readable version of the address. + /// + /// Bech32m-encoded human readable version of the address. + [DataMember(Name = "resource_address", EmitDefaultValue = true)] + public string ResourceAddress { 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 ResourceOwnersRequestAllOf {\n"); + sb.Append(" ResourceAddress: ").Append(ResourceAddress).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 ResourceOwnersRequestAllOf); + } + + /// + /// Returns true if ResourceOwnersRequestAllOf instances are equal + /// + /// Instance of ResourceOwnersRequestAllOf to be compared + /// Boolean + public bool Equals(ResourceOwnersRequestAllOf input) + { + if (input == null) + { + return false; + } + return + ( + this.ResourceAddress == input.ResourceAddress || + (this.ResourceAddress != null && + this.ResourceAddress.Equals(input.ResourceAddress)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.ResourceAddress != null) + { + hashCode = (hashCode * 59) + this.ResourceAddress.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs new file mode 100644 index 000000000..5107d2758 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs @@ -0,0 +1,112 @@ +/* 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.6.1 + * 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 +{ + /// + /// Defines ResourceOwnersResourceType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ResourceOwnersResourceType + { + /// + /// Enum FungibleResource for value: FungibleResource + /// + [EnumMember(Value = "FungibleResource")] + FungibleResource = 1, + + /// + /// Enum NonFungibleResource for value: NonFungibleResource + /// + [EnumMember(Value = "NonFungibleResource")] + NonFungibleResource = 2 + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs new file mode 100644 index 000000000..228bf02d0 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs @@ -0,0 +1,193 @@ +/* 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.6.1 + * 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 +{ + /// + /// ResourceOwnersResponse + /// + [DataContract(Name = "ResourceOwnersResponse")] + public partial class ResourceOwnersResponse : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected ResourceOwnersResponse() { } + /// + /// Initializes a new instance of the class. + /// + /// owners (required). + public ResourceOwnersResponse(ResourceOwnersCollection owners = default(ResourceOwnersCollection)) + { + // to ensure "owners" is required (not null) + if (owners == null) + { + throw new ArgumentNullException("owners is a required property for ResourceOwnersResponse and cannot be null"); + } + this.Owners = owners; + } + + /// + /// Gets or Sets Owners + /// + [DataMember(Name = "owners", IsRequired = true, EmitDefaultValue = true)] + public ResourceOwnersCollection Owners { 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 ResourceOwnersResponse {\n"); + sb.Append(" Owners: ").Append(Owners).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 ResourceOwnersResponse); + } + + /// + /// Returns true if ResourceOwnersResponse instances are equal + /// + /// Instance of ResourceOwnersResponse to be compared + /// Boolean + public bool Equals(ResourceOwnersResponse input) + { + if (input == null) + { + return false; + } + return + ( + this.Owners == input.Owners || + (this.Owners != null && + this.Owners.Equals(input.Owners)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Owners != null) + { + hashCode = (hashCode * 59) + this.Owners.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs new file mode 100644 index 000000000..85d523978 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs @@ -0,0 +1,193 @@ +/* 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.6.1 + * 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 +{ + /// + /// ResourceOwnersResponseAllOf + /// + [DataContract(Name = "ResourceOwnersResponse_allOf")] + public partial class ResourceOwnersResponseAllOf : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected ResourceOwnersResponseAllOf() { } + /// + /// Initializes a new instance of the class. + /// + /// owners (required). + public ResourceOwnersResponseAllOf(ResourceOwnersCollection owners = default(ResourceOwnersCollection)) + { + // to ensure "owners" is required (not null) + if (owners == null) + { + throw new ArgumentNullException("owners is a required property for ResourceOwnersResponseAllOf and cannot be null"); + } + this.Owners = owners; + } + + /// + /// Gets or Sets Owners + /// + [DataMember(Name = "owners", IsRequired = true, EmitDefaultValue = true)] + public ResourceOwnersCollection Owners { 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 ResourceOwnersResponseAllOf {\n"); + sb.Append(" Owners: ").Append(Owners).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 ResourceOwnersResponseAllOf); + } + + /// + /// Returns true if ResourceOwnersResponseAllOf instances are equal + /// + /// Instance of ResourceOwnersResponseAllOf to be compared + /// Boolean + public bool Equals(ResourceOwnersResponseAllOf input) + { + if (input == null) + { + return false; + } + return + ( + this.Owners == input.Owners || + (this.Owners != null && + this.Owners.Equals(input.Owners)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Owners != null) + { + hashCode = (hashCode * 59) + this.Owners.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs new file mode 100644 index 000000000..52c6bc7c1 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs @@ -0,0 +1,231 @@ +/* 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 NpgsqlTypes; +using RadixDlt.NetworkGateway.Abstractions; +using RadixDlt.NetworkGateway.Abstractions.Extensions; +using RadixDlt.NetworkGateway.PostgresIntegration.Models; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; +using CoreModel = RadixDlt.CoreApiSdk.Model; + +namespace RadixDlt.NetworkGateway.PostgresIntegration.LedgerExtension; + +public record ResourceOwner(EntityAddress OwnerAddress); + +public record FungibleResourceOwner(EntityAddress OwnerAddress, string Amount) : ResourceOwner(OwnerAddress); + +public record NonFungibleResourceOwner(EntityAddress OwnerAddress, long NfidCount) : ResourceOwner(OwnerAddress); + +internal class ResourceOwnersProcessor +{ + private readonly ProcessorContext _context; + private readonly ReferencedEntityDictionary _referencedEntities; + private readonly Dictionary> _resourceOwners; + + private List _toAdd = new(); + + public ResourceOwnersProcessor(ProcessorContext context, ReferencedEntityDictionary referencedEntities) + { + _context = context; + _referencedEntities = referencedEntities; + } + + public void VisitUpsert(CoreModel.IUpsertedSubstate substate, ReferencedEntity referencedEntity, long stateVersion) + { + var substateData = substate.Value.SubstateData; + + if (substateData is CoreModel.GenericScryptoComponentFieldStateSubstate componentState) + { + if (substate.SystemStructure is not CoreModel.ObjectFieldStructure objectFieldStructure) + { + throw new UnreachableException($"Generic Scrypto components are expected to have ObjectFieldStructure. Got: {substate.SystemStructure.GetType()}"); + } + + var schemaDetails = objectFieldStructure.ValueSchema.GetSchemaDetails(); + + _toAdd.Add(new SborStateHistory + { + Id = _context.Sequences.StateHistorySequence++, + FromStateVersion = stateVersion, + EntityId = referencedEntity.DatabaseId, + SborState = componentState.Value.DataStruct.StructData.GetDataBytes(), + SchemaHash = schemaDetails.SchemaHash.ConvertFromHex(), + SborTypeKind = schemaDetails.SborTypeKind.ToModel(), + TypeIndex = schemaDetails.TypeIndex, + SchemaDefiningEntityId = _referencedEntities.Get((EntityAddress)schemaDetails.SchemaDefiningEntityAddress).DatabaseId, + }); + } + + if (substateData is CoreModel.ValidatorFieldStateSubstate validator) + { + _toAdd.Add(new JsonStateHistory + { + Id = _context.Sequences.StateHistorySequence++, + FromStateVersion = stateVersion, + EntityId = referencedEntity.DatabaseId, + JsonState = validator.Value.ToJson(), + }); + } + + if (substateData is CoreModel.AccountFieldStateSubstate accountFieldState) + { + _toAdd.Add(new JsonStateHistory + { + Id = _context.Sequences.StateHistorySequence++, + FromStateVersion = stateVersion, + EntityId = referencedEntity.DatabaseId, + JsonState = accountFieldState.Value.ToJson(), + }); + } + + if (substateData is CoreModel.AccessControllerFieldStateSubstate accessControllerFieldState) + { + _toAdd.Add(new JsonStateHistory + { + Id = _context.Sequences.StateHistorySequence++, + FromStateVersion = stateVersion, + EntityId = referencedEntity.DatabaseId, + JsonState = accessControllerFieldState.Value.ToJson(), + }); + } + + if (substateData is CoreModel.OneResourcePoolFieldStateSubstate oneResourcePoolFieldStateSubstate) + { + _toAdd.Add(new JsonStateHistory + { + Id = _context.Sequences.StateHistorySequence++, + FromStateVersion = stateVersion, + EntityId = referencedEntity.DatabaseId, + JsonState = oneResourcePoolFieldStateSubstate.Value.ToJson(), + }); + } + + if (substateData is CoreModel.TwoResourcePoolFieldStateSubstate twoResourcePoolFieldStateSubstate) + { + _toAdd.Add(new JsonStateHistory + { + Id = _context.Sequences.StateHistorySequence++, + FromStateVersion = stateVersion, + EntityId = referencedEntity.DatabaseId, + JsonState = twoResourcePoolFieldStateSubstate.Value.ToJson(), + }); + } + + if (substateData is CoreModel.MultiResourcePoolFieldStateSubstate multiResourcePoolFieldStateSubstate) + { + _toAdd.Add(new JsonStateHistory + { + Id = _context.Sequences.StateHistorySequence++, + FromStateVersion = stateVersion, + EntityId = referencedEntity.DatabaseId, + JsonState = multiResourcePoolFieldStateSubstate.Value.ToJson(), + }); + } + } + + public async Task SaveEntities() + { + var rowsInserted = 0; + + rowsInserted += await CopyStateHistory(); + + return rowsInserted; + } + + private Task CopyStateHistory() => _context.WriteHelper.Copy( + _toAdd, + "COPY state_history (id, from_state_version, entity_id, discriminator, json_state, sbor_state, type_index, schema_hash, sbor_type_kind, schema_defining_entity_id) FROM STDIN (FORMAT BINARY)", + async (writer, e, token) => + { + await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.FromStateVersion, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(_context.WriteHelper.GetDiscriminator(e.GetType()), "state_type", token); + + switch (e) + { + case JsonStateHistory jsonStateHistory: + await writer.WriteAsync(jsonStateHistory.JsonState, NpgsqlDbType.Jsonb, token); + await writer.WriteNullAsync(token); + await writer.WriteNullAsync(token); + await writer.WriteNullAsync(token); + await writer.WriteNullAsync(token); + await writer.WriteNullAsync(token); + break; + case SborStateHistory sborStateHistory: + await writer.WriteNullAsync(token); + await writer.WriteAsync(sborStateHistory.SborState, NpgsqlDbType.Bytea, token); + await writer.WriteAsync(sborStateHistory.TypeIndex, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(sborStateHistory.SchemaHash, NpgsqlDbType.Bytea, token); + await writer.WriteAsync(sborStateHistory.SborTypeKind, "sbor_type_kind", token); + await writer.WriteAsync(sborStateHistory.SchemaDefiningEntityId, NpgsqlDbType.Bigint, token); + break; + default: + throw new ArgumentOutOfRangeException(nameof(e), e, null); + } + }); +} diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs new file mode 100644 index 000000000..274ba4056 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs @@ -0,0 +1,19 @@ +using RadixDlt.NetworkGateway.Abstractions; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace RadixDlt.NetworkGateway.PostgresIntegration.Models; + +[Table("resource_owners")] +internal class ResourceOwners +{ + [Key] + [Column("id")] + public long Id { get; set; } + + [Column("from_state_version")] + public long FromStateVersion { get; set; } + + [Column("resource_address")] + public EntityAddress ResourceAddress { get; set; } +} From 843307b54823e3fdc1d69f5bd1e148b14284c33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Wed, 31 Jul 2024 16:14:42 +0200 Subject: [PATCH 02/18] regenerate tyescript sdk. --- .../lib/generated/.openapi-generator/FILES | 16 ++++ .../lib/generated/apis/ExtensionsApi.ts | 75 +++++++++++++++ sdk/typescript/lib/generated/apis/index.ts | 1 + .../ProgrammaticScryptoSborValueEnum.ts | 4 +- .../ProgrammaticScryptoSborValueEnumAllOf.ts | 4 +- .../models/ProgrammaticScryptoSborValueOwn.ts | 2 +- .../ProgrammaticScryptoSborValueOwnAllOf.ts | 2 +- .../ProgrammaticScryptoSborValueReference.ts | 2 +- ...grammaticScryptoSborValueReferenceAllOf.ts | 2 +- .../models/ResourceOwnersCollection.ts | 89 ++++++++++++++++++ .../models/ResourceOwnersCollectionAllOf.ts | 73 ++++++++++++++ ...rceOwnersCollectionFungibleResourceItem.ts | 94 +++++++++++++++++++ ...nersCollectionFungibleResourceItemAllOf.ts | 84 +++++++++++++++++ .../models/ResourceOwnersCollectionItem.ts | 72 ++++++++++++++ .../ResourceOwnersCollectionItemBase.ts | 82 ++++++++++++++++ ...OwnersCollectionNonFungibleResourceItem.ts | 94 +++++++++++++++++++ ...sCollectionNonFungibleResourceItemAllOf.ts | 84 +++++++++++++++++ .../generated/models/ResourceOwnersRequest.ts | 81 ++++++++++++++++ .../models/ResourceOwnersRequestAllOf.ts | 65 +++++++++++++ .../models/ResourceOwnersResourceType.ts | 38 ++++++++ .../models/ResourceOwnersResponse.ts | 73 ++++++++++++++ .../models/ResourceOwnersResponseAllOf.ts | 73 ++++++++++++++ ...StateKeyValueStoreDataRequestHexKeyItem.ts | 66 +++++++++++++ ...tateKeyValueStoreDataRequestJsonKeyItem.ts | 73 ++++++++++++++ .../StateKeyValueStoreDataRequestKeyItem.ts | 65 +++++-------- sdk/typescript/lib/generated/models/index.ts | 15 +++ 26 files changed, 1281 insertions(+), 48 deletions(-) create mode 100644 sdk/typescript/lib/generated/apis/ExtensionsApi.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollection.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionAllOf.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItem.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionItem.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionItemBase.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItem.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersRequest.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersRequestAllOf.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersResourceType.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersResponse.ts create mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersResponseAllOf.ts create mode 100644 sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestHexKeyItem.ts create mode 100644 sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestJsonKeyItem.ts diff --git a/sdk/typescript/lib/generated/.openapi-generator/FILES b/sdk/typescript/lib/generated/.openapi-generator/FILES index 113fcbe07..1c64ced08 100644 --- a/sdk/typescript/lib/generated/.openapi-generator/FILES +++ b/sdk/typescript/lib/generated/.openapi-generator/FILES @@ -1,4 +1,5 @@ .openapi-generator-ignore +apis/ExtensionsApi.ts apis/StateApi.ts apis/StatisticsApi.ts apis/StatusApi.ts @@ -255,6 +256,19 @@ models/PublicKeyHashEddsaEd25519AllOf.ts models/PublicKeyHashType.ts models/PublicKeyType.ts models/ResourceAggregationLevel.ts +models/ResourceOwnersCollection.ts +models/ResourceOwnersCollectionAllOf.ts +models/ResourceOwnersCollectionFungibleResourceItem.ts +models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts +models/ResourceOwnersCollectionItem.ts +models/ResourceOwnersCollectionItemBase.ts +models/ResourceOwnersCollectionNonFungibleResourceItem.ts +models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts +models/ResourceOwnersRequest.ts +models/ResourceOwnersRequestAllOf.ts +models/ResourceOwnersResourceType.ts +models/ResourceOwnersResponse.ts +models/ResourceOwnersResponseAllOf.ts models/ResultSetCursorMixin.ts models/RoleAssignmentResolution.ts models/RoleKey.ts @@ -320,6 +334,8 @@ models/StateEntitySchemaPageRequest.ts models/StateEntitySchemaPageResponse.ts models/StateKeyValueStoreDataRequest.ts models/StateKeyValueStoreDataRequestAllOf.ts +models/StateKeyValueStoreDataRequestHexKeyItem.ts +models/StateKeyValueStoreDataRequestJsonKeyItem.ts models/StateKeyValueStoreDataRequestKeyItem.ts models/StateKeyValueStoreDataResponse.ts models/StateKeyValueStoreDataResponseAllOf.ts diff --git a/sdk/typescript/lib/generated/apis/ExtensionsApi.ts b/sdk/typescript/lib/generated/apis/ExtensionsApi.ts new file mode 100644 index 000000000..77f85db5b --- /dev/null +++ b/sdk/typescript/lib/generated/apis/ExtensionsApi.ts @@ -0,0 +1,75 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +import * as runtime from '../runtime'; +import type { + ErrorResponse, + ResourceOwnersRequest, + ResourceOwnersResponse, +} from '../models'; +import { + ErrorResponseFromJSON, + ErrorResponseToJSON, + ResourceOwnersRequestFromJSON, + ResourceOwnersRequestToJSON, + ResourceOwnersResponseFromJSON, + ResourceOwnersResponseToJSON, +} from '../models'; + +export interface ResourceOwnersPageRequest { + resourceOwnersRequest: ResourceOwnersRequest; +} + +/** + * + */ +export class ExtensionsApi extends runtime.BaseAPI { + + /** + * Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + * Get Resource Owners Page + */ + async resourceOwnersPageRaw(requestParameters: ResourceOwnersPageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { + if (requestParameters.resourceOwnersRequest === null || requestParameters.resourceOwnersRequest === undefined) { + throw new runtime.RequiredError('resourceOwnersRequest','Required parameter requestParameters.resourceOwnersRequest was null or undefined when calling resourceOwnersPage.'); + } + + const queryParameters: any = {}; + + const headerParameters: runtime.HTTPHeaders = {}; + + headerParameters['Content-Type'] = 'application/json'; + + const response = await this.request({ + path: `/extensions/resource-owners/page`, + method: 'POST', + headers: headerParameters, + query: queryParameters, + body: ResourceOwnersRequestToJSON(requestParameters.resourceOwnersRequest), + }, initOverrides); + + return new runtime.JSONApiResponse(response, (jsonValue) => ResourceOwnersResponseFromJSON(jsonValue)); + } + + /** + * Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + * Get Resource Owners Page + */ + async resourceOwnersPage(requestParameters: ResourceOwnersPageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { + const response = await this.resourceOwnersPageRaw(requestParameters, initOverrides); + return await response.value(); + } + +} diff --git a/sdk/typescript/lib/generated/apis/index.ts b/sdk/typescript/lib/generated/apis/index.ts index 1707abc3c..6f732ce8a 100644 --- a/sdk/typescript/lib/generated/apis/index.ts +++ b/sdk/typescript/lib/generated/apis/index.ts @@ -1,5 +1,6 @@ /* tslint:disable */ /* eslint-disable */ +export * from './ExtensionsApi'; export * from './StateApi'; export * from './StatisticsApi'; export * from './StatusApi'; diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnum.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnum.ts index dd6088877..632f660cd 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnum.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnum.ts @@ -52,10 +52,10 @@ This property is ignored when the value is used as an input to the API. field_name?: string | null; /** * - * @type {number} + * @type {string} * @memberof ProgrammaticScryptoSborValueEnum */ - variant_id: number; + variant_id: string; /** * * @type {string} diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnumAllOf.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnumAllOf.ts index d95cf89f2..4b3272391 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnumAllOf.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnumAllOf.ts @@ -28,10 +28,10 @@ import { export interface ProgrammaticScryptoSborValueEnumAllOf { /** * - * @type {number} + * @type {string} * @memberof ProgrammaticScryptoSborValueEnumAllOf */ - variant_id: number; + variant_id: string; /** * * @type {string} diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwn.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwn.ts index 520d46ff0..8d5249e4e 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwn.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwn.ts @@ -44,7 +44,7 @@ This property is ignored when the value is used as an input to the API. */ field_name?: string | null; /** - * + * Bech32m-encoded human readable version of the address. * @type {string} * @memberof ProgrammaticScryptoSborValueOwn */ diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwnAllOf.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwnAllOf.ts index fc2a27a78..7ccfe4f4e 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwnAllOf.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwnAllOf.ts @@ -20,7 +20,7 @@ import { exists, mapValues } from '../runtime'; */ export interface ProgrammaticScryptoSborValueOwnAllOf { /** - * + * Bech32m-encoded human readable version of the address. * @type {string} * @memberof ProgrammaticScryptoSborValueOwnAllOf */ diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReference.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReference.ts index e1f3de1a7..762dce592 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReference.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReference.ts @@ -44,7 +44,7 @@ This property is ignored when the value is used as an input to the API. */ field_name?: string | null; /** - * + * Bech32m-encoded human readable version of the address. * @type {string} * @memberof ProgrammaticScryptoSborValueReference */ diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReferenceAllOf.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReferenceAllOf.ts index 84381ae6d..bc46a0f4a 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReferenceAllOf.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReferenceAllOf.ts @@ -20,7 +20,7 @@ import { exists, mapValues } from '../runtime'; */ export interface ProgrammaticScryptoSborValueReferenceAllOf { /** - * + * Bech32m-encoded human readable version of the address. * @type {string} * @memberof ProgrammaticScryptoSborValueReferenceAllOf */ diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollection.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollection.ts new file mode 100644 index 000000000..68e3c1e16 --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersCollection.ts @@ -0,0 +1,89 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ResourceOwnersCollectionItem } from './ResourceOwnersCollectionItem'; +import { + ResourceOwnersCollectionItemFromJSON, + ResourceOwnersCollectionItemFromJSONTyped, + ResourceOwnersCollectionItemToJSON, +} from './ResourceOwnersCollectionItem'; + +/** + * + * @export + * @interface ResourceOwnersCollection + */ +export interface ResourceOwnersCollection { + /** + * Total number of items in underlying collection, fragment of which is available in `items` collection. + * @type {number} + * @memberof ResourceOwnersCollection + */ + total_count?: number | null; + /** + * If specified, contains a cursor to query next page of the `items` collection. + * @type {string} + * @memberof ResourceOwnersCollection + */ + next_cursor?: string | null; + /** + * + * @type {Array} + * @memberof ResourceOwnersCollection + */ + items: Array; +} + +/** + * Check if a given object implements the ResourceOwnersCollection interface. + */ +export function instanceOfResourceOwnersCollection(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "items" in value; + + return isInstance; +} + +export function ResourceOwnersCollectionFromJSON(json: any): ResourceOwnersCollection { + return ResourceOwnersCollectionFromJSONTyped(json, false); +} + +export function ResourceOwnersCollectionFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollection { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'total_count': !exists(json, 'total_count') ? undefined : json['total_count'], + 'next_cursor': !exists(json, 'next_cursor') ? undefined : json['next_cursor'], + 'items': ((json['items'] as Array).map(ResourceOwnersCollectionItemFromJSON)), + }; +} + +export function ResourceOwnersCollectionToJSON(value?: ResourceOwnersCollection | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'total_count': value.total_count, + 'next_cursor': value.next_cursor, + 'items': ((value.items as Array).map(ResourceOwnersCollectionItemToJSON)), + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionAllOf.ts new file mode 100644 index 000000000..740790c8c --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionAllOf.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ResourceOwnersCollectionItem } from './ResourceOwnersCollectionItem'; +import { + ResourceOwnersCollectionItemFromJSON, + ResourceOwnersCollectionItemFromJSONTyped, + ResourceOwnersCollectionItemToJSON, +} from './ResourceOwnersCollectionItem'; + +/** + * + * @export + * @interface ResourceOwnersCollectionAllOf + */ +export interface ResourceOwnersCollectionAllOf { + /** + * + * @type {Array} + * @memberof ResourceOwnersCollectionAllOf + */ + items: Array; +} + +/** + * Check if a given object implements the ResourceOwnersCollectionAllOf interface. + */ +export function instanceOfResourceOwnersCollectionAllOf(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "items" in value; + + return isInstance; +} + +export function ResourceOwnersCollectionAllOfFromJSON(json: any): ResourceOwnersCollectionAllOf { + return ResourceOwnersCollectionAllOfFromJSONTyped(json, false); +} + +export function ResourceOwnersCollectionAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionAllOf { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'items': ((json['items'] as Array).map(ResourceOwnersCollectionItemFromJSON)), + }; +} + +export function ResourceOwnersCollectionAllOfToJSON(value?: ResourceOwnersCollectionAllOf | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'items': ((value.items as Array).map(ResourceOwnersCollectionItemToJSON)), + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItem.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItem.ts new file mode 100644 index 000000000..b767dda06 --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItem.ts @@ -0,0 +1,94 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface ResourceOwnersCollectionFungibleResourceItem + */ +export interface ResourceOwnersCollectionFungibleResourceItem { + /** + * + * @type {string} + * @memberof ResourceOwnersCollectionFungibleResourceItem + */ + type: ResourceOwnersCollectionFungibleResourceItemTypeEnum; + /** + * Bech32m-encoded human readable version of the address. + * @type {string} + * @memberof ResourceOwnersCollectionFungibleResourceItem + */ + owner_address: string; + /** + * String-encoded decimal representing the amount of a related fungible resource. + * @type {string} + * @memberof ResourceOwnersCollectionFungibleResourceItem + */ + amount: string; +} + + +/** + * @export + */ +export const ResourceOwnersCollectionFungibleResourceItemTypeEnum = { + FungibleResource: 'FungibleResource' +} as const; +export type ResourceOwnersCollectionFungibleResourceItemTypeEnum = typeof ResourceOwnersCollectionFungibleResourceItemTypeEnum[keyof typeof ResourceOwnersCollectionFungibleResourceItemTypeEnum]; + + +/** + * Check if a given object implements the ResourceOwnersCollectionFungibleResourceItem interface. + */ +export function instanceOfResourceOwnersCollectionFungibleResourceItem(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "type" in value; + isInstance = isInstance && "owner_address" in value; + isInstance = isInstance && "amount" in value; + + return isInstance; +} + +export function ResourceOwnersCollectionFungibleResourceItemFromJSON(json: any): ResourceOwnersCollectionFungibleResourceItem { + return ResourceOwnersCollectionFungibleResourceItemFromJSONTyped(json, false); +} + +export function ResourceOwnersCollectionFungibleResourceItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionFungibleResourceItem { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'type': json['type'], + 'owner_address': json['owner_address'], + 'amount': json['amount'], + }; +} + +export function ResourceOwnersCollectionFungibleResourceItemToJSON(value?: ResourceOwnersCollectionFungibleResourceItem | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'type': value.type, + 'owner_address': value.owner_address, + 'amount': value.amount, + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts new file mode 100644 index 000000000..db1aafaec --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts @@ -0,0 +1,84 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface ResourceOwnersCollectionFungibleResourceItemAllOf + */ +export interface ResourceOwnersCollectionFungibleResourceItemAllOf { + /** + * String-encoded decimal representing the amount of a related fungible resource. + * @type {string} + * @memberof ResourceOwnersCollectionFungibleResourceItemAllOf + */ + amount: string; + /** + * + * @type {string} + * @memberof ResourceOwnersCollectionFungibleResourceItemAllOf + */ + type?: ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum; +} + + +/** + * @export + */ +export const ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum = { + FungibleResource: 'FungibleResource' +} as const; +export type ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum = typeof ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum[keyof typeof ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum]; + + +/** + * Check if a given object implements the ResourceOwnersCollectionFungibleResourceItemAllOf interface. + */ +export function instanceOfResourceOwnersCollectionFungibleResourceItemAllOf(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "amount" in value; + + return isInstance; +} + +export function ResourceOwnersCollectionFungibleResourceItemAllOfFromJSON(json: any): ResourceOwnersCollectionFungibleResourceItemAllOf { + return ResourceOwnersCollectionFungibleResourceItemAllOfFromJSONTyped(json, false); +} + +export function ResourceOwnersCollectionFungibleResourceItemAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionFungibleResourceItemAllOf { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'amount': json['amount'], + 'type': !exists(json, 'type') ? undefined : json['type'], + }; +} + +export function ResourceOwnersCollectionFungibleResourceItemAllOfToJSON(value?: ResourceOwnersCollectionFungibleResourceItemAllOf | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'amount': value.amount, + 'type': value.type, + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItem.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItem.ts new file mode 100644 index 000000000..ed7d32a1c --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItem.ts @@ -0,0 +1,72 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { + ResourceOwnersCollectionFungibleResourceItem, + instanceOfResourceOwnersCollectionFungibleResourceItem, + ResourceOwnersCollectionFungibleResourceItemFromJSON, + ResourceOwnersCollectionFungibleResourceItemFromJSONTyped, + ResourceOwnersCollectionFungibleResourceItemToJSON, +} from './ResourceOwnersCollectionFungibleResourceItem'; +import { + ResourceOwnersCollectionNonFungibleResourceItem, + instanceOfResourceOwnersCollectionNonFungibleResourceItem, + ResourceOwnersCollectionNonFungibleResourceItemFromJSON, + ResourceOwnersCollectionNonFungibleResourceItemFromJSONTyped, + ResourceOwnersCollectionNonFungibleResourceItemToJSON, +} from './ResourceOwnersCollectionNonFungibleResourceItem'; + +/** + * @type ResourceOwnersCollectionItem + * + * @export + */ +export type ResourceOwnersCollectionItem = { type: 'FungibleResource' } & ResourceOwnersCollectionFungibleResourceItem | { type: 'NonFungibleResource' } & ResourceOwnersCollectionNonFungibleResourceItem; + +export function ResourceOwnersCollectionItemFromJSON(json: any): ResourceOwnersCollectionItem { + return ResourceOwnersCollectionItemFromJSONTyped(json, false); +} + +export function ResourceOwnersCollectionItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionItem { + if ((json === undefined) || (json === null)) { + return json; + } + switch (json['type']) { + case 'FungibleResource': + return {...ResourceOwnersCollectionFungibleResourceItemFromJSONTyped(json, true), type: 'FungibleResource'}; + case 'NonFungibleResource': + return {...ResourceOwnersCollectionNonFungibleResourceItemFromJSONTyped(json, true), type: 'NonFungibleResource'}; + default: + throw new Error(`No variant of ResourceOwnersCollectionItem exists with 'type=${json['type']}'`); + } +} + +export function ResourceOwnersCollectionItemToJSON(value?: ResourceOwnersCollectionItem | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + switch (value['type']) { + case 'FungibleResource': + return ResourceOwnersCollectionFungibleResourceItemToJSON(value); + case 'NonFungibleResource': + return ResourceOwnersCollectionNonFungibleResourceItemToJSON(value); + default: + throw new Error(`No variant of ResourceOwnersCollectionItem exists with 'type=${value['type']}'`); + } + +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItemBase.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItemBase.ts new file mode 100644 index 000000000..88e1ef357 --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItemBase.ts @@ -0,0 +1,82 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ResourceOwnersResourceType } from './ResourceOwnersResourceType'; +import { + ResourceOwnersResourceTypeFromJSON, + ResourceOwnersResourceTypeFromJSONTyped, + ResourceOwnersResourceTypeToJSON, +} from './ResourceOwnersResourceType'; + +/** + * + * @export + * @interface ResourceOwnersCollectionItemBase + */ +export interface ResourceOwnersCollectionItemBase { + /** + * + * @type {ResourceOwnersResourceType} + * @memberof ResourceOwnersCollectionItemBase + */ + type: ResourceOwnersResourceType; + /** + * Bech32m-encoded human readable version of the address. + * @type {string} + * @memberof ResourceOwnersCollectionItemBase + */ + owner_address: string; +} + +/** + * Check if a given object implements the ResourceOwnersCollectionItemBase interface. + */ +export function instanceOfResourceOwnersCollectionItemBase(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "type" in value; + isInstance = isInstance && "owner_address" in value; + + return isInstance; +} + +export function ResourceOwnersCollectionItemBaseFromJSON(json: any): ResourceOwnersCollectionItemBase { + return ResourceOwnersCollectionItemBaseFromJSONTyped(json, false); +} + +export function ResourceOwnersCollectionItemBaseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionItemBase { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'type': ResourceOwnersResourceTypeFromJSON(json['type']), + 'owner_address': json['owner_address'], + }; +} + +export function ResourceOwnersCollectionItemBaseToJSON(value?: ResourceOwnersCollectionItemBase | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'type': ResourceOwnersResourceTypeToJSON(value.type), + 'owner_address': value.owner_address, + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItem.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItem.ts new file mode 100644 index 000000000..7aad508a1 --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItem.ts @@ -0,0 +1,94 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface ResourceOwnersCollectionNonFungibleResourceItem + */ +export interface ResourceOwnersCollectionNonFungibleResourceItem { + /** + * + * @type {string} + * @memberof ResourceOwnersCollectionNonFungibleResourceItem + */ + type: ResourceOwnersCollectionNonFungibleResourceItemTypeEnum; + /** + * Bech32m-encoded human readable version of the address. + * @type {string} + * @memberof ResourceOwnersCollectionNonFungibleResourceItem + */ + owner_address: string; + /** + * + * @type {number} + * @memberof ResourceOwnersCollectionNonFungibleResourceItem + */ + non_fungible_ids_count: number; +} + + +/** + * @export + */ +export const ResourceOwnersCollectionNonFungibleResourceItemTypeEnum = { + NonFungibleResource: 'NonFungibleResource' +} as const; +export type ResourceOwnersCollectionNonFungibleResourceItemTypeEnum = typeof ResourceOwnersCollectionNonFungibleResourceItemTypeEnum[keyof typeof ResourceOwnersCollectionNonFungibleResourceItemTypeEnum]; + + +/** + * Check if a given object implements the ResourceOwnersCollectionNonFungibleResourceItem interface. + */ +export function instanceOfResourceOwnersCollectionNonFungibleResourceItem(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "type" in value; + isInstance = isInstance && "owner_address" in value; + isInstance = isInstance && "non_fungible_ids_count" in value; + + return isInstance; +} + +export function ResourceOwnersCollectionNonFungibleResourceItemFromJSON(json: any): ResourceOwnersCollectionNonFungibleResourceItem { + return ResourceOwnersCollectionNonFungibleResourceItemFromJSONTyped(json, false); +} + +export function ResourceOwnersCollectionNonFungibleResourceItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionNonFungibleResourceItem { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'type': json['type'], + 'owner_address': json['owner_address'], + 'non_fungible_ids_count': json['non_fungible_ids_count'], + }; +} + +export function ResourceOwnersCollectionNonFungibleResourceItemToJSON(value?: ResourceOwnersCollectionNonFungibleResourceItem | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'type': value.type, + 'owner_address': value.owner_address, + 'non_fungible_ids_count': value.non_fungible_ids_count, + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts new file mode 100644 index 000000000..857994b0d --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts @@ -0,0 +1,84 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface ResourceOwnersCollectionNonFungibleResourceItemAllOf + */ +export interface ResourceOwnersCollectionNonFungibleResourceItemAllOf { + /** + * + * @type {number} + * @memberof ResourceOwnersCollectionNonFungibleResourceItemAllOf + */ + non_fungible_ids_count: number; + /** + * + * @type {string} + * @memberof ResourceOwnersCollectionNonFungibleResourceItemAllOf + */ + type?: ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum; +} + + +/** + * @export + */ +export const ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum = { + NonFungibleResource: 'NonFungibleResource' +} as const; +export type ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum = typeof ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum[keyof typeof ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum]; + + +/** + * Check if a given object implements the ResourceOwnersCollectionNonFungibleResourceItemAllOf interface. + */ +export function instanceOfResourceOwnersCollectionNonFungibleResourceItemAllOf(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "non_fungible_ids_count" in value; + + return isInstance; +} + +export function ResourceOwnersCollectionNonFungibleResourceItemAllOfFromJSON(json: any): ResourceOwnersCollectionNonFungibleResourceItemAllOf { + return ResourceOwnersCollectionNonFungibleResourceItemAllOfFromJSONTyped(json, false); +} + +export function ResourceOwnersCollectionNonFungibleResourceItemAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionNonFungibleResourceItemAllOf { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'non_fungible_ids_count': json['non_fungible_ids_count'], + 'type': !exists(json, 'type') ? undefined : json['type'], + }; +} + +export function ResourceOwnersCollectionNonFungibleResourceItemAllOfToJSON(value?: ResourceOwnersCollectionNonFungibleResourceItemAllOf | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'non_fungible_ids_count': value.non_fungible_ids_count, + 'type': value.type, + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersRequest.ts b/sdk/typescript/lib/generated/models/ResourceOwnersRequest.ts new file mode 100644 index 000000000..ab6155c7e --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersRequest.ts @@ -0,0 +1,81 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface ResourceOwnersRequest + */ +export interface ResourceOwnersRequest { + /** + * This cursor allows forward pagination, by providing the cursor from the previous request. + * @type {string} + * @memberof ResourceOwnersRequest + */ + cursor?: string | null; + /** + * The page size requested. + * @type {number} + * @memberof ResourceOwnersRequest + */ + limit_per_page?: number | null; + /** + * Bech32m-encoded human readable version of the address. + * @type {string} + * @memberof ResourceOwnersRequest + */ + resource_address?: string; +} + +/** + * Check if a given object implements the ResourceOwnersRequest interface. + */ +export function instanceOfResourceOwnersRequest(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function ResourceOwnersRequestFromJSON(json: any): ResourceOwnersRequest { + return ResourceOwnersRequestFromJSONTyped(json, false); +} + +export function ResourceOwnersRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersRequest { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'cursor': !exists(json, 'cursor') ? undefined : json['cursor'], + 'limit_per_page': !exists(json, 'limit_per_page') ? undefined : json['limit_per_page'], + 'resource_address': !exists(json, 'resource_address') ? undefined : json['resource_address'], + }; +} + +export function ResourceOwnersRequestToJSON(value?: ResourceOwnersRequest | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'cursor': value.cursor, + 'limit_per_page': value.limit_per_page, + 'resource_address': value.resource_address, + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersRequestAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersRequestAllOf.ts new file mode 100644 index 000000000..ab1f09dac --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersRequestAllOf.ts @@ -0,0 +1,65 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface ResourceOwnersRequestAllOf + */ +export interface ResourceOwnersRequestAllOf { + /** + * Bech32m-encoded human readable version of the address. + * @type {string} + * @memberof ResourceOwnersRequestAllOf + */ + resource_address?: string; +} + +/** + * Check if a given object implements the ResourceOwnersRequestAllOf interface. + */ +export function instanceOfResourceOwnersRequestAllOf(value: object): boolean { + let isInstance = true; + + return isInstance; +} + +export function ResourceOwnersRequestAllOfFromJSON(json: any): ResourceOwnersRequestAllOf { + return ResourceOwnersRequestAllOfFromJSONTyped(json, false); +} + +export function ResourceOwnersRequestAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersRequestAllOf { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'resource_address': !exists(json, 'resource_address') ? undefined : json['resource_address'], + }; +} + +export function ResourceOwnersRequestAllOfToJSON(value?: ResourceOwnersRequestAllOf | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'resource_address': value.resource_address, + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersResourceType.ts b/sdk/typescript/lib/generated/models/ResourceOwnersResourceType.ts new file mode 100644 index 000000000..5265faba6 --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersResourceType.ts @@ -0,0 +1,38 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +/** + * + * @export + */ +export const ResourceOwnersResourceType = { + FungibleResource: 'FungibleResource', + NonFungibleResource: 'NonFungibleResource' +} as const; +export type ResourceOwnersResourceType = typeof ResourceOwnersResourceType[keyof typeof ResourceOwnersResourceType]; + + +export function ResourceOwnersResourceTypeFromJSON(json: any): ResourceOwnersResourceType { + return ResourceOwnersResourceTypeFromJSONTyped(json, false); +} + +export function ResourceOwnersResourceTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersResourceType { + return json as ResourceOwnersResourceType; +} + +export function ResourceOwnersResourceTypeToJSON(value?: ResourceOwnersResourceType | null): any { + return value as any; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersResponse.ts b/sdk/typescript/lib/generated/models/ResourceOwnersResponse.ts new file mode 100644 index 000000000..efcc70f3e --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersResponse.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ResourceOwnersCollection } from './ResourceOwnersCollection'; +import { + ResourceOwnersCollectionFromJSON, + ResourceOwnersCollectionFromJSONTyped, + ResourceOwnersCollectionToJSON, +} from './ResourceOwnersCollection'; + +/** + * + * @export + * @interface ResourceOwnersResponse + */ +export interface ResourceOwnersResponse { + /** + * + * @type {ResourceOwnersCollection} + * @memberof ResourceOwnersResponse + */ + owners: ResourceOwnersCollection; +} + +/** + * Check if a given object implements the ResourceOwnersResponse interface. + */ +export function instanceOfResourceOwnersResponse(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "owners" in value; + + return isInstance; +} + +export function ResourceOwnersResponseFromJSON(json: any): ResourceOwnersResponse { + return ResourceOwnersResponseFromJSONTyped(json, false); +} + +export function ResourceOwnersResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersResponse { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'owners': ResourceOwnersCollectionFromJSON(json['owners']), + }; +} + +export function ResourceOwnersResponseToJSON(value?: ResourceOwnersResponse | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'owners': ResourceOwnersCollectionToJSON(value.owners), + }; +} + diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersResponseAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersResponseAllOf.ts new file mode 100644 index 000000000..ddbc2ec47 --- /dev/null +++ b/sdk/typescript/lib/generated/models/ResourceOwnersResponseAllOf.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ResourceOwnersCollection } from './ResourceOwnersCollection'; +import { + ResourceOwnersCollectionFromJSON, + ResourceOwnersCollectionFromJSONTyped, + ResourceOwnersCollectionToJSON, +} from './ResourceOwnersCollection'; + +/** + * + * @export + * @interface ResourceOwnersResponseAllOf + */ +export interface ResourceOwnersResponseAllOf { + /** + * + * @type {ResourceOwnersCollection} + * @memberof ResourceOwnersResponseAllOf + */ + owners: ResourceOwnersCollection; +} + +/** + * Check if a given object implements the ResourceOwnersResponseAllOf interface. + */ +export function instanceOfResourceOwnersResponseAllOf(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "owners" in value; + + return isInstance; +} + +export function ResourceOwnersResponseAllOfFromJSON(json: any): ResourceOwnersResponseAllOf { + return ResourceOwnersResponseAllOfFromJSONTyped(json, false); +} + +export function ResourceOwnersResponseAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersResponseAllOf { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'owners': ResourceOwnersCollectionFromJSON(json['owners']), + }; +} + +export function ResourceOwnersResponseAllOfToJSON(value?: ResourceOwnersResponseAllOf | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'owners': ResourceOwnersCollectionToJSON(value.owners), + }; +} + diff --git a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestHexKeyItem.ts b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestHexKeyItem.ts new file mode 100644 index 000000000..387c724fe --- /dev/null +++ b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestHexKeyItem.ts @@ -0,0 +1,66 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +/** + * + * @export + * @interface StateKeyValueStoreDataRequestHexKeyItem + */ +export interface StateKeyValueStoreDataRequestHexKeyItem { + /** + * Hex-encoded binary blob. + * @type {string} + * @memberof StateKeyValueStoreDataRequestHexKeyItem + */ + key_hex: string; +} + +/** + * Check if a given object implements the StateKeyValueStoreDataRequestHexKeyItem interface. + */ +export function instanceOfStateKeyValueStoreDataRequestHexKeyItem(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "key_hex" in value; + + return isInstance; +} + +export function StateKeyValueStoreDataRequestHexKeyItemFromJSON(json: any): StateKeyValueStoreDataRequestHexKeyItem { + return StateKeyValueStoreDataRequestHexKeyItemFromJSONTyped(json, false); +} + +export function StateKeyValueStoreDataRequestHexKeyItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): StateKeyValueStoreDataRequestHexKeyItem { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'key_hex': json['key_hex'], + }; +} + +export function StateKeyValueStoreDataRequestHexKeyItemToJSON(value?: StateKeyValueStoreDataRequestHexKeyItem | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'key_hex': value.key_hex, + }; +} + diff --git a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestJsonKeyItem.ts b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestJsonKeyItem.ts new file mode 100644 index 000000000..29fc2681c --- /dev/null +++ b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestJsonKeyItem.ts @@ -0,0 +1,73 @@ +/* tslint:disable */ +/* eslint-disable */ +/** + * 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.7.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { exists, mapValues } from '../runtime'; +import type { ProgrammaticScryptoSborValue } from './ProgrammaticScryptoSborValue'; +import { + ProgrammaticScryptoSborValueFromJSON, + ProgrammaticScryptoSborValueFromJSONTyped, + ProgrammaticScryptoSborValueToJSON, +} from './ProgrammaticScryptoSborValue'; + +/** + * + * @export + * @interface StateKeyValueStoreDataRequestJsonKeyItem + */ +export interface StateKeyValueStoreDataRequestJsonKeyItem { + /** + * + * @type {ProgrammaticScryptoSborValue} + * @memberof StateKeyValueStoreDataRequestJsonKeyItem + */ + key_json: ProgrammaticScryptoSborValue; +} + +/** + * Check if a given object implements the StateKeyValueStoreDataRequestJsonKeyItem interface. + */ +export function instanceOfStateKeyValueStoreDataRequestJsonKeyItem(value: object): boolean { + let isInstance = true; + isInstance = isInstance && "key_json" in value; + + return isInstance; +} + +export function StateKeyValueStoreDataRequestJsonKeyItemFromJSON(json: any): StateKeyValueStoreDataRequestJsonKeyItem { + return StateKeyValueStoreDataRequestJsonKeyItemFromJSONTyped(json, false); +} + +export function StateKeyValueStoreDataRequestJsonKeyItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): StateKeyValueStoreDataRequestJsonKeyItem { + if ((json === undefined) || (json === null)) { + return json; + } + return { + + 'key_json': ProgrammaticScryptoSborValueFromJSON(json['key_json']), + }; +} + +export function StateKeyValueStoreDataRequestJsonKeyItemToJSON(value?: StateKeyValueStoreDataRequestJsonKeyItem | null): any { + if (value === undefined) { + return undefined; + } + if (value === null) { + return null; + } + return { + + 'key_json': ProgrammaticScryptoSborValueToJSON(value.key_json), + }; +} + diff --git a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestKeyItem.ts b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestKeyItem.ts index 637cc7aaf..821e125dd 100644 --- a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestKeyItem.ts +++ b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestKeyItem.ts @@ -12,42 +12,27 @@ * Do not edit the class manually. */ -import { exists, mapValues } from '../runtime'; -import type { ProgrammaticScryptoSborValue } from './ProgrammaticScryptoSborValue'; import { - ProgrammaticScryptoSborValueFromJSON, - ProgrammaticScryptoSborValueFromJSONTyped, - ProgrammaticScryptoSborValueToJSON, -} from './ProgrammaticScryptoSborValue'; + StateKeyValueStoreDataRequestHexKeyItem, + instanceOfStateKeyValueStoreDataRequestHexKeyItem, + StateKeyValueStoreDataRequestHexKeyItemFromJSON, + StateKeyValueStoreDataRequestHexKeyItemFromJSONTyped, + StateKeyValueStoreDataRequestHexKeyItemToJSON, +} from './StateKeyValueStoreDataRequestHexKeyItem'; +import { + StateKeyValueStoreDataRequestJsonKeyItem, + instanceOfStateKeyValueStoreDataRequestJsonKeyItem, + StateKeyValueStoreDataRequestJsonKeyItemFromJSON, + StateKeyValueStoreDataRequestJsonKeyItemFromJSONTyped, + StateKeyValueStoreDataRequestJsonKeyItemToJSON, +} from './StateKeyValueStoreDataRequestJsonKeyItem'; /** + * @type StateKeyValueStoreDataRequestKeyItem * * @export - * @interface StateKeyValueStoreDataRequestKeyItem - */ -export interface StateKeyValueStoreDataRequestKeyItem { - /** - * Hex-encoded binary blob. - * @type {string} - * @memberof StateKeyValueStoreDataRequestKeyItem - */ - key_hex?: string; - /** - * - * @type {ProgrammaticScryptoSborValue} - * @memberof StateKeyValueStoreDataRequestKeyItem - */ - key_json?: ProgrammaticScryptoSborValue; -} - -/** - * Check if a given object implements the StateKeyValueStoreDataRequestKeyItem interface. */ -export function instanceOfStateKeyValueStoreDataRequestKeyItem(value: object): boolean { - let isInstance = true; - - return isInstance; -} +export type StateKeyValueStoreDataRequestKeyItem = StateKeyValueStoreDataRequestHexKeyItem | StateKeyValueStoreDataRequestJsonKeyItem; export function StateKeyValueStoreDataRequestKeyItemFromJSON(json: any): StateKeyValueStoreDataRequestKeyItem { return StateKeyValueStoreDataRequestKeyItemFromJSONTyped(json, false); @@ -57,11 +42,7 @@ export function StateKeyValueStoreDataRequestKeyItemFromJSONTyped(json: any, ign if ((json === undefined) || (json === null)) { return json; } - return { - - 'key_hex': !exists(json, 'key_hex') ? undefined : json['key_hex'], - 'key_json': !exists(json, 'key_json') ? undefined : ProgrammaticScryptoSborValueFromJSON(json['key_json']), - }; + return { ...StateKeyValueStoreDataRequestHexKeyItemFromJSONTyped(json, true), ...StateKeyValueStoreDataRequestJsonKeyItemFromJSONTyped(json, true) }; } export function StateKeyValueStoreDataRequestKeyItemToJSON(value?: StateKeyValueStoreDataRequestKeyItem | null): any { @@ -71,10 +52,14 @@ export function StateKeyValueStoreDataRequestKeyItemToJSON(value?: StateKeyValue if (value === null) { return null; } - return { - - 'key_hex': value.key_hex, - 'key_json': ProgrammaticScryptoSborValueToJSON(value.key_json), - }; + + if (instanceOfStateKeyValueStoreDataRequestHexKeyItem(value)) { + return StateKeyValueStoreDataRequestHexKeyItemToJSON(value as StateKeyValueStoreDataRequestHexKeyItem); + } + if (instanceOfStateKeyValueStoreDataRequestJsonKeyItem(value)) { + return StateKeyValueStoreDataRequestJsonKeyItemToJSON(value as StateKeyValueStoreDataRequestJsonKeyItem); + } + + return {}; } diff --git a/sdk/typescript/lib/generated/models/index.ts b/sdk/typescript/lib/generated/models/index.ts index 210e8c37a..8f7988831 100644 --- a/sdk/typescript/lib/generated/models/index.ts +++ b/sdk/typescript/lib/generated/models/index.ts @@ -249,6 +249,19 @@ export * from './PublicKeyHashEddsaEd25519AllOf'; export * from './PublicKeyHashType'; export * from './PublicKeyType'; export * from './ResourceAggregationLevel'; +export * from './ResourceOwnersCollection'; +export * from './ResourceOwnersCollectionAllOf'; +export * from './ResourceOwnersCollectionFungibleResourceItem'; +export * from './ResourceOwnersCollectionFungibleResourceItemAllOf'; +export * from './ResourceOwnersCollectionItem'; +export * from './ResourceOwnersCollectionItemBase'; +export * from './ResourceOwnersCollectionNonFungibleResourceItem'; +export * from './ResourceOwnersCollectionNonFungibleResourceItemAllOf'; +export * from './ResourceOwnersRequest'; +export * from './ResourceOwnersRequestAllOf'; +export * from './ResourceOwnersResourceType'; +export * from './ResourceOwnersResponse'; +export * from './ResourceOwnersResponseAllOf'; export * from './ResultSetCursorMixin'; export * from './RoleAssignmentResolution'; export * from './RoleKey'; @@ -314,6 +327,8 @@ export * from './StateEntitySchemaPageRequest'; export * from './StateEntitySchemaPageResponse'; export * from './StateKeyValueStoreDataRequest'; export * from './StateKeyValueStoreDataRequestAllOf'; +export * from './StateKeyValueStoreDataRequestHexKeyItem'; +export * from './StateKeyValueStoreDataRequestJsonKeyItem'; export * from './StateKeyValueStoreDataRequestKeyItem'; export * from './StateKeyValueStoreDataResponse'; export * from './StateKeyValueStoreDataResponseAllOf'; From ca7903486d198571ab006fabcd2845ea0e534237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Fri, 19 Jul 2024 15:08:28 +0200 Subject: [PATCH 03/18] resource owners feature. --- CHANGELOG.md | 4 +- .../Controllers/ExtensionsController.cs | 82 +++ .../Controllers/StatisticsController.cs | 26 +- .../Handlers/DefaultExtensionsHandler.cs | 94 ++++ .../Handlers/DefaultKeyValueStoreHandler.cs | 8 +- .../Handlers/IExtensionsHandler.cs | 73 +++ .../ServiceCollectionExtensions.cs | 1 + .../Services/IExtensionsQuerier.cs | 82 +++ .../Validators/ResourceOwnersValidator.cs | 84 +++ ...eyValueStoreDataRequestKeyItemValidator.cs | 24 +- .../gateway-api-schema.yaml | 36 +- .../generated/Api/ExtensionsApi.cs | 478 ++++++++++++++++++ .../generated/Api/StatisticsApi.cs | 161 ------ .../Model/ResourceOwnersCollection.cs | 2 +- .../Model/ResourceOwnersCollectionAllOf.cs | 2 +- ...rceOwnersCollectionFungibleResourceItem.cs | 2 +- .../Model/ResourceOwnersCollectionItem.cs | 2 +- ...OwnersCollectionNonFungibleResourceItem.cs | 2 +- ...sCollectionNonFungibleResourceItemAllOf.cs | 2 +- .../generated/Model/ResourceOwnersRequest.cs | 2 +- .../Model/ResourceOwnersRequestAllOf.cs | 2 +- .../Model/ResourceOwnersResourceType.cs | 2 +- .../generated/Model/ResourceOwnersResponse.cs | 2 +- .../Model/ResourceOwnersResponseAllOf.cs | 2 +- ...StateKeyValueStoreDataRequestHexKeyItem.cs | 194 +++++++ ...tateKeyValueStoreDataRequestJsonKeyItem.cs | 193 +++++++ .../StateKeyValueStoreDataRequestKeyItem.cs | 226 +++++++-- .../CommonDbContext.cs | 30 ++ .../GatewayApiBuilderExtensions.cs | 1 + .../PostgresLedgerExtenderService.cs | 36 ++ .../LedgerExtension/ReadHelper.cs | 3 +- .../ResourceOwnersProcessor.cs | 462 ++++++++--------- .../LedgerExtension/SequencesHolder.cs | 2 + .../LedgerExtension/WriteHelper.cs | 65 ++- .../20240812074026_InitialCreate.Designer.cs | 69 +++ .../20240812074026_InitialCreate.cs | 38 ++ .../MigrationsDbContextModelSnapshot.cs | 68 ++- .../Models/ResourceOwners.cs | 88 +++- .../Services/ExtensionsQuerier.cs | 185 +++++++ 39 files changed, 2336 insertions(+), 499 deletions(-) create mode 100644 apps/GatewayApi/Controllers/ExtensionsController.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceOwnersValidator.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestHexKeyItem.cs create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestJsonKeyItem.cs create mode 100644 src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index f855f81c1..0bf80a0c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,15 +21,17 @@ Release built: _not released yet_ - Added support for the Native Resource Details in the `/state/entity/details` endpoint, returned when the `native_resource_details` opt-in is enabled. - Brand-new `native_resource_details` property on the `details` property. - Includes **unit** redemption value for the Validator LSU token and the unit tokens of various Pools. +- Added new endpoint `/extensions/resource-owners/page` which returns information about all owners of the queried resource. ### Database changes - Replaced relationship-related columns (`*_entity_id`) in the `entities` table with more generic collection implementation using `correlated_entity_*` columns. - Replaced per-epoch validator emissions (`validator_emission_statistics` table) with their cumulative statistics (`validator_cumulative_emission_history` table). - Added `non_fungible_data_mutable_fields` to `entities` table. Which contains list of all mutable non fungible data fields for non fungible resource entities. - New `ledger_transaction_markers` type with the `event_global_emitter` discriminator. It represents the global emitter for each event. -- Added new `unverified_standard_metadata_*` tables. They hold **some** of the metadata entries using db-friendly (normalized) model. See https://docs.radixdlt.com/docs/metadata-standards +- Added new `unverified_standard_metadata_*` tables. They hold **some** of the metadata entries using db-friendly (normalized) model. See https://docs.radixdlt.com/docs/metadata-standards - Extended list of supported entity correlations in the `entities` table. - Renamed values of the `entity_relationship` enum type. +- Added new `resource_owners` table. It keeps information about all owners of each fungible and non fungible resource. ## 1.6.3 Release built: 06.08.2024 diff --git a/apps/GatewayApi/Controllers/ExtensionsController.cs b/apps/GatewayApi/Controllers/ExtensionsController.cs new file mode 100644 index 000000000..ef9723e30 --- /dev/null +++ b/apps/GatewayApi/Controllers/ExtensionsController.cs @@ -0,0 +1,82 @@ +/* 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 Microsoft.AspNetCore.Mvc; +using RadixDlt.NetworkGateway.GatewayApi.Handlers; +using System.Threading; +using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; + +namespace GatewayApi.Controllers; + +[ApiController] +[Route("extensions")] +public class ExtensionsController(IExtensionsHandler extensionsHandler) : ControllerBase +{ + [HttpPost("resource-owners/page")] + public async Task ResourceOwnersPage(GatewayModel.ResourceOwnersRequest request, CancellationToken token) + { + return await extensionsHandler.ResourceOwners(request, token); + } +} diff --git a/apps/GatewayApi/Controllers/StatisticsController.cs b/apps/GatewayApi/Controllers/StatisticsController.cs index 564d4f5f3..8dc5f8bee 100644 --- a/apps/GatewayApi/Controllers/StatisticsController.cs +++ b/apps/GatewayApi/Controllers/StatisticsController.cs @@ -64,7 +64,6 @@ using Microsoft.AspNetCore.Mvc; using RadixDlt.NetworkGateway.GatewayApi.Handlers; -using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; @@ -73,32 +72,11 @@ namespace GatewayApi.Controllers; [ApiController] [Route("statistics")] -public class StatisticsController : ControllerBase +public class StatisticsController(IValidatorHandler validatorHandler) : ControllerBase { - private readonly IValidatorHandler _validatorHandler; - - public StatisticsController(IValidatorHandler validatorHandler) - { - _validatorHandler = validatorHandler; - } - [HttpPost("validators/uptime")] public async Task ValidatorsUptime(GatewayModel.ValidatorsUptimeRequest request, CancellationToken token) { - return await _validatorHandler.Uptime(request, token); - } - - [HttpPost("page/resource-owners")] - public async Task ResourceOwnersPage(GatewayModel.ResourceOwnersRequest request, CancellationToken token) - { - await Task.Yield(); - return new GatewayModel.ResourceOwnersResponse( - new GatewayModel.ResourceOwnersCollection( - 200, - null, - new List - { - new GatewayModel.ResourceOwnersCollectionFungibleResourceItem("100", GatewayModel.ResourceOwnersResourceType.FungibleResource, "lol-address"), - })); + return await validatorHandler.Uptime(request, token); } } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs new file mode 100644 index 000000000..82e923c04 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs @@ -0,0 +1,94 @@ +/* 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 Microsoft.Extensions.Options; +using RadixDlt.NetworkGateway.Abstractions; +using RadixDlt.NetworkGateway.GatewayApi.Configuration; +using RadixDlt.NetworkGateway.GatewayApi.Services; +using System.Threading; +using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; + +namespace RadixDlt.NetworkGateway.GatewayApi.Handlers; + +internal class DefaultExtensionsHandler : IExtensionsHandler +{ + private readonly IExtensionsQuerier _extensionsQuerier; + private readonly IOptionsSnapshot _endpointConfiguration; + + public DefaultExtensionsHandler(IExtensionsQuerier extensionsQuerier, IOptionsSnapshot endpointConfiguration) + { + _extensionsQuerier = extensionsQuerier; + _endpointConfiguration = endpointConfiguration; + } + + public async Task ResourceOwners(GatewayModel.ResourceOwnersRequest request, CancellationToken token) + { + return await _extensionsQuerier.ResourceOwners( + (EntityAddress)request.ResourceAddress, + GatewayModel.OffsetCursor.FromCursorString(request.Cursor)?.Offset ?? 0, + _endpointConfiguration.Value.ResolvePageSize(request.LimitPerPage), + token); + } +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultKeyValueStoreHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultKeyValueStoreHandler.cs index ac699a1ed..785d75430 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultKeyValueStoreHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultKeyValueStoreHandler.cs @@ -123,15 +123,15 @@ private IEnumerable ExtractKeys(List ResourceOwners(GatewayApiSdk.Model.ResourceOwnersRequest request, CancellationToken token); +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/ServiceCollectionExtensions.cs b/src/RadixDlt.NetworkGateway.GatewayApi/ServiceCollectionExtensions.cs index 9f21c6036..2848edc54 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/ServiceCollectionExtensions.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/ServiceCollectionExtensions.cs @@ -148,6 +148,7 @@ private static void AddNodeScopedServices(IServiceCollection services) private static void AddRequestServices(IServiceCollection services) { services.TryAddScoped(); + services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs new file mode 100644 index 000000000..90f2039e9 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs @@ -0,0 +1,82 @@ +/* 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. +// + +using RadixDlt.NetworkGateway.Abstractions; +using System.Threading; +using System.Threading.Tasks; + +namespace RadixDlt.NetworkGateway.GatewayApi.Services; + +public interface IExtensionsQuerier +{ + Task ResourceOwners( + EntityAddress resourceAddress, + int offset, + int limit, + CancellationToken token = default); +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceOwnersValidator.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceOwnersValidator.cs new file mode 100644 index 000000000..3efca3eb8 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceOwnersValidator.cs @@ -0,0 +1,84 @@ +/* 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 FluentValidation; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; + +namespace RadixDlt.NetworkGateway.GatewayApi.Validators; + +internal class ResourceOwnersRequestValidator : AbstractValidator +{ + public ResourceOwnersRequestValidator(RadixAddressValidator radixAddressValidator) + { + RuleFor(x => x.ResourceAddress) + .NotNull() + .SetValidator(radixAddressValidator); + + RuleFor(x => x.Cursor) + .Base64(); + + RuleFor(x => x.LimitPerPage) + .GreaterThan(0); + } +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateKeyValueStoreDataRequestKeyItemValidator.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateKeyValueStoreDataRequestKeyItemValidator.cs index 18fb4b2cd..5b68d1c49 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateKeyValueStoreDataRequestKeyItemValidator.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/StateKeyValueStoreDataRequestKeyItemValidator.cs @@ -71,10 +71,26 @@ internal class StateKeyValueStoreDataRequestKeyItemValidator : AbstractValidator { public StateKeyValueStoreDataRequestKeyItemValidator() { - RuleFor(x => x.KeyHex) - .Hex(); + RuleFor(x => x.ActualInstance).SetInheritanceValidator(x => + { + x.Add(new StateKeyValueStoreDataRequestJsonKeyItemValidator()); + x.Add(new StateKeyValueStoreDataRequestHexKeyItemValidator()); + }); + } +} - RuleFor(x => x) - .Must(x => x.KeyHex != null || x.KeyJson != null).WithMessage("Either key_hex or key_json must be not empty."); +internal class StateKeyValueStoreDataRequestJsonKeyItemValidator : AbstractValidator +{ + public StateKeyValueStoreDataRequestJsonKeyItemValidator() + { + RuleFor(x => x.KeyJson).NotEmpty(); + } +} + +internal class StateKeyValueStoreDataRequestHexKeyItemValidator : AbstractValidator +{ + public StateKeyValueStoreDataRequestHexKeyItemValidator() + { + RuleFor(x => x.KeyHex).NotEmpty().Hex(); } } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index 803d0c7f9..726f700b5 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -59,6 +59,7 @@ x-tagGroups: - Stream - State - Statistics + - Extensions tags: - name: SubAPIs x-displayName: Sub-APIs @@ -70,6 +71,7 @@ tags: - **Stream** (`/transaction/*`) - For reading committed transactions. - **State** (`/state/*`) - For reading the current or past ledger state of the network. - **Statistics** (`/statistics/*`) - For calculating particular statistics against the current or past ledger state of the network. + - **Extensions** (`/Extensions/*`) - For additional endpoints that do not fit into other categories. They do not support historical browsing. - name: Concepts x-displayName: Concepts x-traitTag: true # Don't display endpoints under this tag @@ -1195,6 +1197,9 @@ tags: - name: Statistics x-displayName: Statistics Endpoints description: Calculate particular statistics based on current or historic ledger state. + - name: Extensions + x-displayName: Extensions Endpoints + description: Additional endpoints that do not fit into other categories. paths: "/status/gateway-status": @@ -1900,14 +1905,14 @@ paths: "4XX": $ref: "#/components/responses/ErrorResponse" - /statistics/page/resource-owners/: + /extensions/resource-owners/page: post: operationId: ResourceOwnersPage summary: Get Resource Owners Page description: | Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. tags: - - Statistics + - Extensions requestBody: required: true content: @@ -1916,7 +1921,7 @@ paths: $ref: "#/components/schemas/ResourceOwnersRequest" responses: "200": - description: Validators Uptime + description: Resource owners content: application/json: schema: @@ -3150,7 +3155,7 @@ components: items: type: array items: - $ref: "#/components/schemas/ResourceOwnersCollectionItem" + $ref: "#/components/schemas/ResourceOwnersCollectionItem" ResourceOwnersResourceType: type: string @@ -3611,7 +3616,7 @@ components: $ref: "#/components/schemas/TransactionAccountDepositPreValidationAuthorizedDepositorBadge" example: account_address: "" - resource_addresses: [""] + resource_addresses: [ "" ] AccountDepositPreValidationResponse: allOf: @@ -4840,11 +4845,18 @@ components: StateKeyValueStoreDataRequestKeyItem: description: Provide either `key_hex` or `key_json`. If both are provided, `key_hex` is used and `key_json` is ignored. type: object + required: + - key_json properties: - key_hex: - $ref: "#/components/schemas/HexString" key_json: $ref: "#/components/schemas/ProgrammaticScryptoSborValue" + StateKeyValueStoreDataRequestHexKeyItem: + type: object + required: + - key_hex + properties: + key_hex: + $ref: "#/components/schemas/HexString" StateKeyValueStoreDataResponse: allOf: - $ref: "#/components/schemas/LedgerStateMixin" @@ -4978,11 +4990,11 @@ components: ResourceOwnersRequest: allOf: - - $ref: "#/components/schemas/CursorLimitMixin" - - type: object - properties: - resource_address: - $ref: "#/components/schemas/Address" + - $ref: "#/components/schemas/CursorLimitMixin" + - type: object + properties: + resource_address: + $ref: "#/components/schemas/Address" ResourceOwnersResponse: allOf: diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs new file mode 100644 index 000000000..8a8b2b5af --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs @@ -0,0 +1,478 @@ +/* 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.7.0 + * Generated by: https://github.com/openapitools/openapi-generator.git + */ + + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Net.Mime; +using RadixDlt.NetworkGateway.GatewayApiSdk.Client; +using RadixDlt.NetworkGateway.GatewayApiSdk.Model; + +namespace RadixDlt.NetworkGateway.GatewayApiSdk.Api +{ + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IExtensionsApiSync : IApiAccessor + { + #region Synchronous Operations + /// + /// Get Resource Owners Page + /// + /// + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// ResourceOwnersResponse + ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceOwnersRequest); + + /// + /// Get Resource Owners Page + /// + /// + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// ApiResponse of ResourceOwnersResponse + ApiResponse ResourceOwnersPageWithHttpInfo(ResourceOwnersRequest resourceOwnersRequest); + #endregion Synchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IExtensionsApiAsync : IApiAccessor + { + #region Asynchronous Operations + /// + /// Get Resource Owners Page + /// + /// + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ResourceOwnersResponse + System.Threading.Tasks.Task ResourceOwnersPageAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + + /// + /// Get Resource Owners Page + /// + /// + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ResourceOwnersResponse) + System.Threading.Tasks.Task> ResourceOwnersPageWithHttpInfoAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + #endregion Asynchronous Operations + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public interface IExtensionsApi : IExtensionsApiSync, IExtensionsApiAsync + { + + } + + /// + /// Represents a collection of functions to interact with the API endpoints + /// + public partial class ExtensionsApi : IDisposable, IExtensionsApi + { + private RadixDlt.NetworkGateway.GatewayApiSdk.Client.ExceptionFactory _exceptionFactory = (name, response) => null; + + /// + /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an instance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHandler. + /// + /// + public ExtensionsApi() : this((string)null) + { + } + + /// + /// Initializes a new instance of the class. + /// **IMPORTANT** This will also create an instance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHandler. + /// + /// The target service's base path in URL format. + /// + /// + public ExtensionsApi(string basePath) + { + this.Configuration = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.MergeConfigurations( + RadixDlt.NetworkGateway.GatewayApiSdk.Client.GlobalConfiguration.Instance, + new RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// **IMPORTANT** This will also create an instance of HttpClient, which is less than ideal. + /// It's better to reuse the HttpClient and HttpClientHandler. + /// + /// An instance of Configuration. + /// + /// + public ExtensionsApi(RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration configuration) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + + this.Configuration = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.MergeConfigurations( + RadixDlt.NetworkGateway.GatewayApiSdk.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiClient(this.Configuration.BasePath); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ExtensionsApi(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ExtensionsApi(HttpClient client, string basePath, HttpClientHandler handler = null) + { + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.MergeConfigurations( + RadixDlt.NetworkGateway.GatewayApiSdk.Client.GlobalConfiguration.Instance, + new RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration { BasePath = basePath } + ); + this.ApiClient = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiClient(client, this.Configuration.BasePath, handler); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + this.ExceptionFactory = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class using Configuration object. + /// + /// An instance of HttpClient. + /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ExtensionsApi(HttpClient client, RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration configuration, HttpClientHandler handler = null) + { + if (configuration == null) throw new ArgumentNullException("configuration"); + if (client == null) throw new ArgumentNullException("client"); + + this.Configuration = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.MergeConfigurations( + RadixDlt.NetworkGateway.GatewayApiSdk.Client.GlobalConfiguration.Instance, + configuration + ); + this.ApiClient = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiClient(client, this.Configuration.BasePath, handler); + this.Client = this.ApiClient; + this.AsynchronousClient = this.ApiClient; + ExceptionFactory = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Initializes a new instance of the class + /// using a Configuration object and client instance. + /// + /// The client interface for synchronous API access. + /// The client interface for asynchronous API access. + /// The configuration object. + /// + public ExtensionsApi(RadixDlt.NetworkGateway.GatewayApiSdk.Client.ISynchronousClient client, RadixDlt.NetworkGateway.GatewayApiSdk.Client.IAsynchronousClient asyncClient, RadixDlt.NetworkGateway.GatewayApiSdk.Client.IReadableConfiguration configuration) + { + if (client == null) throw new ArgumentNullException("client"); + if (asyncClient == null) throw new ArgumentNullException("asyncClient"); + if (configuration == null) throw new ArgumentNullException("configuration"); + + this.Client = client; + this.AsynchronousClient = asyncClient; + this.Configuration = configuration; + this.ExceptionFactory = RadixDlt.NetworkGateway.GatewayApiSdk.Client.Configuration.DefaultExceptionFactory; + } + + /// + /// Disposes resources if they were created by us + /// + public void Dispose() + { + this.ApiClient?.Dispose(); + } + + /// + /// Holds the ApiClient if created + /// + public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiClient ApiClient { get; set; } = null; + + /// + /// The client for accessing this underlying API asynchronously. + /// + public RadixDlt.NetworkGateway.GatewayApiSdk.Client.IAsynchronousClient AsynchronousClient { get; set; } + + /// + /// The client for accessing this underlying API synchronously. + /// + public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ISynchronousClient Client { get; set; } + + /// + /// Gets the base path of the API client. + /// + /// The base path + public string GetBasePath() + { + return this.Configuration.BasePath; + } + + /// + /// Gets or sets the configuration object + /// + /// An instance of the Configuration + public RadixDlt.NetworkGateway.GatewayApiSdk.Client.IReadableConfiguration Configuration { get; set; } + + /// + /// Provides a factory method hook for the creation of exceptions. + /// + public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ExceptionFactory ExceptionFactory + { + get + { + if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1) + { + throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported."); + } + return _exceptionFactory; + } + set { _exceptionFactory = value; } + } + + /// + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// ResourceOwnersResponse + public ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceOwnersRequest) + { + RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = ResourceOwnersPageWithHttpInfo(resourceOwnersRequest); + return localVarResponse.Data; + } + + /// + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// ApiResponse of ResourceOwnersResponse + public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse ResourceOwnersPageWithHttpInfo(ResourceOwnersRequest resourceOwnersRequest) + { + // verify the required parameter 'resourceOwnersRequest' is set + if (resourceOwnersRequest == null) + throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceOwnersRequest' when calling ExtensionsApi->ResourceOwnersPage"); + + RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions localVarRequestOptions = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/json" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + var localVarContentType = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.Data = resourceOwnersRequest; + + + // make the HTTP request + var localVarResponse = this.Client.Post("/extensions/resource-owners/page", localVarRequestOptions, this.Configuration); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("ResourceOwnersPage", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + /// + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ResourceOwnersResponse + public async System.Threading.Tasks.Task ResourceOwnersPageAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = await ResourceOwnersPageWithHttpInfoAsync(resourceOwnersRequest, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + + /// + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// + /// Thrown when fails to make API call + /// + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (ResourceOwnersResponse) + public async System.Threading.Tasks.Task> ResourceOwnersPageWithHttpInfoAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + // verify the required parameter 'resourceOwnersRequest' is set + if (resourceOwnersRequest == null) + throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceOwnersRequest' when calling ExtensionsApi->ResourceOwnersPage"); + + + RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions localVarRequestOptions = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions(); + + string[] _contentTypes = new string[] { + "application/json" + }; + + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + + + var localVarContentType = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + + var localVarAccept = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + + localVarRequestOptions.Data = resourceOwnersRequest; + + + // make the HTTP request + + var localVarResponse = await this.AsynchronousClient.PostAsync("/extensions/resource-owners/page", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("ResourceOwnersPage", localVarResponse); + if (_exception != null) throw _exception; + } + + return localVarResponse; + } + + } +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/StatisticsApi.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/StatisticsApi.cs index fa92491da..56b3fec6d 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/StatisticsApi.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/StatisticsApi.cs @@ -92,27 +92,6 @@ public interface IStatisticsApiSync : IApiAccessor { #region Synchronous Operations /// - /// Get Resource Owners Page - /// - /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - /// - /// Thrown when fails to make API call - /// - /// ResourceOwnersResponse - ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceOwnersRequest); - - /// - /// Get Resource Owners Page - /// - /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ResourceOwnersResponse - ApiResponse ResourceOwnersPageWithHttpInfo(ResourceOwnersRequest resourceOwnersRequest); - /// /// Get Validators Uptime /// /// @@ -143,29 +122,6 @@ public interface IStatisticsApiAsync : IApiAccessor { #region Asynchronous Operations /// - /// Get Resource Owners Page - /// - /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ResourceOwnersResponse - System.Threading.Tasks.Task ResourceOwnersPageAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - - /// - /// Get Resource Owners Page - /// - /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ResourceOwnersResponse) - System.Threading.Tasks.Task> ResourceOwnersPageWithHttpInfoAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); - /// /// Get Validators Uptime /// /// @@ -401,123 +357,6 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ExceptionFactory ExceptionFa set { _exceptionFactory = value; } } - /// - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - /// - /// Thrown when fails to make API call - /// - /// ResourceOwnersResponse - public ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceOwnersRequest) - { - RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = ResourceOwnersPageWithHttpInfo(resourceOwnersRequest); - return localVarResponse.Data; - } - - /// - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - /// - /// Thrown when fails to make API call - /// - /// ApiResponse of ResourceOwnersResponse - public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse ResourceOwnersPageWithHttpInfo(ResourceOwnersRequest resourceOwnersRequest) - { - // verify the required parameter 'resourceOwnersRequest' is set - if (resourceOwnersRequest == null) - throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceOwnersRequest' when calling StatisticsApi->ResourceOwnersPage"); - - RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions localVarRequestOptions = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/json" - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/json" - }; - - var localVarContentType = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = resourceOwnersRequest; - - - // make the HTTP request - var localVarResponse = this.Client.Post("/statistics/page/resource-owners/", localVarRequestOptions, this.Configuration); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ResourceOwnersPage", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - - /// - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ResourceOwnersResponse - public async System.Threading.Tasks.Task ResourceOwnersPageAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = await ResourceOwnersPageWithHttpInfoAsync(resourceOwnersRequest, cancellationToken).ConfigureAwait(false); - return localVarResponse.Data; - } - - /// - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - /// - /// Thrown when fails to make API call - /// - /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ResourceOwnersResponse) - public async System.Threading.Tasks.Task> ResourceOwnersPageWithHttpInfoAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) - { - // verify the required parameter 'resourceOwnersRequest' is set - if (resourceOwnersRequest == null) - throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceOwnersRequest' when calling StatisticsApi->ResourceOwnersPage"); - - - RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions localVarRequestOptions = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions(); - - string[] _contentTypes = new string[] { - "application/json" - }; - - // to determine the Accept header - string[] _accepts = new string[] { - "application/json" - }; - - - var localVarContentType = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderContentType(_contentTypes); - if (localVarContentType != null) localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); - - var localVarAccept = RadixDlt.NetworkGateway.GatewayApiSdk.Client.ClientUtils.SelectHeaderAccept(_accepts); - if (localVarAccept != null) localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); - - localVarRequestOptions.Data = resourceOwnersRequest; - - - // make the HTTP request - - var localVarResponse = await this.AsynchronousClient.PostAsync("/statistics/page/resource-owners/", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); - - if (this.ExceptionFactory != null) - { - Exception _exception = this.ExceptionFactory("ResourceOwnersPage", localVarResponse); - if (_exception != null) throw _exception; - } - - return localVarResponse; - } - /// /// Get Validators Uptime Returns validators uptime data for time range limited by `from_state_version` and `at_state_version`. /// diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs index 46ad245e2..0e9b6857b 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs index 962cce159..5dd99b6f8 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs index 3c4fe312f..eca4e61fc 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs index e80c51715..d0e99efb6 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs index 1d6bf272f..085604504 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs index 54c034e42..67bc808f8 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs index 281e9510d..ccaffbb7b 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs index 2d9ca32b5..d97055c21 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs index 5107d2758..7a037d3af 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs index 228bf02d0..aa6cc10d5 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs index 85d523978..7f4d24057 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs @@ -67,7 +67,7 @@ * * 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.6.1 + * The version of the OpenAPI document: v1.7.0 * Generated by: https://github.com/openapitools/openapi-generator.git */ diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestHexKeyItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestHexKeyItem.cs new file mode 100644 index 000000000..dd51a9a85 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestHexKeyItem.cs @@ -0,0 +1,194 @@ +/* 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.7.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 +{ + /// + /// StateKeyValueStoreDataRequestHexKeyItem + /// + [DataContract(Name = "StateKeyValueStoreDataRequestHexKeyItem")] + public partial class StateKeyValueStoreDataRequestHexKeyItem : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected StateKeyValueStoreDataRequestHexKeyItem() { } + /// + /// Initializes a new instance of the class. + /// + /// Hex-encoded binary blob. (required). + public StateKeyValueStoreDataRequestHexKeyItem(string keyHex = default(string)) + { + // to ensure "keyHex" is required (not null) + if (keyHex == null) + { + throw new ArgumentNullException("keyHex is a required property for StateKeyValueStoreDataRequestHexKeyItem and cannot be null"); + } + this.KeyHex = keyHex; + } + + /// + /// Hex-encoded binary blob. + /// + /// Hex-encoded binary blob. + [DataMember(Name = "key_hex", IsRequired = true, EmitDefaultValue = true)] + public string KeyHex { 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 StateKeyValueStoreDataRequestHexKeyItem {\n"); + sb.Append(" KeyHex: ").Append(KeyHex).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 StateKeyValueStoreDataRequestHexKeyItem); + } + + /// + /// Returns true if StateKeyValueStoreDataRequestHexKeyItem instances are equal + /// + /// Instance of StateKeyValueStoreDataRequestHexKeyItem to be compared + /// Boolean + public bool Equals(StateKeyValueStoreDataRequestHexKeyItem input) + { + if (input == null) + { + return false; + } + return + ( + this.KeyHex == input.KeyHex || + (this.KeyHex != null && + this.KeyHex.Equals(input.KeyHex)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.KeyHex != null) + { + hashCode = (hashCode * 59) + this.KeyHex.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestJsonKeyItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestJsonKeyItem.cs new file mode 100644 index 000000000..9c69947a1 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestJsonKeyItem.cs @@ -0,0 +1,193 @@ +/* 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.7.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 +{ + /// + /// StateKeyValueStoreDataRequestJsonKeyItem + /// + [DataContract(Name = "StateKeyValueStoreDataRequestJsonKeyItem")] + public partial class StateKeyValueStoreDataRequestJsonKeyItem : IEquatable + { + /// + /// Initializes a new instance of the class. + /// + [JsonConstructorAttribute] + protected StateKeyValueStoreDataRequestJsonKeyItem() { } + /// + /// Initializes a new instance of the class. + /// + /// keyJson (required). + public StateKeyValueStoreDataRequestJsonKeyItem(ProgrammaticScryptoSborValue keyJson = default(ProgrammaticScryptoSborValue)) + { + // to ensure "keyJson" is required (not null) + if (keyJson == null) + { + throw new ArgumentNullException("keyJson is a required property for StateKeyValueStoreDataRequestJsonKeyItem and cannot be null"); + } + this.KeyJson = keyJson; + } + + /// + /// Gets or Sets KeyJson + /// + [DataMember(Name = "key_json", IsRequired = true, EmitDefaultValue = true)] + public ProgrammaticScryptoSborValue KeyJson { 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 StateKeyValueStoreDataRequestJsonKeyItem {\n"); + sb.Append(" KeyJson: ").Append(KeyJson).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 StateKeyValueStoreDataRequestJsonKeyItem); + } + + /// + /// Returns true if StateKeyValueStoreDataRequestJsonKeyItem instances are equal + /// + /// Instance of StateKeyValueStoreDataRequestJsonKeyItem to be compared + /// Boolean + public bool Equals(StateKeyValueStoreDataRequestJsonKeyItem input) + { + if (input == null) + { + return false; + } + return + ( + this.KeyJson == input.KeyJson || + (this.KeyJson != null && + this.KeyJson.Equals(input.KeyJson)) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.KeyJson != null) + { + hashCode = (hashCode * 59) + this.KeyJson.GetHashCode(); + } + return hashCode; + } + } + + } + +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs index ddaef8d13..2c32d28e4 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs @@ -86,38 +86,89 @@ using Newtonsoft.Json.Linq; using FileParameter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.FileParameter; using OpenAPIDateConverter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.OpenAPIDateConverter; +using System.Reflection; namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// /// Provide either `key_hex` or `key_json`. If both are provided, `key_hex` is used and `key_json` is ignored. /// + [JsonConverter(typeof(StateKeyValueStoreDataRequestKeyItemJsonConverter))] [DataContract(Name = "StateKeyValueStoreDataRequestKeyItem")] - public partial class StateKeyValueStoreDataRequestKeyItem : IEquatable + public partial class StateKeyValueStoreDataRequestKeyItem : AbstractOpenAPISchema, IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class + /// with the class /// - /// Hex-encoded binary blob.. - /// keyJson. - public StateKeyValueStoreDataRequestKeyItem(string keyHex = default(string), ProgrammaticScryptoSborValue keyJson = default(ProgrammaticScryptoSborValue)) + /// An instance of StateKeyValueStoreDataRequestJsonKeyItem. + public StateKeyValueStoreDataRequestKeyItem(StateKeyValueStoreDataRequestJsonKeyItem actualInstance) { - this.KeyHex = keyHex; - this.KeyJson = keyJson; + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); } /// - /// Hex-encoded binary blob. + /// Initializes a new instance of the class + /// with the class /// - /// Hex-encoded binary blob. - [DataMember(Name = "key_hex", EmitDefaultValue = true)] - public string KeyHex { get; set; } + /// An instance of StateKeyValueStoreDataRequestHexKeyItem. + public StateKeyValueStoreDataRequestKeyItem(StateKeyValueStoreDataRequestHexKeyItem actualInstance) + { + this.IsNullable = false; + this.SchemaType= "oneOf"; + this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + } + + + private Object _actualInstance; + + /// + /// Gets or Sets ActualInstance + /// + public override Object ActualInstance + { + get + { + return _actualInstance; + } + set + { + if (value.GetType() == typeof(StateKeyValueStoreDataRequestHexKeyItem)) + { + this._actualInstance = value; + } + else if (value.GetType() == typeof(StateKeyValueStoreDataRequestJsonKeyItem)) + { + this._actualInstance = value; + } + else + { + throw new ArgumentException("Invalid instance found. Must be the following types: StateKeyValueStoreDataRequestHexKeyItem, StateKeyValueStoreDataRequestJsonKeyItem"); + } + } + } /// - /// Gets or Sets KeyJson + /// Get the actual instance of `StateKeyValueStoreDataRequestJsonKeyItem`. If the actual instance is not `StateKeyValueStoreDataRequestJsonKeyItem`, + /// the InvalidClassException will be thrown /// - [DataMember(Name = "key_json", EmitDefaultValue = true)] - public ProgrammaticScryptoSborValue KeyJson { get; set; } + /// An instance of StateKeyValueStoreDataRequestJsonKeyItem + public StateKeyValueStoreDataRequestJsonKeyItem GetStateKeyValueStoreDataRequestJsonKeyItem() + { + return (StateKeyValueStoreDataRequestJsonKeyItem)this.ActualInstance; + } + + /// + /// Get the actual instance of `StateKeyValueStoreDataRequestHexKeyItem`. If the actual instance is not `StateKeyValueStoreDataRequestHexKeyItem`, + /// the InvalidClassException will be thrown + /// + /// An instance of StateKeyValueStoreDataRequestHexKeyItem + public StateKeyValueStoreDataRequestHexKeyItem GetStateKeyValueStoreDataRequestHexKeyItem() + { + return (StateKeyValueStoreDataRequestHexKeyItem)this.ActualInstance; + } /// /// Returns the string presentation of the object @@ -125,10 +176,9 @@ public partial class StateKeyValueStoreDataRequestKeyItem : IEquatableString presentation of the object public override string ToString() { - StringBuilder sb = new StringBuilder(); + var sb = new StringBuilder(); sb.Append("class StateKeyValueStoreDataRequestKeyItem {\n"); - sb.Append(" KeyHex: ").Append(KeyHex).Append("\n"); - sb.Append(" KeyJson: ").Append(KeyJson).Append("\n"); + sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -137,9 +187,78 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public virtual string ToJson() + public override string ToJson() { - return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + return JsonConvert.SerializeObject(this.ActualInstance, StateKeyValueStoreDataRequestKeyItem.SerializerSettings); + } + + /// + /// Converts the JSON string into an instance of StateKeyValueStoreDataRequestKeyItem + /// + /// JSON string + /// An instance of StateKeyValueStoreDataRequestKeyItem + public static StateKeyValueStoreDataRequestKeyItem FromJson(string jsonString) + { + StateKeyValueStoreDataRequestKeyItem newStateKeyValueStoreDataRequestKeyItem = null; + + if (string.IsNullOrEmpty(jsonString)) + { + return newStateKeyValueStoreDataRequestKeyItem; + } + int match = 0; + List matchedTypes = new List(); + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(StateKeyValueStoreDataRequestHexKeyItem).GetProperty("AdditionalProperties") == null) + { + newStateKeyValueStoreDataRequestKeyItem = new StateKeyValueStoreDataRequestKeyItem(JsonConvert.DeserializeObject(jsonString, StateKeyValueStoreDataRequestKeyItem.SerializerSettings)); + } + else + { + newStateKeyValueStoreDataRequestKeyItem = new StateKeyValueStoreDataRequestKeyItem(JsonConvert.DeserializeObject(jsonString, StateKeyValueStoreDataRequestKeyItem.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("StateKeyValueStoreDataRequestHexKeyItem"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into StateKeyValueStoreDataRequestHexKeyItem: {1}", jsonString, exception.ToString())); + } + + try + { + // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize + if (typeof(StateKeyValueStoreDataRequestJsonKeyItem).GetProperty("AdditionalProperties") == null) + { + newStateKeyValueStoreDataRequestKeyItem = new StateKeyValueStoreDataRequestKeyItem(JsonConvert.DeserializeObject(jsonString, StateKeyValueStoreDataRequestKeyItem.SerializerSettings)); + } + else + { + newStateKeyValueStoreDataRequestKeyItem = new StateKeyValueStoreDataRequestKeyItem(JsonConvert.DeserializeObject(jsonString, StateKeyValueStoreDataRequestKeyItem.AdditionalPropertiesSerializerSettings)); + } + matchedTypes.Add("StateKeyValueStoreDataRequestJsonKeyItem"); + match++; + } + catch (Exception exception) + { + // deserialization failed, try the next one + System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into StateKeyValueStoreDataRequestJsonKeyItem: {1}", jsonString, exception.ToString())); + } + + if (match == 0) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); + } + else if (match > 1) + { + throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); + } + + // deserialization is considered successful at this point if no exception has been thrown. + return newStateKeyValueStoreDataRequestKeyItem; } /// @@ -160,20 +279,9 @@ public override bool Equals(object input) public bool Equals(StateKeyValueStoreDataRequestKeyItem input) { if (input == null) - { return false; - } - return - ( - this.KeyHex == input.KeyHex || - (this.KeyHex != null && - this.KeyHex.Equals(input.KeyHex)) - ) && - ( - this.KeyJson == input.KeyJson || - (this.KeyJson != null && - this.KeyJson.Equals(input.KeyJson)) - ); + + return this.ActualInstance.Equals(input.ActualInstance); } /// @@ -185,18 +293,56 @@ public override int GetHashCode() unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.KeyHex != null) - { - hashCode = (hashCode * 59) + this.KeyHex.GetHashCode(); - } - if (this.KeyJson != null) - { - hashCode = (hashCode * 59) + this.KeyJson.GetHashCode(); - } + if (this.ActualInstance != null) + hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); return hashCode; } } } + /// + /// Custom JSON converter for StateKeyValueStoreDataRequestKeyItem + /// + public class StateKeyValueStoreDataRequestKeyItemJsonConverter : JsonConverter + { + /// + /// To write the JSON string + /// + /// JSON writer + /// Object to be converted into a JSON string + /// JSON Serializer + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + writer.WriteRawValue((string)(typeof(StateKeyValueStoreDataRequestKeyItem).GetMethod("ToJson").Invoke(value, null))); + } + + /// + /// To convert a JSON string into an object + /// + /// JSON reader + /// Object type + /// Existing value + /// JSON Serializer + /// The object converted from the JSON string + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + if(reader.TokenType != JsonToken.Null) + { + return StateKeyValueStoreDataRequestKeyItem.FromJson(JObject.Load(reader).ToString(Formatting.None)); + } + return null; + } + + /// + /// Check if the object can be converted + /// + /// Object type + /// True if the object can be converted + public override bool CanConvert(Type objectType) + { + return false; + } + } + } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs index 9f497c57c..321cdddaa 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs @@ -174,6 +174,8 @@ internal abstract class CommonDbContext : DbContext public DbSet UnverifiedStandardMetadataEntryHistory => Set(); + public DbSet ResourceOwners => Set(); + public CommonDbContext(DbContextOptions options) : base(options) { @@ -630,5 +632,33 @@ private static void HookupHistory(ModelBuilder modelBuilder) modelBuilder .Entity() .HasIndex(e => new { e.EntityId, e.Discriminator, e.FromStateVersion }); + + // TODO PP: + // best if we could have it in separate schema/dbcontext. + // it doesn't follow historical browse and might be easily split into separate. + // Same applies to pending transactions. + modelBuilder + .Entity() + .HasDiscriminator(DiscriminatorColumnName) + .HasValue(ResourceType.Fungible) + .HasValue(ResourceType.NonFungible); + + // TODO PP: + // do we need all these indexes? + // what order of fields? entityid, resource or reverse? + modelBuilder + .Entity() + .HasIndex(e => new { e.EntityId, e.ResourceEntityId }) + .IsUnique(); + + modelBuilder + .Entity() + .HasIndex(e => new { e.EntityId, e.ResourceEntityId, e.Balance }) + .HasFilter("discriminator = 'fungible'"); + + modelBuilder + .Entity() + .HasIndex(e => new { e.EntityId, e.ResourceEntityId, e.TotalCount }) + .HasFilter("discriminator = 'non_fungible'"); } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/GatewayApiBuilderExtensions.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/GatewayApiBuilderExtensions.cs index dded99605..5e5ba1bfa 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/GatewayApiBuilderExtensions.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/GatewayApiBuilderExtensions.cs @@ -87,6 +87,7 @@ public static GatewayApiBuilder AddPostgresPersistenceCore(this GatewayApiBuilde builder .Services .AddScoped() + .AddScoped() .AddScoped() .AddScoped() .AddScoped() diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index f165b67b4..c168e7e17 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -1438,6 +1438,41 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, } } + var resourceOwnersToAdd = entityResourceAggregatedVaultsHistoryToAdd + .GroupBy( + x => new { x.EntityId, x.ResourceEntityId }, + (key, group) => new + { + key, + newestEntry = group.MaxBy(x => x.FromStateVersion), + } + ) + .Select( + x => + { + ResourceOwners result = x.newestEntry switch + { + EntityFungibleResourceAggregatedVaultsHistory fungible => new FungibleResourceOwners + { + Id = sequences.ResourceOwnersSequence++, + EntityId = fungible.EntityId, + ResourceEntityId = fungible.ResourceEntityId, + Balance = fungible.Balance, + }, + EntityNonFungibleResourceAggregatedVaultsHistory nonFungible => new NonFungibleResourceOwners + { + Id = sequences.ResourceOwnersSequence++, + EntityId = nonFungible.EntityId, + ResourceEntityId = nonFungible.ResourceEntityId, + TotalCount = nonFungible.TotalCount, + }, + _ => throw new ArgumentOutOfRangeException(nameof(x.newestEntry), x.newestEntry, null), + }; + + return result; + }) + .ToList(); + var resourceEntitySupplyHistoryToAdd = resourceSupplyChanges .GroupBy(x => new { x.ResourceEntityId, x.StateVersion }) .Select( @@ -1497,6 +1532,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, rowsInserted += await writeHelper.CopyResourceEntitySupplyHistory(resourceEntitySupplyHistoryToAdd, token); rowsInserted += await writeHelper.CopyNonFungibleDataSchemaHistory(nonFungibleSchemaHistoryToAdd, token); rowsInserted += await writeHelper.CopyKeyValueStoreSchemaHistory(keyValueStoreSchemaHistoryToAdd, token); + rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd, token); rowsInserted += await entityStateProcessor.SaveEntities(); rowsInserted += await entityMetadataProcessor.SaveEntities(); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ReadHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ReadHelper.cs index b9679546b..c5c6370d2 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ReadHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ReadHelper.cs @@ -440,7 +440,8 @@ public async Task LoadSequences(CancellationToken token) nextval('account_authorized_depositor_entry_history_id_seq') AS AccountAuthorizedDepositorEntryHistorySequence, nextval('account_authorized_depositor_aggregate_history_id_seq') AS AccountAuthorizedDepositorAggregateHistorySequence, nextval('unverified_standard_metadata_aggregate_history_id_seq') AS UnverifiedStandardMetadataAggregateHistorySequence, - nextval('unverified_standard_metadata_entry_history_id_seq') AS UnverifiedStandardMetadataEntryHistorySequence + nextval('unverified_standard_metadata_entry_history_id_seq') AS UnverifiedStandardMetadataEntryHistorySequence, + nextval('resource_owners_id_seq') AS ResourceOwnersSequence ", cancellationToken: token); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs index 52c6bc7c1..93cc9a687 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs @@ -1,231 +1,231 @@ -/* 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 NpgsqlTypes; -using RadixDlt.NetworkGateway.Abstractions; -using RadixDlt.NetworkGateway.Abstractions.Extensions; -using RadixDlt.NetworkGateway.PostgresIntegration.Models; -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Threading.Tasks; -using CoreModel = RadixDlt.CoreApiSdk.Model; - -namespace RadixDlt.NetworkGateway.PostgresIntegration.LedgerExtension; - -public record ResourceOwner(EntityAddress OwnerAddress); - -public record FungibleResourceOwner(EntityAddress OwnerAddress, string Amount) : ResourceOwner(OwnerAddress); - -public record NonFungibleResourceOwner(EntityAddress OwnerAddress, long NfidCount) : ResourceOwner(OwnerAddress); - -internal class ResourceOwnersProcessor -{ - private readonly ProcessorContext _context; - private readonly ReferencedEntityDictionary _referencedEntities; - private readonly Dictionary> _resourceOwners; - - private List _toAdd = new(); - - public ResourceOwnersProcessor(ProcessorContext context, ReferencedEntityDictionary referencedEntities) - { - _context = context; - _referencedEntities = referencedEntities; - } - - public void VisitUpsert(CoreModel.IUpsertedSubstate substate, ReferencedEntity referencedEntity, long stateVersion) - { - var substateData = substate.Value.SubstateData; - - if (substateData is CoreModel.GenericScryptoComponentFieldStateSubstate componentState) - { - if (substate.SystemStructure is not CoreModel.ObjectFieldStructure objectFieldStructure) - { - throw new UnreachableException($"Generic Scrypto components are expected to have ObjectFieldStructure. Got: {substate.SystemStructure.GetType()}"); - } - - var schemaDetails = objectFieldStructure.ValueSchema.GetSchemaDetails(); - - _toAdd.Add(new SborStateHistory - { - Id = _context.Sequences.StateHistorySequence++, - FromStateVersion = stateVersion, - EntityId = referencedEntity.DatabaseId, - SborState = componentState.Value.DataStruct.StructData.GetDataBytes(), - SchemaHash = schemaDetails.SchemaHash.ConvertFromHex(), - SborTypeKind = schemaDetails.SborTypeKind.ToModel(), - TypeIndex = schemaDetails.TypeIndex, - SchemaDefiningEntityId = _referencedEntities.Get((EntityAddress)schemaDetails.SchemaDefiningEntityAddress).DatabaseId, - }); - } - - if (substateData is CoreModel.ValidatorFieldStateSubstate validator) - { - _toAdd.Add(new JsonStateHistory - { - Id = _context.Sequences.StateHistorySequence++, - FromStateVersion = stateVersion, - EntityId = referencedEntity.DatabaseId, - JsonState = validator.Value.ToJson(), - }); - } - - if (substateData is CoreModel.AccountFieldStateSubstate accountFieldState) - { - _toAdd.Add(new JsonStateHistory - { - Id = _context.Sequences.StateHistorySequence++, - FromStateVersion = stateVersion, - EntityId = referencedEntity.DatabaseId, - JsonState = accountFieldState.Value.ToJson(), - }); - } - - if (substateData is CoreModel.AccessControllerFieldStateSubstate accessControllerFieldState) - { - _toAdd.Add(new JsonStateHistory - { - Id = _context.Sequences.StateHistorySequence++, - FromStateVersion = stateVersion, - EntityId = referencedEntity.DatabaseId, - JsonState = accessControllerFieldState.Value.ToJson(), - }); - } - - if (substateData is CoreModel.OneResourcePoolFieldStateSubstate oneResourcePoolFieldStateSubstate) - { - _toAdd.Add(new JsonStateHistory - { - Id = _context.Sequences.StateHistorySequence++, - FromStateVersion = stateVersion, - EntityId = referencedEntity.DatabaseId, - JsonState = oneResourcePoolFieldStateSubstate.Value.ToJson(), - }); - } - - if (substateData is CoreModel.TwoResourcePoolFieldStateSubstate twoResourcePoolFieldStateSubstate) - { - _toAdd.Add(new JsonStateHistory - { - Id = _context.Sequences.StateHistorySequence++, - FromStateVersion = stateVersion, - EntityId = referencedEntity.DatabaseId, - JsonState = twoResourcePoolFieldStateSubstate.Value.ToJson(), - }); - } - - if (substateData is CoreModel.MultiResourcePoolFieldStateSubstate multiResourcePoolFieldStateSubstate) - { - _toAdd.Add(new JsonStateHistory - { - Id = _context.Sequences.StateHistorySequence++, - FromStateVersion = stateVersion, - EntityId = referencedEntity.DatabaseId, - JsonState = multiResourcePoolFieldStateSubstate.Value.ToJson(), - }); - } - } - - public async Task SaveEntities() - { - var rowsInserted = 0; - - rowsInserted += await CopyStateHistory(); - - return rowsInserted; - } - - private Task CopyStateHistory() => _context.WriteHelper.Copy( - _toAdd, - "COPY state_history (id, from_state_version, entity_id, discriminator, json_state, sbor_state, type_index, schema_hash, sbor_type_kind, schema_defining_entity_id) FROM STDIN (FORMAT BINARY)", - async (writer, e, token) => - { - await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(e.FromStateVersion, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(_context.WriteHelper.GetDiscriminator(e.GetType()), "state_type", token); - - switch (e) - { - case JsonStateHistory jsonStateHistory: - await writer.WriteAsync(jsonStateHistory.JsonState, NpgsqlDbType.Jsonb, token); - await writer.WriteNullAsync(token); - await writer.WriteNullAsync(token); - await writer.WriteNullAsync(token); - await writer.WriteNullAsync(token); - await writer.WriteNullAsync(token); - break; - case SborStateHistory sborStateHistory: - await writer.WriteNullAsync(token); - await writer.WriteAsync(sborStateHistory.SborState, NpgsqlDbType.Bytea, token); - await writer.WriteAsync(sborStateHistory.TypeIndex, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(sborStateHistory.SchemaHash, NpgsqlDbType.Bytea, token); - await writer.WriteAsync(sborStateHistory.SborTypeKind, "sbor_type_kind", token); - await writer.WriteAsync(sborStateHistory.SchemaDefiningEntityId, NpgsqlDbType.Bigint, token); - break; - default: - throw new ArgumentOutOfRangeException(nameof(e), e, null); - } - }); -} +// /* 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 NpgsqlTypes; +// using RadixDlt.NetworkGateway.Abstractions; +// using RadixDlt.NetworkGateway.Abstractions.Extensions; +// using RadixDlt.NetworkGateway.PostgresIntegration.Models; +// using System; +// using System.Collections.Generic; +// using System.Diagnostics; +// using System.Threading.Tasks; +// using CoreModel = RadixDlt.CoreApiSdk.Model; +// +// namespace RadixDlt.NetworkGateway.PostgresIntegration.LedgerExtension; +// +// public record ResourceOwner(EntityAddress OwnerAddress); +// +// public record FungibleResourceOwner(EntityAddress OwnerAddress, string Amount) : ResourceOwner(OwnerAddress); +// +// public record NonFungibleResourceOwner(EntityAddress OwnerAddress, long NfidCount) : ResourceOwner(OwnerAddress); +// +// internal class ResourceOwnersProcessor +// { +// private readonly ProcessorContext _context; +// private readonly ReferencedEntityDictionary _referencedEntities; +// private readonly Dictionary> _resourceOwners; +// +// private List _toAdd = new(); +// +// public ResourceOwnersProcessor(ProcessorContext context, ReferencedEntityDictionary referencedEntities) +// { +// _context = context; +// _referencedEntities = referencedEntities; +// } +// +// public void VisitUpsert(CoreModel.IUpsertedSubstate substate, ReferencedEntity referencedEntity, long stateVersion) +// { +// var substateData = substate.Value.SubstateData; +// +// if (substateData is CoreModel.GenericScryptoComponentFieldStateSubstate componentState) +// { +// if (substate.SystemStructure is not CoreModel.ObjectFieldStructure objectFieldStructure) +// { +// throw new UnreachableException($"Generic Scrypto components are expected to have ObjectFieldStructure. Got: {substate.SystemStructure.GetType()}"); +// } +// +// var schemaDetails = objectFieldStructure.ValueSchema.GetSchemaDetails(); +// +// _toAdd.Add(new SborStateHistory +// { +// Id = _context.Sequences.StateHistorySequence++, +// FromStateVersion = stateVersion, +// EntityId = referencedEntity.DatabaseId, +// SborState = componentState.Value.DataStruct.StructData.GetDataBytes(), +// SchemaHash = schemaDetails.SchemaHash.ConvertFromHex(), +// SborTypeKind = schemaDetails.SborTypeKind.ToModel(), +// TypeIndex = schemaDetails.TypeIndex, +// SchemaDefiningEntityId = _referencedEntities.Get((EntityAddress)schemaDetails.SchemaDefiningEntityAddress).DatabaseId, +// }); +// } +// +// if (substateData is CoreModel.ValidatorFieldStateSubstate validator) +// { +// _toAdd.Add(new JsonStateHistory +// { +// Id = _context.Sequences.StateHistorySequence++, +// FromStateVersion = stateVersion, +// EntityId = referencedEntity.DatabaseId, +// JsonState = validator.Value.ToJson(), +// }); +// } +// +// if (substateData is CoreModel.AccountFieldStateSubstate accountFieldState) +// { +// _toAdd.Add(new JsonStateHistory +// { +// Id = _context.Sequences.StateHistorySequence++, +// FromStateVersion = stateVersion, +// EntityId = referencedEntity.DatabaseId, +// JsonState = accountFieldState.Value.ToJson(), +// }); +// } +// +// if (substateData is CoreModel.AccessControllerFieldStateSubstate accessControllerFieldState) +// { +// _toAdd.Add(new JsonStateHistory +// { +// Id = _context.Sequences.StateHistorySequence++, +// FromStateVersion = stateVersion, +// EntityId = referencedEntity.DatabaseId, +// JsonState = accessControllerFieldState.Value.ToJson(), +// }); +// } +// +// if (substateData is CoreModel.OneResourcePoolFieldStateSubstate oneResourcePoolFieldStateSubstate) +// { +// _toAdd.Add(new JsonStateHistory +// { +// Id = _context.Sequences.StateHistorySequence++, +// FromStateVersion = stateVersion, +// EntityId = referencedEntity.DatabaseId, +// JsonState = oneResourcePoolFieldStateSubstate.Value.ToJson(), +// }); +// } +// +// if (substateData is CoreModel.TwoResourcePoolFieldStateSubstate twoResourcePoolFieldStateSubstate) +// { +// _toAdd.Add(new JsonStateHistory +// { +// Id = _context.Sequences.StateHistorySequence++, +// FromStateVersion = stateVersion, +// EntityId = referencedEntity.DatabaseId, +// JsonState = twoResourcePoolFieldStateSubstate.Value.ToJson(), +// }); +// } +// +// if (substateData is CoreModel.MultiResourcePoolFieldStateSubstate multiResourcePoolFieldStateSubstate) +// { +// _toAdd.Add(new JsonStateHistory +// { +// Id = _context.Sequences.StateHistorySequence++, +// FromStateVersion = stateVersion, +// EntityId = referencedEntity.DatabaseId, +// JsonState = multiResourcePoolFieldStateSubstate.Value.ToJson(), +// }); +// } +// } +// +// public async Task SaveEntities() +// { +// var rowsInserted = 0; +// +// rowsInserted += await CopyStateHistory(); +// +// return rowsInserted; +// } +// +// private Task CopyStateHistory() => _context.WriteHelper.Copy( +// _toAdd, +// "COPY state_history (id, from_state_version, entity_id, discriminator, json_state, sbor_state, type_index, schema_hash, sbor_type_kind, schema_defining_entity_id) FROM STDIN (FORMAT BINARY)", +// async (writer, e, token) => +// { +// await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); +// await writer.WriteAsync(e.FromStateVersion, NpgsqlDbType.Bigint, token); +// await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); +// await writer.WriteAsync(_context.WriteHelper.GetDiscriminator(e.GetType()), "state_type", token); +// +// switch (e) +// { +// case JsonStateHistory jsonStateHistory: +// await writer.WriteAsync(jsonStateHistory.JsonState, NpgsqlDbType.Jsonb, token); +// await writer.WriteNullAsync(token); +// await writer.WriteNullAsync(token); +// await writer.WriteNullAsync(token); +// await writer.WriteNullAsync(token); +// await writer.WriteNullAsync(token); +// break; +// case SborStateHistory sborStateHistory: +// await writer.WriteNullAsync(token); +// await writer.WriteAsync(sborStateHistory.SborState, NpgsqlDbType.Bytea, token); +// await writer.WriteAsync(sborStateHistory.TypeIndex, NpgsqlDbType.Bigint, token); +// await writer.WriteAsync(sborStateHistory.SchemaHash, NpgsqlDbType.Bytea, token); +// await writer.WriteAsync(sborStateHistory.SborTypeKind, "sbor_type_kind", token); +// await writer.WriteAsync(sborStateHistory.SchemaDefiningEntityId, NpgsqlDbType.Bigint, token); +// break; +// default: +// throw new ArgumentOutOfRangeException(nameof(e), e, null); +// } +// }); +// } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/SequencesHolder.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/SequencesHolder.cs index 57efb925f..4339ba339 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/SequencesHolder.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/SequencesHolder.cs @@ -147,4 +147,6 @@ internal class SequencesHolder public long UnverifiedStandardMetadataAggregateHistorySequence { get; set; } public long UnverifiedStandardMetadataEntryHistorySequence { get; set; } + + public long ResourceOwnersSequence { get; set; } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs index 576d94440..8b0a543eb 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs @@ -735,6 +735,67 @@ await _connection.BeginBinaryImportAsync( return entities.Count; } + public async Task CopyResourceOwners(ICollection entities, CancellationToken token) + { + if (!entities.Any()) + { + return 0; + } + + var sw = Stopwatch.GetTimestamp(); + + await using var createTempTableCommand = _connection.CreateCommand(); + createTempTableCommand.CommandText = @" +CREATE TEMP TABLE tmp_resource_owners +(LIKE resource_owners INCLUDING DEFAULTS) +ON COMMIT DROP"; + + await createTempTableCommand.ExecuteNonQueryAsync(token); + + await using var writer = + await _connection.BeginBinaryImportAsync( + "COPY tmp_resource_owners (id, entity_id, resource_entity_id, discriminator, balance, total_count) FROM STDIN (FORMAT BINARY)", + token); + + foreach (var e in entities) + { + await writer.StartRowAsync(token); + await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.ResourceEntityId, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(GetDiscriminator(e.GetType()), "resource_type", token); + + if (e is FungibleResourceOwners fe) + { + await writer.WriteAsync(fe.Balance.GetSubUnitsSafeForPostgres(), NpgsqlDbType.Numeric, token); + await writer.WriteNullAsync(token); + } + else if (e is NonFungibleResourceOwners nfe) + { + await writer.WriteNullAsync(token); + await writer.WriteAsync(nfe.TotalCount, NpgsqlDbType.Bigint, token); + } + } + + await writer.CompleteAsync(token); + await writer.DisposeAsync(); + + await using var copyFromTempTablecommand = _connection.CreateCommand(); + copyFromTempTablecommand.CommandText = @" +INSERT INTO resource_owners +SELECT * +FROM tmp_resource_owners +ON CONFLICT (entity_id, resource_entity_id) DO UPDATE SET + balance = EXCLUDED.balance, + total_count = EXCLUDED.total_count;"; + + await copyFromTempTablecommand.ExecuteNonQueryAsync(token); + + await _observers.ForEachAsync(x => x.StageCompleted(nameof(CopyResourceOwners), Stopwatch.GetElapsedTime(sw), entities.Count)); + + return entities.Count; + } + public async Task UpdateSequences(SequencesHolder sequences, CancellationToken token) { var sw = Stopwatch.GetTimestamp(); @@ -782,7 +843,8 @@ public async Task UpdateSequences(SequencesHolder sequences, CancellationToken t setval('account_authorized_depositor_entry_history_id_seq', @accountAuthorizedDepositorEntryHistorySequence), setval('account_authorized_depositor_aggregate_history_id_seq', @accountAuthorizedDepositorAggregateHistorySequence), setval('unverified_standard_metadata_aggregate_history_id_seq', @unverifiedStandardMetadataAggregateHistorySequence), - setval('unverified_standard_metadata_entry_history_id_seq', @unverifiedStandardMetadataEntryHistorySequence) + setval('unverified_standard_metadata_entry_history_id_seq', @unverifiedStandardMetadataEntryHistorySequence), + setval('resource_owners_id_seq', @resourceOwnersSequence) ", parameters: new { @@ -827,6 +889,7 @@ public async Task UpdateSequences(SequencesHolder sequences, CancellationToken t accountAuthorizedDepositorAggregateHistorySequence = sequences.AccountAuthorizedDepositorAggregateHistorySequence, unverifiedStandardMetadataAggregateHistorySequence = sequences.UnverifiedStandardMetadataAggregateHistorySequence, unverifiedStandardMetadataEntryHistorySequence = sequences.UnverifiedStandardMetadataEntryHistorySequence, + resourceOwnersSequence = sequences.ResourceOwnersSequence, }, cancellationToken: token); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs index a603b5ceb..eeb44ec25 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs @@ -81,7 +81,11 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations { [DbContext(typeof(MigrationsDbContext))] +<<<<<<<< HEAD:src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs [Migration("20240812074026_InitialCreate")] +======== + [Migration("20240807102112_InitialCreate")] +>>>>>>>> b8f1f86c (resource owners feature.):src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240807102112_InitialCreate.Designer.cs partial class InitialCreate { /// @@ -1557,6 +1561,38 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("resource_entity_supply_history"); }); + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.Property("discriminator") + .HasColumnType("resource_type"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "ResourceEntityId") + .IsUnique(); + + b.ToTable("resource_owners"); + + b.HasDiscriminator("discriminator"); + + b.UseTphMappingStrategy(); + }); + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SchemaEntryAggregateHistory", b => { b.Property("Id") @@ -2613,6 +2649,39 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.Origin); }); + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.FungibleResourceOwners", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners"); + + b.Property("Balance") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("balance"); + + b.HasIndex("EntityId", "ResourceEntityId", "Balance") + .HasFilter("discriminator = 'fungible'"); + + b.ToTable("resource_owners"); + + b.HasDiscriminator().HasValue(ResourceType.Fungible); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleResourceOwners", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners"); + + b.Property("TotalCount") + .HasColumnType("bigint") + .HasColumnName("total_count"); + + b.HasIndex("EntityId", "ResourceEntityId", "TotalCount") + .HasFilter("discriminator = 'non_fungible'"); + + b.ToTable("resource_owners"); + + b.HasDiscriminator().HasValue(ResourceType.NonFungible); + }); + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.JsonStateHistory", b => { b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.StateHistory"); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs index ac1de06ab..cc8fbbe97 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs @@ -754,6 +754,23 @@ protected override void Up(MigrationBuilder migrationBuilder) table.PrimaryKey("PK_resource_entity_supply_history", x => x.id); }); + migrationBuilder.CreateTable( + name: "resource_owners", + columns: table => new + { + id = table.Column(type: "bigint", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + entity_id = table.Column(type: "bigint", nullable: false), + resource_entity_id = table.Column(type: "bigint", nullable: false), + discriminator = table.Column(type: "resource_type", nullable: false), + balance = table.Column(type: "numeric(1000)", precision: 1000, nullable: true), + total_count = table.Column(type: "bigint", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_resource_owners", x => x.id); + }); + migrationBuilder.CreateTable( name: "schema_entry_aggregate_history", columns: table => new @@ -1238,6 +1255,24 @@ protected override void Up(MigrationBuilder migrationBuilder) table: "resource_entity_supply_history", columns: new[] { "resource_entity_id", "from_state_version" }); + migrationBuilder.CreateIndex( + name: "IX_resource_owners_entity_id_resource_entity_id", + table: "resource_owners", + columns: new[] { "entity_id", "resource_entity_id" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_resource_owners_entity_id_resource_entity_id_balance", + table: "resource_owners", + columns: new[] { "entity_id", "resource_entity_id", "balance" }, + filter: "discriminator = 'fungible'"); + + migrationBuilder.CreateIndex( + name: "IX_resource_owners_entity_id_resource_entity_id_total_count", + table: "resource_owners", + columns: new[] { "entity_id", "resource_entity_id", "total_count" }, + filter: "discriminator = 'non_fungible'"); + migrationBuilder.CreateIndex( name: "IX_schema_entry_aggregate_history_entity_id_from_state_version", table: "schema_entry_aggregate_history", @@ -1402,6 +1437,9 @@ protected override void Down(MigrationBuilder migrationBuilder) migrationBuilder.DropTable( name: "resource_entity_supply_history"); + migrationBuilder.DropTable( + name: "resource_owners"); + migrationBuilder.DropTable( name: "schema_entry_aggregate_history"); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs index 7b4fcc113..b7283fc30 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs @@ -68,11 +68,8 @@ using System.Numerics; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using RadixDlt.NetworkGateway.Abstractions.Model; using RadixDlt.NetworkGateway.Abstractions.StandardMetadata; -using RadixDlt.NetworkGateway.PostgresIntegration; using RadixDlt.NetworkGateway.PostgresIntegration.Models; #nullable disable @@ -1554,6 +1551,38 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("resource_entity_supply_history"); }); + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint") + .HasColumnName("id"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("EntityId") + .HasColumnType("bigint") + .HasColumnName("entity_id"); + + b.Property("ResourceEntityId") + .HasColumnType("bigint") + .HasColumnName("resource_entity_id"); + + b.Property("discriminator") + .HasColumnType("resource_type"); + + b.HasKey("Id"); + + b.HasIndex("EntityId", "ResourceEntityId") + .IsUnique(); + + b.ToTable("resource_owners"); + + b.HasDiscriminator("discriminator"); + + b.UseTphMappingStrategy(); + }); + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SchemaEntryAggregateHistory", b => { b.Property("Id") @@ -2610,6 +2639,39 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.Origin); }); + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.FungibleResourceOwners", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners"); + + b.Property("Balance") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("balance"); + + b.HasIndex("EntityId", "ResourceEntityId", "Balance") + .HasFilter("discriminator = 'fungible'"); + + b.ToTable("resource_owners"); + + b.HasDiscriminator().HasValue(ResourceType.Fungible); + }); + + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleResourceOwners", b => + { + b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners"); + + b.Property("TotalCount") + .HasColumnType("bigint") + .HasColumnName("total_count"); + + b.HasIndex("EntityId", "ResourceEntityId", "TotalCount") + .HasFilter("discriminator = 'non_fungible'"); + + b.ToTable("resource_owners"); + + b.HasDiscriminator().HasValue(ResourceType.NonFungible); + }); + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.JsonStateHistory", b => { b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.StateHistory"); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs index 274ba4056..261efb8ef 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs @@ -1,19 +1,95 @@ -using RadixDlt.NetworkGateway.Abstractions; +/* 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.Numerics; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; namespace RadixDlt.NetworkGateway.PostgresIntegration.Models; [Table("resource_owners")] -internal class ResourceOwners +internal abstract class ResourceOwners { [Key] [Column("id")] public long Id { get; set; } - [Column("from_state_version")] - public long FromStateVersion { get; set; } + [Column("entity_id")] + public long EntityId { get; set; } + + [Column("resource_entity_id")] + public long ResourceEntityId { get; set; } +} - [Column("resource_address")] - public EntityAddress ResourceAddress { get; set; } +internal class FungibleResourceOwners : ResourceOwners +{ + [Column("balance")] + public TokenAmount Balance { get; set; } +} + +internal class NonFungibleResourceOwners : ResourceOwners +{ + [Column("total_count")] + public long TotalCount { get; set; } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs new file mode 100644 index 000000000..a52b8c849 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs @@ -0,0 +1,185 @@ +/* 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 Dapper; +using Microsoft.EntityFrameworkCore; +using RadixDlt.NetworkGateway.Abstractions; +using RadixDlt.NetworkGateway.Abstractions.Numerics; +using RadixDlt.NetworkGateway.GatewayApi.Services; +using RadixDlt.NetworkGateway.PostgresIntegration.Models; +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; + +namespace RadixDlt.NetworkGateway.PostgresIntegration.Services; + +internal class ExtensionsQuerier : IExtensionsQuerier +{ + private readonly ReadOnlyDbContext _dbContext; + private readonly IDapperWrapper _dapperWrapper; + + private record FungibleResourceOwnersViewModel(EntityAddress EntityAddress, string Balance); + + private record NonFungibleResourceOwnersViewModel(EntityAddress EntityAddress, long TotalCount); + + public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapper) + { + _dbContext = dbContext; + _dapperWrapper = dapperWrapper; + } + + public async Task ResourceOwners( + EntityAddress resourceAddress, + int offset, + int limit, + CancellationToken token = default) + { + var resourceEntity = await _dbContext + .Entities + .AnnotateMetricName() + .FirstOrDefaultAsync(e => e.Address == resourceAddress, token); + + switch (resourceEntity) + { + case GlobalFungibleResourceEntity: + { + var totalCount = await _dbContext.ResourceOwners.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); + + var cd = new CommandDefinition( + commandText: @" +SELECT + e.address AS EntityAddress, + CAST(ro.balance AS text) AS Balance +FROM resource_owners ro +INNER JOIN entities e +ON ro.entity_id = e.id +WHERE resource_entity_id = @resourceEntityId +ORDER BY ro.balance DESC +LIMIT @limit +OFFSET @offset", + parameters: new + { + resourceEntityId = resourceEntity.Id, + offset = offset, + limit = limit, + }, + cancellationToken: token); + + var fungibleResult = await _dapperWrapper.QueryAsync(_dbContext.Database.GetDbConnection(), cd); + + var casted = fungibleResult + .Select( + x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionFungibleResourceItem( + amount: TokenAmount.FromSubUnitsString(x.Balance).ToString(), + ownerAddress: x.EntityAddress) + ) + .ToList(); + + var nextCursor = CursorGenerator.GenerateOffsetCursor(offset, limit, totalCount); + return new GatewayModel.ResourceOwnersResponse(new GatewayModel.ResourceOwnersCollection(totalCount, nextCursor, casted)); + } + + case GlobalNonFungibleResourceEntity: + { + var totalCount = await _dbContext.ResourceOwners.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); + + var cd = new CommandDefinition( + commandText: @" +SELECT + e.address AS EntityAddress, + ro.total_count as TotalCount +FROM resource_owners ro +INNER JOIN entities e +ON ro.entity_id = e.id +WHERE resource_entity_id = @resourceEntityId +ORDER BY total_count DESC +LIMIT @limit +OFFSET @offset", + parameters: new + { + resourceEntityId = resourceEntity.Id, + offset = offset, + limit = limit, + }, + cancellationToken: token); + + var nonFungibleResult = (await _dapperWrapper.QueryAsync(_dbContext.Database.GetDbConnection(), cd)) + .Select( + x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionNonFungibleResourceItem( + nonFungibleIdsCount: x.TotalCount, + ownerAddress: x.EntityAddress) + ) + .ToList(); + + var nextCursor = CursorGenerator.GenerateOffsetCursor(offset, limit, totalCount); + return new GatewayModel.ResourceOwnersResponse(new GatewayModel.ResourceOwnersCollection(totalCount, nextCursor, nonFungibleResult)); + } + + default: + throw new ArgumentOutOfRangeException(nameof(resourceEntity), resourceEntity, null); + } + } +} From fc77e7708b0ec0bdbd5efadfbce3e99d88531351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Fri, 9 Aug 2024 10:04:31 +0200 Subject: [PATCH 04/18] revert kvstore request change. --- .../Handlers/DefaultKeyValueStoreHandler.cs | 8 +- ...eyValueStoreDataRequestKeyItemValidator.cs | 24 +- .../gateway-api-schema.yaml | 11 +- ...StateKeyValueStoreDataRequestHexKeyItem.cs | 194 --------------- ...tateKeyValueStoreDataRequestJsonKeyItem.cs | 193 --------------- .../StateKeyValueStoreDataRequestKeyItem.cs | 226 ++++-------------- 6 files changed, 50 insertions(+), 606 deletions(-) delete mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestHexKeyItem.cs delete mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestJsonKeyItem.cs diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultKeyValueStoreHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultKeyValueStoreHandler.cs index 785d75430..ac699a1ed 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultKeyValueStoreHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultKeyValueStoreHandler.cs @@ -123,15 +123,15 @@ private IEnumerable ExtractKeys(List x.ActualInstance).SetInheritanceValidator(x => - { - x.Add(new StateKeyValueStoreDataRequestJsonKeyItemValidator()); - x.Add(new StateKeyValueStoreDataRequestHexKeyItemValidator()); - }); - } -} + RuleFor(x => x.KeyHex) + .Hex(); -internal class StateKeyValueStoreDataRequestJsonKeyItemValidator : AbstractValidator -{ - public StateKeyValueStoreDataRequestJsonKeyItemValidator() - { - RuleFor(x => x.KeyJson).NotEmpty(); - } -} - -internal class StateKeyValueStoreDataRequestHexKeyItemValidator : AbstractValidator -{ - public StateKeyValueStoreDataRequestHexKeyItemValidator() - { - RuleFor(x => x.KeyHex).NotEmpty().Hex(); + RuleFor(x => x) + .Must(x => x.KeyHex != null || x.KeyJson != null).WithMessage("Either key_hex or key_json must be not empty."); } } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index 726f700b5..9e531443e 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -4845,18 +4845,11 @@ components: StateKeyValueStoreDataRequestKeyItem: description: Provide either `key_hex` or `key_json`. If both are provided, `key_hex` is used and `key_json` is ignored. type: object - required: - - key_json - properties: - key_json: - $ref: "#/components/schemas/ProgrammaticScryptoSborValue" - StateKeyValueStoreDataRequestHexKeyItem: - type: object - required: - - key_hex properties: key_hex: $ref: "#/components/schemas/HexString" + key_json: + $ref: "#/components/schemas/ProgrammaticScryptoSborValue" StateKeyValueStoreDataResponse: allOf: - $ref: "#/components/schemas/LedgerStateMixin" diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestHexKeyItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestHexKeyItem.cs deleted file mode 100644 index dd51a9a85..000000000 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestHexKeyItem.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.7.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 -{ - /// - /// StateKeyValueStoreDataRequestHexKeyItem - /// - [DataContract(Name = "StateKeyValueStoreDataRequestHexKeyItem")] - public partial class StateKeyValueStoreDataRequestHexKeyItem : IEquatable - { - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected StateKeyValueStoreDataRequestHexKeyItem() { } - /// - /// Initializes a new instance of the class. - /// - /// Hex-encoded binary blob. (required). - public StateKeyValueStoreDataRequestHexKeyItem(string keyHex = default(string)) - { - // to ensure "keyHex" is required (not null) - if (keyHex == null) - { - throw new ArgumentNullException("keyHex is a required property for StateKeyValueStoreDataRequestHexKeyItem and cannot be null"); - } - this.KeyHex = keyHex; - } - - /// - /// Hex-encoded binary blob. - /// - /// Hex-encoded binary blob. - [DataMember(Name = "key_hex", IsRequired = true, EmitDefaultValue = true)] - public string KeyHex { 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 StateKeyValueStoreDataRequestHexKeyItem {\n"); - sb.Append(" KeyHex: ").Append(KeyHex).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 StateKeyValueStoreDataRequestHexKeyItem); - } - - /// - /// Returns true if StateKeyValueStoreDataRequestHexKeyItem instances are equal - /// - /// Instance of StateKeyValueStoreDataRequestHexKeyItem to be compared - /// Boolean - public bool Equals(StateKeyValueStoreDataRequestHexKeyItem input) - { - if (input == null) - { - return false; - } - return - ( - this.KeyHex == input.KeyHex || - (this.KeyHex != null && - this.KeyHex.Equals(input.KeyHex)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.KeyHex != null) - { - hashCode = (hashCode * 59) + this.KeyHex.GetHashCode(); - } - return hashCode; - } - } - - } - -} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestJsonKeyItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestJsonKeyItem.cs deleted file mode 100644 index 9c69947a1..000000000 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestJsonKeyItem.cs +++ /dev/null @@ -1,193 +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.7.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 -{ - /// - /// StateKeyValueStoreDataRequestJsonKeyItem - /// - [DataContract(Name = "StateKeyValueStoreDataRequestJsonKeyItem")] - public partial class StateKeyValueStoreDataRequestJsonKeyItem : IEquatable - { - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected StateKeyValueStoreDataRequestJsonKeyItem() { } - /// - /// Initializes a new instance of the class. - /// - /// keyJson (required). - public StateKeyValueStoreDataRequestJsonKeyItem(ProgrammaticScryptoSborValue keyJson = default(ProgrammaticScryptoSborValue)) - { - // to ensure "keyJson" is required (not null) - if (keyJson == null) - { - throw new ArgumentNullException("keyJson is a required property for StateKeyValueStoreDataRequestJsonKeyItem and cannot be null"); - } - this.KeyJson = keyJson; - } - - /// - /// Gets or Sets KeyJson - /// - [DataMember(Name = "key_json", IsRequired = true, EmitDefaultValue = true)] - public ProgrammaticScryptoSborValue KeyJson { 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 StateKeyValueStoreDataRequestJsonKeyItem {\n"); - sb.Append(" KeyJson: ").Append(KeyJson).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 StateKeyValueStoreDataRequestJsonKeyItem); - } - - /// - /// Returns true if StateKeyValueStoreDataRequestJsonKeyItem instances are equal - /// - /// Instance of StateKeyValueStoreDataRequestJsonKeyItem to be compared - /// Boolean - public bool Equals(StateKeyValueStoreDataRequestJsonKeyItem input) - { - if (input == null) - { - return false; - } - return - ( - this.KeyJson == input.KeyJson || - (this.KeyJson != null && - this.KeyJson.Equals(input.KeyJson)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.KeyJson != null) - { - hashCode = (hashCode * 59) + this.KeyJson.GetHashCode(); - } - return hashCode; - } - } - - } - -} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs index 2c32d28e4..ddaef8d13 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs @@ -86,89 +86,38 @@ using Newtonsoft.Json.Linq; using FileParameter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.FileParameter; using OpenAPIDateConverter = RadixDlt.NetworkGateway.GatewayApiSdk.Client.OpenAPIDateConverter; -using System.Reflection; namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// /// Provide either `key_hex` or `key_json`. If both are provided, `key_hex` is used and `key_json` is ignored. /// - [JsonConverter(typeof(StateKeyValueStoreDataRequestKeyItemJsonConverter))] [DataContract(Name = "StateKeyValueStoreDataRequestKeyItem")] - public partial class StateKeyValueStoreDataRequestKeyItem : AbstractOpenAPISchema, IEquatable + public partial class StateKeyValueStoreDataRequestKeyItem : IEquatable { /// - /// Initializes a new instance of the class - /// with the class + /// Initializes a new instance of the class. /// - /// An instance of StateKeyValueStoreDataRequestJsonKeyItem. - public StateKeyValueStoreDataRequestKeyItem(StateKeyValueStoreDataRequestJsonKeyItem actualInstance) + /// Hex-encoded binary blob.. + /// keyJson. + public StateKeyValueStoreDataRequestKeyItem(string keyHex = default(string), ProgrammaticScryptoSborValue keyJson = default(ProgrammaticScryptoSborValue)) { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); + this.KeyHex = keyHex; + this.KeyJson = keyJson; } /// - /// Initializes a new instance of the class - /// with the class + /// Hex-encoded binary blob. /// - /// An instance of StateKeyValueStoreDataRequestHexKeyItem. - public StateKeyValueStoreDataRequestKeyItem(StateKeyValueStoreDataRequestHexKeyItem actualInstance) - { - this.IsNullable = false; - this.SchemaType= "oneOf"; - this.ActualInstance = actualInstance ?? throw new ArgumentException("Invalid instance found. Must not be null."); - } - - - private Object _actualInstance; - - /// - /// Gets or Sets ActualInstance - /// - public override Object ActualInstance - { - get - { - return _actualInstance; - } - set - { - if (value.GetType() == typeof(StateKeyValueStoreDataRequestHexKeyItem)) - { - this._actualInstance = value; - } - else if (value.GetType() == typeof(StateKeyValueStoreDataRequestJsonKeyItem)) - { - this._actualInstance = value; - } - else - { - throw new ArgumentException("Invalid instance found. Must be the following types: StateKeyValueStoreDataRequestHexKeyItem, StateKeyValueStoreDataRequestJsonKeyItem"); - } - } - } + /// Hex-encoded binary blob. + [DataMember(Name = "key_hex", EmitDefaultValue = true)] + public string KeyHex { get; set; } /// - /// Get the actual instance of `StateKeyValueStoreDataRequestJsonKeyItem`. If the actual instance is not `StateKeyValueStoreDataRequestJsonKeyItem`, - /// the InvalidClassException will be thrown + /// Gets or Sets KeyJson /// - /// An instance of StateKeyValueStoreDataRequestJsonKeyItem - public StateKeyValueStoreDataRequestJsonKeyItem GetStateKeyValueStoreDataRequestJsonKeyItem() - { - return (StateKeyValueStoreDataRequestJsonKeyItem)this.ActualInstance; - } - - /// - /// Get the actual instance of `StateKeyValueStoreDataRequestHexKeyItem`. If the actual instance is not `StateKeyValueStoreDataRequestHexKeyItem`, - /// the InvalidClassException will be thrown - /// - /// An instance of StateKeyValueStoreDataRequestHexKeyItem - public StateKeyValueStoreDataRequestHexKeyItem GetStateKeyValueStoreDataRequestHexKeyItem() - { - return (StateKeyValueStoreDataRequestHexKeyItem)this.ActualInstance; - } + [DataMember(Name = "key_json", EmitDefaultValue = true)] + public ProgrammaticScryptoSborValue KeyJson { get; set; } /// /// Returns the string presentation of the object @@ -176,9 +125,10 @@ public StateKeyValueStoreDataRequestHexKeyItem GetStateKeyValueStoreDataRequestH /// String presentation of the object public override string ToString() { - var sb = new StringBuilder(); + StringBuilder sb = new StringBuilder(); sb.Append("class StateKeyValueStoreDataRequestKeyItem {\n"); - sb.Append(" ActualInstance: ").Append(this.ActualInstance).Append("\n"); + sb.Append(" KeyHex: ").Append(KeyHex).Append("\n"); + sb.Append(" KeyJson: ").Append(KeyJson).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -187,78 +137,9 @@ public override string ToString() /// Returns the JSON string presentation of the object /// /// JSON string presentation of the object - public override string ToJson() + public virtual string ToJson() { - return JsonConvert.SerializeObject(this.ActualInstance, StateKeyValueStoreDataRequestKeyItem.SerializerSettings); - } - - /// - /// Converts the JSON string into an instance of StateKeyValueStoreDataRequestKeyItem - /// - /// JSON string - /// An instance of StateKeyValueStoreDataRequestKeyItem - public static StateKeyValueStoreDataRequestKeyItem FromJson(string jsonString) - { - StateKeyValueStoreDataRequestKeyItem newStateKeyValueStoreDataRequestKeyItem = null; - - if (string.IsNullOrEmpty(jsonString)) - { - return newStateKeyValueStoreDataRequestKeyItem; - } - int match = 0; - List matchedTypes = new List(); - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(StateKeyValueStoreDataRequestHexKeyItem).GetProperty("AdditionalProperties") == null) - { - newStateKeyValueStoreDataRequestKeyItem = new StateKeyValueStoreDataRequestKeyItem(JsonConvert.DeserializeObject(jsonString, StateKeyValueStoreDataRequestKeyItem.SerializerSettings)); - } - else - { - newStateKeyValueStoreDataRequestKeyItem = new StateKeyValueStoreDataRequestKeyItem(JsonConvert.DeserializeObject(jsonString, StateKeyValueStoreDataRequestKeyItem.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("StateKeyValueStoreDataRequestHexKeyItem"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into StateKeyValueStoreDataRequestHexKeyItem: {1}", jsonString, exception.ToString())); - } - - try - { - // if it does not contains "AdditionalProperties", use SerializerSettings to deserialize - if (typeof(StateKeyValueStoreDataRequestJsonKeyItem).GetProperty("AdditionalProperties") == null) - { - newStateKeyValueStoreDataRequestKeyItem = new StateKeyValueStoreDataRequestKeyItem(JsonConvert.DeserializeObject(jsonString, StateKeyValueStoreDataRequestKeyItem.SerializerSettings)); - } - else - { - newStateKeyValueStoreDataRequestKeyItem = new StateKeyValueStoreDataRequestKeyItem(JsonConvert.DeserializeObject(jsonString, StateKeyValueStoreDataRequestKeyItem.AdditionalPropertiesSerializerSettings)); - } - matchedTypes.Add("StateKeyValueStoreDataRequestJsonKeyItem"); - match++; - } - catch (Exception exception) - { - // deserialization failed, try the next one - System.Diagnostics.Debug.WriteLine(string.Format("Failed to deserialize `{0}` into StateKeyValueStoreDataRequestJsonKeyItem: {1}", jsonString, exception.ToString())); - } - - if (match == 0) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` cannot be deserialized into any schema defined."); - } - else if (match > 1) - { - throw new InvalidDataException("The JSON string `" + jsonString + "` incorrectly matches more than one schema (should be exactly one match): " + matchedTypes); - } - - // deserialization is considered successful at this point if no exception has been thrown. - return newStateKeyValueStoreDataRequestKeyItem; + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// @@ -279,9 +160,20 @@ public override bool Equals(object input) public bool Equals(StateKeyValueStoreDataRequestKeyItem input) { if (input == null) + { return false; - - return this.ActualInstance.Equals(input.ActualInstance); + } + return + ( + this.KeyHex == input.KeyHex || + (this.KeyHex != null && + this.KeyHex.Equals(input.KeyHex)) + ) && + ( + this.KeyJson == input.KeyJson || + (this.KeyJson != null && + this.KeyJson.Equals(input.KeyJson)) + ); } /// @@ -293,56 +185,18 @@ public override int GetHashCode() unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.ActualInstance != null) - hashCode = hashCode * 59 + this.ActualInstance.GetHashCode(); + if (this.KeyHex != null) + { + hashCode = (hashCode * 59) + this.KeyHex.GetHashCode(); + } + if (this.KeyJson != null) + { + hashCode = (hashCode * 59) + this.KeyJson.GetHashCode(); + } return hashCode; } } } - /// - /// Custom JSON converter for StateKeyValueStoreDataRequestKeyItem - /// - public class StateKeyValueStoreDataRequestKeyItemJsonConverter : JsonConverter - { - /// - /// To write the JSON string - /// - /// JSON writer - /// Object to be converted into a JSON string - /// JSON Serializer - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - writer.WriteRawValue((string)(typeof(StateKeyValueStoreDataRequestKeyItem).GetMethod("ToJson").Invoke(value, null))); - } - - /// - /// To convert a JSON string into an object - /// - /// JSON reader - /// Object type - /// Existing value - /// JSON Serializer - /// The object converted from the JSON string - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - if(reader.TokenType != JsonToken.Null) - { - return StateKeyValueStoreDataRequestKeyItem.FromJson(JObject.Load(reader).ToString(Formatting.None)); - } - return null; - } - - /// - /// Check if the object can be converted - /// - /// Object type - /// True if the object can be converted - public override bool CanConvert(Type objectType) - { - return false; - } - } - } From 1f02059a964595b635859e9d1fa3b200b4897e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Fri, 9 Aug 2024 10:14:04 +0200 Subject: [PATCH 05/18] use gatewaymodel pattern in entire codebase. --- babylon-gateway.sln.DotSettings | 1 + .../Handlers/DefaultExtensionsHandler.cs | 15 +++------------ .../Handlers/DefaultValidatorHandler.cs | 3 ++- .../Handlers/IExtensionsHandler.cs | 3 ++- .../Handlers/IValidatorHandler.cs | 3 ++- .../Services/IAccountStateQuerier.cs | 9 +++++---- .../Services/IDepositPreValidationQuerier.cs | 5 +++-- .../Services/IExtensionsQuerier.cs | 3 ++- .../Services/IValidatorQuerier.cs | 7 ++++--- .../Services/AccountStateQuerier.cs | 8 ++++---- .../Services/BlueprintProvider.cs | 5 +++-- .../Services/EntityStateQuerier.account.cs | 2 +- .../Services/EntityStateQuerier.nonfungibles.cs | 10 +++++----- .../Services/KeyValueStoreQuerier.cs | 6 +++--- .../Services/QueryHelper.cs | 5 +++-- .../Services/RoleAssignmentQuerier.cs | 11 ++++++----- .../Services/RoleAssignmentsMapper.cs | 4 ++-- 17 files changed, 51 insertions(+), 49 deletions(-) diff --git a/babylon-gateway.sln.DotSettings b/babylon-gateway.sln.DotSettings index 9b8c11fbb..99b35ffac 100644 --- a/babylon-gateway.sln.DotSettings +++ b/babylon-gateway.sln.DotSettings @@ -1,5 +1,6 @@  True + True True True True diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs index 82e923c04..7d0d25811 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs @@ -72,23 +72,14 @@ namespace RadixDlt.NetworkGateway.GatewayApi.Handlers; -internal class DefaultExtensionsHandler : IExtensionsHandler +internal class DefaultExtensionsHandler(IExtensionsQuerier extensionsQuerier, IOptionsSnapshot endpointConfiguration) : IExtensionsHandler { - private readonly IExtensionsQuerier _extensionsQuerier; - private readonly IOptionsSnapshot _endpointConfiguration; - - public DefaultExtensionsHandler(IExtensionsQuerier extensionsQuerier, IOptionsSnapshot endpointConfiguration) - { - _extensionsQuerier = extensionsQuerier; - _endpointConfiguration = endpointConfiguration; - } - public async Task ResourceOwners(GatewayModel.ResourceOwnersRequest request, CancellationToken token) { - return await _extensionsQuerier.ResourceOwners( + return await extensionsQuerier.ResourceOwners( (EntityAddress)request.ResourceAddress, GatewayModel.OffsetCursor.FromCursorString(request.Cursor)?.Offset ?? 0, - _endpointConfiguration.Value.ResolvePageSize(request.LimitPerPage), + endpointConfiguration.Value.ResolvePageSize(request.LimitPerPage), token); } } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultValidatorHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultValidatorHandler.cs index e850994f4..9bef160df 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultValidatorHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultValidatorHandler.cs @@ -67,6 +67,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.GatewayApi.Handlers; @@ -81,7 +82,7 @@ public DefaultValidatorHandler(ILedgerStateQuerier ledgerStateQuerier, IValidato _validatorQuerier = validatorQuerier; } - public async Task Uptime(GatewayApiSdk.Model.ValidatorsUptimeRequest request, CancellationToken token) + public async Task Uptime(GatewayModel.ValidatorsUptimeRequest request, CancellationToken token) { var ledgerState = await _ledgerStateQuerier.GetValidLedgerStateForReadRequest(request.AtLedgerState, token); var fromLedgerState = await _ledgerStateQuerier.GetValidLedgerStateForReadForwardRequest(request.FromLedgerState, token); diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs index c4c03f415..2795f3e76 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs @@ -64,10 +64,11 @@ using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.GatewayApi.Handlers; public interface IExtensionsHandler { - Task ResourceOwners(GatewayApiSdk.Model.ResourceOwnersRequest request, CancellationToken token); + Task ResourceOwners(GatewayModel.ResourceOwnersRequest request, CancellationToken token); } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IValidatorHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IValidatorHandler.cs index f5d3246d7..4a8037b86 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IValidatorHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IValidatorHandler.cs @@ -64,10 +64,11 @@ using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.GatewayApi.Handlers; public interface IValidatorHandler { - Task Uptime(GatewayApiSdk.Model.ValidatorsUptimeRequest request, CancellationToken token); + Task Uptime(GatewayModel.ValidatorsUptimeRequest request, CancellationToken token); } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IAccountStateQuerier.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IAccountStateQuerier.cs index a9ad2dbf4..1b57b35c4 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IAccountStateQuerier.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IAccountStateQuerier.cs @@ -65,21 +65,22 @@ using RadixDlt.NetworkGateway.Abstractions; using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.GatewayApi.Services; public interface IAccountStateQuerier { - Task AccountResourcePreferences( + Task AccountResourcePreferences( EntityAddress accountAddress, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, int offset, int limit, CancellationToken token = default); - Task AccountAuthorizedDepositors( + Task AccountAuthorizedDepositors( EntityAddress accountAddress, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, int offset, int limit, CancellationToken token = default); diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IDepositPreValidationQuerier.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IDepositPreValidationQuerier.cs index f1a9afff5..454591006 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IDepositPreValidationQuerier.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IDepositPreValidationQuerier.cs @@ -65,17 +65,18 @@ using RadixDlt.NetworkGateway.Abstractions; using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.GatewayApi.Services; public interface IDepositPreValidationQuerier { - Task AccountTryDepositPreValidation( + Task AccountTryDepositPreValidation( EntityAddress accountAddress, EntityAddress[] resourceAddresses, EntityAddress? badgeResourceAddress, string? nonFungibleBadgeNfid, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, CancellationToken token = default ); } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs index 90f2039e9..95d51679d 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs @@ -69,12 +69,13 @@ using RadixDlt.NetworkGateway.Abstractions; using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.GatewayApi.Services; public interface IExtensionsQuerier { - Task ResourceOwners( + Task ResourceOwners( EntityAddress resourceAddress, int offset, int limit, diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IValidatorQuerier.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IValidatorQuerier.cs index 20214f210..10dd9320b 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IValidatorQuerier.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IValidatorQuerier.cs @@ -66,14 +66,15 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.GatewayApi.Services; public interface IValidatorQuerier { - Task ValidatorsUptimeStatistics( + Task ValidatorsUptimeStatistics( IList validatorAddresses, - GatewayApiSdk.Model.LedgerState ledgerState, - GatewayApiSdk.Model.LedgerState? fromLedgerState, + GatewayModel.LedgerState ledgerState, + GatewayModel.LedgerState? fromLedgerState, CancellationToken token = default); } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountStateQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountStateQuerier.cs index 81181a68b..c14f111f0 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountStateQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/AccountStateQuerier.cs @@ -107,9 +107,9 @@ public AccountStateQuerier(IDapperWrapper dapperWrapper, ReadOnlyDbContext dbCon _dbContext = dbContext; } - public async Task AccountResourcePreferences( + public async Task AccountResourcePreferences( EntityAddress accountAddress, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, int offset, int limit, CancellationToken token = default) @@ -157,7 +157,7 @@ INNER JOIN LATERAL UNNEST(resource_preference_rules_slice) WITH ORDINALITY AS re lastUpdatedAtStateVersion: item.FromStateVersion)) .ToList(); - return new GatewayApiSdk.Model.StateAccountResourcePreferencesPageResponse( + return new GatewayModel.StateAccountResourcePreferencesPageResponse( ledgerState: ledgerState, accountAddress: accountAddress, totalCount: totalCount, @@ -226,7 +226,7 @@ INNER JOIN LATERAL UNNEST(resource_authorized_depositors_slice) WITH ORDINALITY })) .ToList(); - return new GatewayApiSdk.Model.StateAccountAuthorizedDepositorsPageResponse( + return new GatewayModel.StateAccountAuthorizedDepositorsPageResponse( ledgerState: ledgerState, accountAddress: accountAddress, totalCount: totalCount, diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/BlueprintProvider.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/BlueprintProvider.cs index fed6859a6..7433d2b37 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/BlueprintProvider.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/BlueprintProvider.cs @@ -68,6 +68,7 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.PostgresIntegration.Services; @@ -75,7 +76,7 @@ internal interface IBlueprintProvider { Task> GetBlueprints( IReadOnlyCollection blueprintDefinitions, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, CancellationToken token = default ); } @@ -91,7 +92,7 @@ public BlueprintProvider(ReadOnlyDbContext dbContext) public async Task> GetBlueprints( IReadOnlyCollection blueprintDefinitions, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, CancellationToken token = default ) { diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.account.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.account.cs index c882879a3..b9e3a5fac 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.account.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.account.cs @@ -169,7 +169,7 @@ LIMIT 1 ? new GatewayModel.StateAccountLockerAccountResourcesCursor(vaultsAndOneMore.Last().FromStateVersion, vaultsAndOneMore.Last().Id).ToCursorString() : null; - return new GatewayApiSdk.Model.StateAccountLockerPageVaultsResponse( + return new GatewayModel.StateAccountLockerPageVaultsResponse( ledgerState: ledgerState, lockerAddress: accountLocker.Address, accountAddress: account.Address, diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.nonfungibles.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.nonfungibles.cs index b0b9db423..b115052bc 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.nonfungibles.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/EntityStateQuerier.nonfungibles.cs @@ -511,7 +511,7 @@ private GatewayModel.NonFungibleResourcesCollection MapToNonFungibleResourcesCol int vaultLimit) { var resourcesTotalCount = 0; - var resources = new Dictionary(); + var resources = new Dictionary(); foreach (var vm in input) { @@ -519,12 +519,12 @@ private GatewayModel.NonFungibleResourcesCollection MapToNonFungibleResourcesCol if (!resources.TryGetValue(vm.ResourceEntityAddress, out var existingRecord)) { - existingRecord = new GatewayApiSdk.Model.NonFungibleResourcesCollectionItemVaultAggregated( + existingRecord = new GatewayModel.NonFungibleResourcesCollectionItemVaultAggregated( resourceAddress: vm.ResourceEntityAddress, - vaults: new GatewayApiSdk.Model.NonFungibleResourcesCollectionItemVaultAggregatedVault( + vaults: new GatewayModel.NonFungibleResourcesCollectionItemVaultAggregatedVault( totalCount: vm.VaultTotalCount, nextCursor: CursorGenerator.GenerateOffsetCursor(vaultOffset, vaultLimit, vm.VaultTotalCount), - items: new List())); + items: new List())); resources[vm.ResourceEntityAddress] = existingRecord; } @@ -543,7 +543,7 @@ private GatewayModel.NonFungibleResourcesCollection MapToNonFungibleResourcesCol lastUpdatedAtStateVersion: vm.LastUpdatedAtStateVersion)); } - var items = resources.Values.Cast().ToList(); + var items = resources.Values.Cast().ToList(); return new GatewayModel.NonFungibleResourcesCollection(resourcesTotalCount, CursorGenerator.GenerateOffsetCursor(resourceOffset, resourceLimit, resourcesTotalCount), items); } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/KeyValueStoreQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/KeyValueStoreQuerier.cs index 2a7f5268a..4ec785af1 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/KeyValueStoreQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/KeyValueStoreQuerier.cs @@ -96,9 +96,9 @@ public KeyValueStoreQuerier(IDapperWrapper dapperWrapper, ReadOnlyDbContext dbCo _networkConfigurationProvider = networkConfigurationProvider; } - public async Task KeyValueStoreKeys( + public async Task KeyValueStoreKeys( EntityAddress keyValueStoreAddress, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, GatewayModel.IdBoundaryCoursor? cursor, int pageSize, CancellationToken token = default) @@ -155,7 +155,7 @@ LIMIT @limit ? new GatewayModel.IdBoundaryCoursor(entriesAndOneMore.Last().FromStateVersion, entriesAndOneMore.Last().Id).ToCursorString() : null; - return new GatewayApiSdk.Model.StateKeyValueStoreKeysResponse( + return new GatewayModel.StateKeyValueStoreKeysResponse( ledgerState: ledgerState, keyValueStoreAddress: keyValueStoreAddress, nextCursor: nextCursor, diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/QueryHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/QueryHelper.cs index f05f4b716..0f90bfb1b 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/QueryHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/QueryHelper.cs @@ -70,12 +70,13 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.PostgresIntegration.Services; internal static class QueryHelper { - internal static async Task> ResolveEntityIds(ReadOnlyDbContext dbContext, List addresses, GatewayApiSdk.Model.LedgerState ledgerState, CancellationToken token) + internal static async Task> ResolveEntityIds(ReadOnlyDbContext dbContext, List addresses, GatewayModel.LedgerState ledgerState, CancellationToken token) { var entities = await dbContext .Entities @@ -86,7 +87,7 @@ internal static async Task> ResolveEntityIds(Rea return entities; } - internal static async Task GetEntity(ReadOnlyDbContext dbContext, EntityAddress address, GatewayApiSdk.Model.LedgerState ledgerState, CancellationToken token) + internal static async Task GetEntity(ReadOnlyDbContext dbContext, EntityAddress address, GatewayModel.LedgerState ledgerState, CancellationToken token) where TEntity : Entity { var entity = await dbContext diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/RoleAssignmentQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/RoleAssignmentQuerier.cs index afb2e11e3..752d9deaf 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/RoleAssignmentQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/RoleAssignmentQuerier.cs @@ -72,14 +72,15 @@ using System.Threading; using System.Threading.Tasks; using CoreApiModel = RadixDlt.CoreApiSdk.Model; +using GatewayModel = RadixDlt.NetworkGateway.GatewayApiSdk.Model; namespace RadixDlt.NetworkGateway.PostgresIntegration.Services; internal interface IRoleAssignmentQuerier { - Task> GetRoleAssignmentsHistory( + Task> GetRoleAssignmentsHistory( List componentEntities, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, CancellationToken token = default); } @@ -99,9 +100,9 @@ public RoleAssignmentQuerier( _blueprintProvider = blueprintProvider; } - public async Task> GetRoleAssignmentsHistory( + public async Task> GetRoleAssignmentsHistory( List componentEntities, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, CancellationToken token = default) { var componentLookup = componentEntities.Select(x => x.Id).ToHashSet(); @@ -152,7 +153,7 @@ public RoleAssignmentQuerier( private async Task> GetEntityRoleAssignmentsAggregateHistory( IReadOnlyCollection componentIds, - GatewayApiSdk.Model.LedgerState ledgerState, + GatewayModel.LedgerState ledgerState, CancellationToken token = default) { if (!componentIds.Any()) diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/RoleAssignmentsMapper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/RoleAssignmentsMapper.cs index 3f3b6c9a4..a0e44e236 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/RoleAssignmentsMapper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/RoleAssignmentsMapper.cs @@ -74,7 +74,7 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Services; internal interface IRoleAssignmentsMapper { - Dictionary GetEffectiveRoleAssignments( + Dictionary GetEffectiveRoleAssignments( ICollection componentEntities, Dictionary blueprintAuthConfigs, ICollection ownerRoles, @@ -119,7 +119,7 @@ public RoleAssignmentsMapper(IRoleAssignmentsKeyProvider roleAssignmentsKeyProvi var assignedNativeModuleKeys = nativeModulesKeys.Where(x => entity.AssignedModuleIds.Contains(x.Key.ModuleId)); var allModulesKeys = mainModuleKeys.Concat(assignedNativeModuleKeys).ToList(); - return new GatewayApiSdk.Model.ComponentEntityRoleAssignments( + return new GatewayModel.ComponentEntityRoleAssignments( new JRaw(ownerRole), GetEntries(entity.Id, allModulesKeys, roleAssignments) ); From 9f738985ebc1db5efee59d46aa45df548e115899 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Fri, 9 Aug 2024 15:19:50 +0200 Subject: [PATCH 06/18] revert ts changes. --- .../lib/generated/.openapi-generator/FILES | 16 ---- .../lib/generated/apis/ExtensionsApi.ts | 75 --------------- sdk/typescript/lib/generated/apis/index.ts | 1 - .../ProgrammaticScryptoSborValueEnum.ts | 4 +- .../ProgrammaticScryptoSborValueEnumAllOf.ts | 4 +- .../models/ProgrammaticScryptoSborValueOwn.ts | 2 +- .../ProgrammaticScryptoSborValueOwnAllOf.ts | 2 +- .../ProgrammaticScryptoSborValueReference.ts | 2 +- ...grammaticScryptoSborValueReferenceAllOf.ts | 2 +- .../models/ResourceOwnersCollection.ts | 89 ------------------ .../models/ResourceOwnersCollectionAllOf.ts | 73 -------------- ...rceOwnersCollectionFungibleResourceItem.ts | 94 ------------------- ...nersCollectionFungibleResourceItemAllOf.ts | 84 ----------------- .../models/ResourceOwnersCollectionItem.ts | 72 -------------- .../ResourceOwnersCollectionItemBase.ts | 82 ---------------- ...OwnersCollectionNonFungibleResourceItem.ts | 94 ------------------- ...sCollectionNonFungibleResourceItemAllOf.ts | 84 ----------------- .../generated/models/ResourceOwnersRequest.ts | 81 ---------------- .../models/ResourceOwnersRequestAllOf.ts | 65 ------------- .../models/ResourceOwnersResourceType.ts | 38 -------- .../models/ResourceOwnersResponse.ts | 73 -------------- .../models/ResourceOwnersResponseAllOf.ts | 73 -------------- ...StateKeyValueStoreDataRequestHexKeyItem.ts | 66 ------------- ...tateKeyValueStoreDataRequestJsonKeyItem.ts | 73 -------------- .../StateKeyValueStoreDataRequestKeyItem.ts | 65 ++++++++----- sdk/typescript/lib/generated/models/index.ts | 15 --- 26 files changed, 48 insertions(+), 1281 deletions(-) delete mode 100644 sdk/typescript/lib/generated/apis/ExtensionsApi.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollection.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionAllOf.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItem.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionItem.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionItemBase.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItem.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersRequest.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersRequestAllOf.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersResourceType.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersResponse.ts delete mode 100644 sdk/typescript/lib/generated/models/ResourceOwnersResponseAllOf.ts delete mode 100644 sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestHexKeyItem.ts delete mode 100644 sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestJsonKeyItem.ts diff --git a/sdk/typescript/lib/generated/.openapi-generator/FILES b/sdk/typescript/lib/generated/.openapi-generator/FILES index 1c64ced08..113fcbe07 100644 --- a/sdk/typescript/lib/generated/.openapi-generator/FILES +++ b/sdk/typescript/lib/generated/.openapi-generator/FILES @@ -1,5 +1,4 @@ .openapi-generator-ignore -apis/ExtensionsApi.ts apis/StateApi.ts apis/StatisticsApi.ts apis/StatusApi.ts @@ -256,19 +255,6 @@ models/PublicKeyHashEddsaEd25519AllOf.ts models/PublicKeyHashType.ts models/PublicKeyType.ts models/ResourceAggregationLevel.ts -models/ResourceOwnersCollection.ts -models/ResourceOwnersCollectionAllOf.ts -models/ResourceOwnersCollectionFungibleResourceItem.ts -models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts -models/ResourceOwnersCollectionItem.ts -models/ResourceOwnersCollectionItemBase.ts -models/ResourceOwnersCollectionNonFungibleResourceItem.ts -models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts -models/ResourceOwnersRequest.ts -models/ResourceOwnersRequestAllOf.ts -models/ResourceOwnersResourceType.ts -models/ResourceOwnersResponse.ts -models/ResourceOwnersResponseAllOf.ts models/ResultSetCursorMixin.ts models/RoleAssignmentResolution.ts models/RoleKey.ts @@ -334,8 +320,6 @@ models/StateEntitySchemaPageRequest.ts models/StateEntitySchemaPageResponse.ts models/StateKeyValueStoreDataRequest.ts models/StateKeyValueStoreDataRequestAllOf.ts -models/StateKeyValueStoreDataRequestHexKeyItem.ts -models/StateKeyValueStoreDataRequestJsonKeyItem.ts models/StateKeyValueStoreDataRequestKeyItem.ts models/StateKeyValueStoreDataResponse.ts models/StateKeyValueStoreDataResponseAllOf.ts diff --git a/sdk/typescript/lib/generated/apis/ExtensionsApi.ts b/sdk/typescript/lib/generated/apis/ExtensionsApi.ts deleted file mode 100644 index 77f85db5b..000000000 --- a/sdk/typescript/lib/generated/apis/ExtensionsApi.ts +++ /dev/null @@ -1,75 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -import * as runtime from '../runtime'; -import type { - ErrorResponse, - ResourceOwnersRequest, - ResourceOwnersResponse, -} from '../models'; -import { - ErrorResponseFromJSON, - ErrorResponseToJSON, - ResourceOwnersRequestFromJSON, - ResourceOwnersRequestToJSON, - ResourceOwnersResponseFromJSON, - ResourceOwnersResponseToJSON, -} from '../models'; - -export interface ResourceOwnersPageRequest { - resourceOwnersRequest: ResourceOwnersRequest; -} - -/** - * - */ -export class ExtensionsApi extends runtime.BaseAPI { - - /** - * Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - * Get Resource Owners Page - */ - async resourceOwnersPageRaw(requestParameters: ResourceOwnersPageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> { - if (requestParameters.resourceOwnersRequest === null || requestParameters.resourceOwnersRequest === undefined) { - throw new runtime.RequiredError('resourceOwnersRequest','Required parameter requestParameters.resourceOwnersRequest was null or undefined when calling resourceOwnersPage.'); - } - - const queryParameters: any = {}; - - const headerParameters: runtime.HTTPHeaders = {}; - - headerParameters['Content-Type'] = 'application/json'; - - const response = await this.request({ - path: `/extensions/resource-owners/page`, - method: 'POST', - headers: headerParameters, - query: queryParameters, - body: ResourceOwnersRequestToJSON(requestParameters.resourceOwnersRequest), - }, initOverrides); - - return new runtime.JSONApiResponse(response, (jsonValue) => ResourceOwnersResponseFromJSON(jsonValue)); - } - - /** - * Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. - * Get Resource Owners Page - */ - async resourceOwnersPage(requestParameters: ResourceOwnersPageRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise { - const response = await this.resourceOwnersPageRaw(requestParameters, initOverrides); - return await response.value(); - } - -} diff --git a/sdk/typescript/lib/generated/apis/index.ts b/sdk/typescript/lib/generated/apis/index.ts index 6f732ce8a..1707abc3c 100644 --- a/sdk/typescript/lib/generated/apis/index.ts +++ b/sdk/typescript/lib/generated/apis/index.ts @@ -1,6 +1,5 @@ /* tslint:disable */ /* eslint-disable */ -export * from './ExtensionsApi'; export * from './StateApi'; export * from './StatisticsApi'; export * from './StatusApi'; diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnum.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnum.ts index 632f660cd..dd6088877 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnum.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnum.ts @@ -52,10 +52,10 @@ This property is ignored when the value is used as an input to the API. field_name?: string | null; /** * - * @type {string} + * @type {number} * @memberof ProgrammaticScryptoSborValueEnum */ - variant_id: string; + variant_id: number; /** * * @type {string} diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnumAllOf.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnumAllOf.ts index 4b3272391..d95cf89f2 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnumAllOf.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueEnumAllOf.ts @@ -28,10 +28,10 @@ import { export interface ProgrammaticScryptoSborValueEnumAllOf { /** * - * @type {string} + * @type {number} * @memberof ProgrammaticScryptoSborValueEnumAllOf */ - variant_id: string; + variant_id: number; /** * * @type {string} diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwn.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwn.ts index 8d5249e4e..520d46ff0 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwn.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwn.ts @@ -44,7 +44,7 @@ This property is ignored when the value is used as an input to the API. */ field_name?: string | null; /** - * Bech32m-encoded human readable version of the address. + * * @type {string} * @memberof ProgrammaticScryptoSborValueOwn */ diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwnAllOf.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwnAllOf.ts index 7ccfe4f4e..fc2a27a78 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwnAllOf.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueOwnAllOf.ts @@ -20,7 +20,7 @@ import { exists, mapValues } from '../runtime'; */ export interface ProgrammaticScryptoSborValueOwnAllOf { /** - * Bech32m-encoded human readable version of the address. + * * @type {string} * @memberof ProgrammaticScryptoSborValueOwnAllOf */ diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReference.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReference.ts index 762dce592..e1f3de1a7 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReference.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReference.ts @@ -44,7 +44,7 @@ This property is ignored when the value is used as an input to the API. */ field_name?: string | null; /** - * Bech32m-encoded human readable version of the address. + * * @type {string} * @memberof ProgrammaticScryptoSborValueReference */ diff --git a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReferenceAllOf.ts b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReferenceAllOf.ts index bc46a0f4a..84381ae6d 100644 --- a/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReferenceAllOf.ts +++ b/sdk/typescript/lib/generated/models/ProgrammaticScryptoSborValueReferenceAllOf.ts @@ -20,7 +20,7 @@ import { exists, mapValues } from '../runtime'; */ export interface ProgrammaticScryptoSborValueReferenceAllOf { /** - * Bech32m-encoded human readable version of the address. + * * @type {string} * @memberof ProgrammaticScryptoSborValueReferenceAllOf */ diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollection.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollection.ts deleted file mode 100644 index 68e3c1e16..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersCollection.ts +++ /dev/null @@ -1,89 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { ResourceOwnersCollectionItem } from './ResourceOwnersCollectionItem'; -import { - ResourceOwnersCollectionItemFromJSON, - ResourceOwnersCollectionItemFromJSONTyped, - ResourceOwnersCollectionItemToJSON, -} from './ResourceOwnersCollectionItem'; - -/** - * - * @export - * @interface ResourceOwnersCollection - */ -export interface ResourceOwnersCollection { - /** - * Total number of items in underlying collection, fragment of which is available in `items` collection. - * @type {number} - * @memberof ResourceOwnersCollection - */ - total_count?: number | null; - /** - * If specified, contains a cursor to query next page of the `items` collection. - * @type {string} - * @memberof ResourceOwnersCollection - */ - next_cursor?: string | null; - /** - * - * @type {Array} - * @memberof ResourceOwnersCollection - */ - items: Array; -} - -/** - * Check if a given object implements the ResourceOwnersCollection interface. - */ -export function instanceOfResourceOwnersCollection(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "items" in value; - - return isInstance; -} - -export function ResourceOwnersCollectionFromJSON(json: any): ResourceOwnersCollection { - return ResourceOwnersCollectionFromJSONTyped(json, false); -} - -export function ResourceOwnersCollectionFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollection { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'total_count': !exists(json, 'total_count') ? undefined : json['total_count'], - 'next_cursor': !exists(json, 'next_cursor') ? undefined : json['next_cursor'], - 'items': ((json['items'] as Array).map(ResourceOwnersCollectionItemFromJSON)), - }; -} - -export function ResourceOwnersCollectionToJSON(value?: ResourceOwnersCollection | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'total_count': value.total_count, - 'next_cursor': value.next_cursor, - 'items': ((value.items as Array).map(ResourceOwnersCollectionItemToJSON)), - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionAllOf.ts deleted file mode 100644 index 740790c8c..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionAllOf.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { ResourceOwnersCollectionItem } from './ResourceOwnersCollectionItem'; -import { - ResourceOwnersCollectionItemFromJSON, - ResourceOwnersCollectionItemFromJSONTyped, - ResourceOwnersCollectionItemToJSON, -} from './ResourceOwnersCollectionItem'; - -/** - * - * @export - * @interface ResourceOwnersCollectionAllOf - */ -export interface ResourceOwnersCollectionAllOf { - /** - * - * @type {Array} - * @memberof ResourceOwnersCollectionAllOf - */ - items: Array; -} - -/** - * Check if a given object implements the ResourceOwnersCollectionAllOf interface. - */ -export function instanceOfResourceOwnersCollectionAllOf(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "items" in value; - - return isInstance; -} - -export function ResourceOwnersCollectionAllOfFromJSON(json: any): ResourceOwnersCollectionAllOf { - return ResourceOwnersCollectionAllOfFromJSONTyped(json, false); -} - -export function ResourceOwnersCollectionAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionAllOf { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'items': ((json['items'] as Array).map(ResourceOwnersCollectionItemFromJSON)), - }; -} - -export function ResourceOwnersCollectionAllOfToJSON(value?: ResourceOwnersCollectionAllOf | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'items': ((value.items as Array).map(ResourceOwnersCollectionItemToJSON)), - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItem.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItem.ts deleted file mode 100644 index b767dda06..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItem.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface ResourceOwnersCollectionFungibleResourceItem - */ -export interface ResourceOwnersCollectionFungibleResourceItem { - /** - * - * @type {string} - * @memberof ResourceOwnersCollectionFungibleResourceItem - */ - type: ResourceOwnersCollectionFungibleResourceItemTypeEnum; - /** - * Bech32m-encoded human readable version of the address. - * @type {string} - * @memberof ResourceOwnersCollectionFungibleResourceItem - */ - owner_address: string; - /** - * String-encoded decimal representing the amount of a related fungible resource. - * @type {string} - * @memberof ResourceOwnersCollectionFungibleResourceItem - */ - amount: string; -} - - -/** - * @export - */ -export const ResourceOwnersCollectionFungibleResourceItemTypeEnum = { - FungibleResource: 'FungibleResource' -} as const; -export type ResourceOwnersCollectionFungibleResourceItemTypeEnum = typeof ResourceOwnersCollectionFungibleResourceItemTypeEnum[keyof typeof ResourceOwnersCollectionFungibleResourceItemTypeEnum]; - - -/** - * Check if a given object implements the ResourceOwnersCollectionFungibleResourceItem interface. - */ -export function instanceOfResourceOwnersCollectionFungibleResourceItem(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "type" in value; - isInstance = isInstance && "owner_address" in value; - isInstance = isInstance && "amount" in value; - - return isInstance; -} - -export function ResourceOwnersCollectionFungibleResourceItemFromJSON(json: any): ResourceOwnersCollectionFungibleResourceItem { - return ResourceOwnersCollectionFungibleResourceItemFromJSONTyped(json, false); -} - -export function ResourceOwnersCollectionFungibleResourceItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionFungibleResourceItem { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'type': json['type'], - 'owner_address': json['owner_address'], - 'amount': json['amount'], - }; -} - -export function ResourceOwnersCollectionFungibleResourceItemToJSON(value?: ResourceOwnersCollectionFungibleResourceItem | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'type': value.type, - 'owner_address': value.owner_address, - 'amount': value.amount, - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts deleted file mode 100644 index db1aafaec..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionFungibleResourceItemAllOf.ts +++ /dev/null @@ -1,84 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface ResourceOwnersCollectionFungibleResourceItemAllOf - */ -export interface ResourceOwnersCollectionFungibleResourceItemAllOf { - /** - * String-encoded decimal representing the amount of a related fungible resource. - * @type {string} - * @memberof ResourceOwnersCollectionFungibleResourceItemAllOf - */ - amount: string; - /** - * - * @type {string} - * @memberof ResourceOwnersCollectionFungibleResourceItemAllOf - */ - type?: ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum; -} - - -/** - * @export - */ -export const ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum = { - FungibleResource: 'FungibleResource' -} as const; -export type ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum = typeof ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum[keyof typeof ResourceOwnersCollectionFungibleResourceItemAllOfTypeEnum]; - - -/** - * Check if a given object implements the ResourceOwnersCollectionFungibleResourceItemAllOf interface. - */ -export function instanceOfResourceOwnersCollectionFungibleResourceItemAllOf(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "amount" in value; - - return isInstance; -} - -export function ResourceOwnersCollectionFungibleResourceItemAllOfFromJSON(json: any): ResourceOwnersCollectionFungibleResourceItemAllOf { - return ResourceOwnersCollectionFungibleResourceItemAllOfFromJSONTyped(json, false); -} - -export function ResourceOwnersCollectionFungibleResourceItemAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionFungibleResourceItemAllOf { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'amount': json['amount'], - 'type': !exists(json, 'type') ? undefined : json['type'], - }; -} - -export function ResourceOwnersCollectionFungibleResourceItemAllOfToJSON(value?: ResourceOwnersCollectionFungibleResourceItemAllOf | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'amount': value.amount, - 'type': value.type, - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItem.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItem.ts deleted file mode 100644 index ed7d32a1c..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItem.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { - ResourceOwnersCollectionFungibleResourceItem, - instanceOfResourceOwnersCollectionFungibleResourceItem, - ResourceOwnersCollectionFungibleResourceItemFromJSON, - ResourceOwnersCollectionFungibleResourceItemFromJSONTyped, - ResourceOwnersCollectionFungibleResourceItemToJSON, -} from './ResourceOwnersCollectionFungibleResourceItem'; -import { - ResourceOwnersCollectionNonFungibleResourceItem, - instanceOfResourceOwnersCollectionNonFungibleResourceItem, - ResourceOwnersCollectionNonFungibleResourceItemFromJSON, - ResourceOwnersCollectionNonFungibleResourceItemFromJSONTyped, - ResourceOwnersCollectionNonFungibleResourceItemToJSON, -} from './ResourceOwnersCollectionNonFungibleResourceItem'; - -/** - * @type ResourceOwnersCollectionItem - * - * @export - */ -export type ResourceOwnersCollectionItem = { type: 'FungibleResource' } & ResourceOwnersCollectionFungibleResourceItem | { type: 'NonFungibleResource' } & ResourceOwnersCollectionNonFungibleResourceItem; - -export function ResourceOwnersCollectionItemFromJSON(json: any): ResourceOwnersCollectionItem { - return ResourceOwnersCollectionItemFromJSONTyped(json, false); -} - -export function ResourceOwnersCollectionItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionItem { - if ((json === undefined) || (json === null)) { - return json; - } - switch (json['type']) { - case 'FungibleResource': - return {...ResourceOwnersCollectionFungibleResourceItemFromJSONTyped(json, true), type: 'FungibleResource'}; - case 'NonFungibleResource': - return {...ResourceOwnersCollectionNonFungibleResourceItemFromJSONTyped(json, true), type: 'NonFungibleResource'}; - default: - throw new Error(`No variant of ResourceOwnersCollectionItem exists with 'type=${json['type']}'`); - } -} - -export function ResourceOwnersCollectionItemToJSON(value?: ResourceOwnersCollectionItem | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - switch (value['type']) { - case 'FungibleResource': - return ResourceOwnersCollectionFungibleResourceItemToJSON(value); - case 'NonFungibleResource': - return ResourceOwnersCollectionNonFungibleResourceItemToJSON(value); - default: - throw new Error(`No variant of ResourceOwnersCollectionItem exists with 'type=${value['type']}'`); - } - -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItemBase.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItemBase.ts deleted file mode 100644 index 88e1ef357..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionItemBase.ts +++ /dev/null @@ -1,82 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { ResourceOwnersResourceType } from './ResourceOwnersResourceType'; -import { - ResourceOwnersResourceTypeFromJSON, - ResourceOwnersResourceTypeFromJSONTyped, - ResourceOwnersResourceTypeToJSON, -} from './ResourceOwnersResourceType'; - -/** - * - * @export - * @interface ResourceOwnersCollectionItemBase - */ -export interface ResourceOwnersCollectionItemBase { - /** - * - * @type {ResourceOwnersResourceType} - * @memberof ResourceOwnersCollectionItemBase - */ - type: ResourceOwnersResourceType; - /** - * Bech32m-encoded human readable version of the address. - * @type {string} - * @memberof ResourceOwnersCollectionItemBase - */ - owner_address: string; -} - -/** - * Check if a given object implements the ResourceOwnersCollectionItemBase interface. - */ -export function instanceOfResourceOwnersCollectionItemBase(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "type" in value; - isInstance = isInstance && "owner_address" in value; - - return isInstance; -} - -export function ResourceOwnersCollectionItemBaseFromJSON(json: any): ResourceOwnersCollectionItemBase { - return ResourceOwnersCollectionItemBaseFromJSONTyped(json, false); -} - -export function ResourceOwnersCollectionItemBaseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionItemBase { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'type': ResourceOwnersResourceTypeFromJSON(json['type']), - 'owner_address': json['owner_address'], - }; -} - -export function ResourceOwnersCollectionItemBaseToJSON(value?: ResourceOwnersCollectionItemBase | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'type': ResourceOwnersResourceTypeToJSON(value.type), - 'owner_address': value.owner_address, - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItem.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItem.ts deleted file mode 100644 index 7aad508a1..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItem.ts +++ /dev/null @@ -1,94 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface ResourceOwnersCollectionNonFungibleResourceItem - */ -export interface ResourceOwnersCollectionNonFungibleResourceItem { - /** - * - * @type {string} - * @memberof ResourceOwnersCollectionNonFungibleResourceItem - */ - type: ResourceOwnersCollectionNonFungibleResourceItemTypeEnum; - /** - * Bech32m-encoded human readable version of the address. - * @type {string} - * @memberof ResourceOwnersCollectionNonFungibleResourceItem - */ - owner_address: string; - /** - * - * @type {number} - * @memberof ResourceOwnersCollectionNonFungibleResourceItem - */ - non_fungible_ids_count: number; -} - - -/** - * @export - */ -export const ResourceOwnersCollectionNonFungibleResourceItemTypeEnum = { - NonFungibleResource: 'NonFungibleResource' -} as const; -export type ResourceOwnersCollectionNonFungibleResourceItemTypeEnum = typeof ResourceOwnersCollectionNonFungibleResourceItemTypeEnum[keyof typeof ResourceOwnersCollectionNonFungibleResourceItemTypeEnum]; - - -/** - * Check if a given object implements the ResourceOwnersCollectionNonFungibleResourceItem interface. - */ -export function instanceOfResourceOwnersCollectionNonFungibleResourceItem(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "type" in value; - isInstance = isInstance && "owner_address" in value; - isInstance = isInstance && "non_fungible_ids_count" in value; - - return isInstance; -} - -export function ResourceOwnersCollectionNonFungibleResourceItemFromJSON(json: any): ResourceOwnersCollectionNonFungibleResourceItem { - return ResourceOwnersCollectionNonFungibleResourceItemFromJSONTyped(json, false); -} - -export function ResourceOwnersCollectionNonFungibleResourceItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionNonFungibleResourceItem { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'type': json['type'], - 'owner_address': json['owner_address'], - 'non_fungible_ids_count': json['non_fungible_ids_count'], - }; -} - -export function ResourceOwnersCollectionNonFungibleResourceItemToJSON(value?: ResourceOwnersCollectionNonFungibleResourceItem | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'type': value.type, - 'owner_address': value.owner_address, - 'non_fungible_ids_count': value.non_fungible_ids_count, - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts deleted file mode 100644 index 857994b0d..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersCollectionNonFungibleResourceItemAllOf.ts +++ /dev/null @@ -1,84 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface ResourceOwnersCollectionNonFungibleResourceItemAllOf - */ -export interface ResourceOwnersCollectionNonFungibleResourceItemAllOf { - /** - * - * @type {number} - * @memberof ResourceOwnersCollectionNonFungibleResourceItemAllOf - */ - non_fungible_ids_count: number; - /** - * - * @type {string} - * @memberof ResourceOwnersCollectionNonFungibleResourceItemAllOf - */ - type?: ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum; -} - - -/** - * @export - */ -export const ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum = { - NonFungibleResource: 'NonFungibleResource' -} as const; -export type ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum = typeof ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum[keyof typeof ResourceOwnersCollectionNonFungibleResourceItemAllOfTypeEnum]; - - -/** - * Check if a given object implements the ResourceOwnersCollectionNonFungibleResourceItemAllOf interface. - */ -export function instanceOfResourceOwnersCollectionNonFungibleResourceItemAllOf(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "non_fungible_ids_count" in value; - - return isInstance; -} - -export function ResourceOwnersCollectionNonFungibleResourceItemAllOfFromJSON(json: any): ResourceOwnersCollectionNonFungibleResourceItemAllOf { - return ResourceOwnersCollectionNonFungibleResourceItemAllOfFromJSONTyped(json, false); -} - -export function ResourceOwnersCollectionNonFungibleResourceItemAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersCollectionNonFungibleResourceItemAllOf { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'non_fungible_ids_count': json['non_fungible_ids_count'], - 'type': !exists(json, 'type') ? undefined : json['type'], - }; -} - -export function ResourceOwnersCollectionNonFungibleResourceItemAllOfToJSON(value?: ResourceOwnersCollectionNonFungibleResourceItemAllOf | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'non_fungible_ids_count': value.non_fungible_ids_count, - 'type': value.type, - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersRequest.ts b/sdk/typescript/lib/generated/models/ResourceOwnersRequest.ts deleted file mode 100644 index ab6155c7e..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersRequest.ts +++ /dev/null @@ -1,81 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface ResourceOwnersRequest - */ -export interface ResourceOwnersRequest { - /** - * This cursor allows forward pagination, by providing the cursor from the previous request. - * @type {string} - * @memberof ResourceOwnersRequest - */ - cursor?: string | null; - /** - * The page size requested. - * @type {number} - * @memberof ResourceOwnersRequest - */ - limit_per_page?: number | null; - /** - * Bech32m-encoded human readable version of the address. - * @type {string} - * @memberof ResourceOwnersRequest - */ - resource_address?: string; -} - -/** - * Check if a given object implements the ResourceOwnersRequest interface. - */ -export function instanceOfResourceOwnersRequest(value: object): boolean { - let isInstance = true; - - return isInstance; -} - -export function ResourceOwnersRequestFromJSON(json: any): ResourceOwnersRequest { - return ResourceOwnersRequestFromJSONTyped(json, false); -} - -export function ResourceOwnersRequestFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersRequest { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'cursor': !exists(json, 'cursor') ? undefined : json['cursor'], - 'limit_per_page': !exists(json, 'limit_per_page') ? undefined : json['limit_per_page'], - 'resource_address': !exists(json, 'resource_address') ? undefined : json['resource_address'], - }; -} - -export function ResourceOwnersRequestToJSON(value?: ResourceOwnersRequest | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'cursor': value.cursor, - 'limit_per_page': value.limit_per_page, - 'resource_address': value.resource_address, - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersRequestAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersRequestAllOf.ts deleted file mode 100644 index ab1f09dac..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersRequestAllOf.ts +++ /dev/null @@ -1,65 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface ResourceOwnersRequestAllOf - */ -export interface ResourceOwnersRequestAllOf { - /** - * Bech32m-encoded human readable version of the address. - * @type {string} - * @memberof ResourceOwnersRequestAllOf - */ - resource_address?: string; -} - -/** - * Check if a given object implements the ResourceOwnersRequestAllOf interface. - */ -export function instanceOfResourceOwnersRequestAllOf(value: object): boolean { - let isInstance = true; - - return isInstance; -} - -export function ResourceOwnersRequestAllOfFromJSON(json: any): ResourceOwnersRequestAllOf { - return ResourceOwnersRequestAllOfFromJSONTyped(json, false); -} - -export function ResourceOwnersRequestAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersRequestAllOf { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'resource_address': !exists(json, 'resource_address') ? undefined : json['resource_address'], - }; -} - -export function ResourceOwnersRequestAllOfToJSON(value?: ResourceOwnersRequestAllOf | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'resource_address': value.resource_address, - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersResourceType.ts b/sdk/typescript/lib/generated/models/ResourceOwnersResourceType.ts deleted file mode 100644 index 5265faba6..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersResourceType.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - - -/** - * - * @export - */ -export const ResourceOwnersResourceType = { - FungibleResource: 'FungibleResource', - NonFungibleResource: 'NonFungibleResource' -} as const; -export type ResourceOwnersResourceType = typeof ResourceOwnersResourceType[keyof typeof ResourceOwnersResourceType]; - - -export function ResourceOwnersResourceTypeFromJSON(json: any): ResourceOwnersResourceType { - return ResourceOwnersResourceTypeFromJSONTyped(json, false); -} - -export function ResourceOwnersResourceTypeFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersResourceType { - return json as ResourceOwnersResourceType; -} - -export function ResourceOwnersResourceTypeToJSON(value?: ResourceOwnersResourceType | null): any { - return value as any; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersResponse.ts b/sdk/typescript/lib/generated/models/ResourceOwnersResponse.ts deleted file mode 100644 index efcc70f3e..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersResponse.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { ResourceOwnersCollection } from './ResourceOwnersCollection'; -import { - ResourceOwnersCollectionFromJSON, - ResourceOwnersCollectionFromJSONTyped, - ResourceOwnersCollectionToJSON, -} from './ResourceOwnersCollection'; - -/** - * - * @export - * @interface ResourceOwnersResponse - */ -export interface ResourceOwnersResponse { - /** - * - * @type {ResourceOwnersCollection} - * @memberof ResourceOwnersResponse - */ - owners: ResourceOwnersCollection; -} - -/** - * Check if a given object implements the ResourceOwnersResponse interface. - */ -export function instanceOfResourceOwnersResponse(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "owners" in value; - - return isInstance; -} - -export function ResourceOwnersResponseFromJSON(json: any): ResourceOwnersResponse { - return ResourceOwnersResponseFromJSONTyped(json, false); -} - -export function ResourceOwnersResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersResponse { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'owners': ResourceOwnersCollectionFromJSON(json['owners']), - }; -} - -export function ResourceOwnersResponseToJSON(value?: ResourceOwnersResponse | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'owners': ResourceOwnersCollectionToJSON(value.owners), - }; -} - diff --git a/sdk/typescript/lib/generated/models/ResourceOwnersResponseAllOf.ts b/sdk/typescript/lib/generated/models/ResourceOwnersResponseAllOf.ts deleted file mode 100644 index ddbc2ec47..000000000 --- a/sdk/typescript/lib/generated/models/ResourceOwnersResponseAllOf.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { ResourceOwnersCollection } from './ResourceOwnersCollection'; -import { - ResourceOwnersCollectionFromJSON, - ResourceOwnersCollectionFromJSONTyped, - ResourceOwnersCollectionToJSON, -} from './ResourceOwnersCollection'; - -/** - * - * @export - * @interface ResourceOwnersResponseAllOf - */ -export interface ResourceOwnersResponseAllOf { - /** - * - * @type {ResourceOwnersCollection} - * @memberof ResourceOwnersResponseAllOf - */ - owners: ResourceOwnersCollection; -} - -/** - * Check if a given object implements the ResourceOwnersResponseAllOf interface. - */ -export function instanceOfResourceOwnersResponseAllOf(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "owners" in value; - - return isInstance; -} - -export function ResourceOwnersResponseAllOfFromJSON(json: any): ResourceOwnersResponseAllOf { - return ResourceOwnersResponseAllOfFromJSONTyped(json, false); -} - -export function ResourceOwnersResponseAllOfFromJSONTyped(json: any, ignoreDiscriminator: boolean): ResourceOwnersResponseAllOf { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'owners': ResourceOwnersCollectionFromJSON(json['owners']), - }; -} - -export function ResourceOwnersResponseAllOfToJSON(value?: ResourceOwnersResponseAllOf | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'owners': ResourceOwnersCollectionToJSON(value.owners), - }; -} - diff --git a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestHexKeyItem.ts b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestHexKeyItem.ts deleted file mode 100644 index 387c724fe..000000000 --- a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestHexKeyItem.ts +++ /dev/null @@ -1,66 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -/** - * - * @export - * @interface StateKeyValueStoreDataRequestHexKeyItem - */ -export interface StateKeyValueStoreDataRequestHexKeyItem { - /** - * Hex-encoded binary blob. - * @type {string} - * @memberof StateKeyValueStoreDataRequestHexKeyItem - */ - key_hex: string; -} - -/** - * Check if a given object implements the StateKeyValueStoreDataRequestHexKeyItem interface. - */ -export function instanceOfStateKeyValueStoreDataRequestHexKeyItem(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "key_hex" in value; - - return isInstance; -} - -export function StateKeyValueStoreDataRequestHexKeyItemFromJSON(json: any): StateKeyValueStoreDataRequestHexKeyItem { - return StateKeyValueStoreDataRequestHexKeyItemFromJSONTyped(json, false); -} - -export function StateKeyValueStoreDataRequestHexKeyItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): StateKeyValueStoreDataRequestHexKeyItem { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'key_hex': json['key_hex'], - }; -} - -export function StateKeyValueStoreDataRequestHexKeyItemToJSON(value?: StateKeyValueStoreDataRequestHexKeyItem | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'key_hex': value.key_hex, - }; -} - diff --git a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestJsonKeyItem.ts b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestJsonKeyItem.ts deleted file mode 100644 index 29fc2681c..000000000 --- a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestJsonKeyItem.ts +++ /dev/null @@ -1,73 +0,0 @@ -/* tslint:disable */ -/* eslint-disable */ -/** - * 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.7.0 - * - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -import { exists, mapValues } from '../runtime'; -import type { ProgrammaticScryptoSborValue } from './ProgrammaticScryptoSborValue'; -import { - ProgrammaticScryptoSborValueFromJSON, - ProgrammaticScryptoSborValueFromJSONTyped, - ProgrammaticScryptoSborValueToJSON, -} from './ProgrammaticScryptoSborValue'; - -/** - * - * @export - * @interface StateKeyValueStoreDataRequestJsonKeyItem - */ -export interface StateKeyValueStoreDataRequestJsonKeyItem { - /** - * - * @type {ProgrammaticScryptoSborValue} - * @memberof StateKeyValueStoreDataRequestJsonKeyItem - */ - key_json: ProgrammaticScryptoSborValue; -} - -/** - * Check if a given object implements the StateKeyValueStoreDataRequestJsonKeyItem interface. - */ -export function instanceOfStateKeyValueStoreDataRequestJsonKeyItem(value: object): boolean { - let isInstance = true; - isInstance = isInstance && "key_json" in value; - - return isInstance; -} - -export function StateKeyValueStoreDataRequestJsonKeyItemFromJSON(json: any): StateKeyValueStoreDataRequestJsonKeyItem { - return StateKeyValueStoreDataRequestJsonKeyItemFromJSONTyped(json, false); -} - -export function StateKeyValueStoreDataRequestJsonKeyItemFromJSONTyped(json: any, ignoreDiscriminator: boolean): StateKeyValueStoreDataRequestJsonKeyItem { - if ((json === undefined) || (json === null)) { - return json; - } - return { - - 'key_json': ProgrammaticScryptoSborValueFromJSON(json['key_json']), - }; -} - -export function StateKeyValueStoreDataRequestJsonKeyItemToJSON(value?: StateKeyValueStoreDataRequestJsonKeyItem | null): any { - if (value === undefined) { - return undefined; - } - if (value === null) { - return null; - } - return { - - 'key_json': ProgrammaticScryptoSborValueToJSON(value.key_json), - }; -} - diff --git a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestKeyItem.ts b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestKeyItem.ts index 821e125dd..637cc7aaf 100644 --- a/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestKeyItem.ts +++ b/sdk/typescript/lib/generated/models/StateKeyValueStoreDataRequestKeyItem.ts @@ -12,27 +12,42 @@ * Do not edit the class manually. */ +import { exists, mapValues } from '../runtime'; +import type { ProgrammaticScryptoSborValue } from './ProgrammaticScryptoSborValue'; import { - StateKeyValueStoreDataRequestHexKeyItem, - instanceOfStateKeyValueStoreDataRequestHexKeyItem, - StateKeyValueStoreDataRequestHexKeyItemFromJSON, - StateKeyValueStoreDataRequestHexKeyItemFromJSONTyped, - StateKeyValueStoreDataRequestHexKeyItemToJSON, -} from './StateKeyValueStoreDataRequestHexKeyItem'; -import { - StateKeyValueStoreDataRequestJsonKeyItem, - instanceOfStateKeyValueStoreDataRequestJsonKeyItem, - StateKeyValueStoreDataRequestJsonKeyItemFromJSON, - StateKeyValueStoreDataRequestJsonKeyItemFromJSONTyped, - StateKeyValueStoreDataRequestJsonKeyItemToJSON, -} from './StateKeyValueStoreDataRequestJsonKeyItem'; + ProgrammaticScryptoSborValueFromJSON, + ProgrammaticScryptoSborValueFromJSONTyped, + ProgrammaticScryptoSborValueToJSON, +} from './ProgrammaticScryptoSborValue'; /** - * @type StateKeyValueStoreDataRequestKeyItem * * @export + * @interface StateKeyValueStoreDataRequestKeyItem + */ +export interface StateKeyValueStoreDataRequestKeyItem { + /** + * Hex-encoded binary blob. + * @type {string} + * @memberof StateKeyValueStoreDataRequestKeyItem + */ + key_hex?: string; + /** + * + * @type {ProgrammaticScryptoSborValue} + * @memberof StateKeyValueStoreDataRequestKeyItem + */ + key_json?: ProgrammaticScryptoSborValue; +} + +/** + * Check if a given object implements the StateKeyValueStoreDataRequestKeyItem interface. */ -export type StateKeyValueStoreDataRequestKeyItem = StateKeyValueStoreDataRequestHexKeyItem | StateKeyValueStoreDataRequestJsonKeyItem; +export function instanceOfStateKeyValueStoreDataRequestKeyItem(value: object): boolean { + let isInstance = true; + + return isInstance; +} export function StateKeyValueStoreDataRequestKeyItemFromJSON(json: any): StateKeyValueStoreDataRequestKeyItem { return StateKeyValueStoreDataRequestKeyItemFromJSONTyped(json, false); @@ -42,7 +57,11 @@ export function StateKeyValueStoreDataRequestKeyItemFromJSONTyped(json: any, ign if ((json === undefined) || (json === null)) { return json; } - return { ...StateKeyValueStoreDataRequestHexKeyItemFromJSONTyped(json, true), ...StateKeyValueStoreDataRequestJsonKeyItemFromJSONTyped(json, true) }; + return { + + 'key_hex': !exists(json, 'key_hex') ? undefined : json['key_hex'], + 'key_json': !exists(json, 'key_json') ? undefined : ProgrammaticScryptoSborValueFromJSON(json['key_json']), + }; } export function StateKeyValueStoreDataRequestKeyItemToJSON(value?: StateKeyValueStoreDataRequestKeyItem | null): any { @@ -52,14 +71,10 @@ export function StateKeyValueStoreDataRequestKeyItemToJSON(value?: StateKeyValue if (value === null) { return null; } - - if (instanceOfStateKeyValueStoreDataRequestHexKeyItem(value)) { - return StateKeyValueStoreDataRequestHexKeyItemToJSON(value as StateKeyValueStoreDataRequestHexKeyItem); - } - if (instanceOfStateKeyValueStoreDataRequestJsonKeyItem(value)) { - return StateKeyValueStoreDataRequestJsonKeyItemToJSON(value as StateKeyValueStoreDataRequestJsonKeyItem); - } - - return {}; + return { + + 'key_hex': value.key_hex, + 'key_json': ProgrammaticScryptoSborValueToJSON(value.key_json), + }; } diff --git a/sdk/typescript/lib/generated/models/index.ts b/sdk/typescript/lib/generated/models/index.ts index 8f7988831..210e8c37a 100644 --- a/sdk/typescript/lib/generated/models/index.ts +++ b/sdk/typescript/lib/generated/models/index.ts @@ -249,19 +249,6 @@ export * from './PublicKeyHashEddsaEd25519AllOf'; export * from './PublicKeyHashType'; export * from './PublicKeyType'; export * from './ResourceAggregationLevel'; -export * from './ResourceOwnersCollection'; -export * from './ResourceOwnersCollectionAllOf'; -export * from './ResourceOwnersCollectionFungibleResourceItem'; -export * from './ResourceOwnersCollectionFungibleResourceItemAllOf'; -export * from './ResourceOwnersCollectionItem'; -export * from './ResourceOwnersCollectionItemBase'; -export * from './ResourceOwnersCollectionNonFungibleResourceItem'; -export * from './ResourceOwnersCollectionNonFungibleResourceItemAllOf'; -export * from './ResourceOwnersRequest'; -export * from './ResourceOwnersRequestAllOf'; -export * from './ResourceOwnersResourceType'; -export * from './ResourceOwnersResponse'; -export * from './ResourceOwnersResponseAllOf'; export * from './ResultSetCursorMixin'; export * from './RoleAssignmentResolution'; export * from './RoleKey'; @@ -327,8 +314,6 @@ export * from './StateEntitySchemaPageRequest'; export * from './StateEntitySchemaPageResponse'; export * from './StateKeyValueStoreDataRequest'; export * from './StateKeyValueStoreDataRequestAllOf'; -export * from './StateKeyValueStoreDataRequestHexKeyItem'; -export * from './StateKeyValueStoreDataRequestJsonKeyItem'; export * from './StateKeyValueStoreDataRequestKeyItem'; export * from './StateKeyValueStoreDataResponse'; export * from './StateKeyValueStoreDataResponseAllOf'; From eee74fac928158e5691b6c0fd9d625b578dd6582 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Fri, 9 Aug 2024 13:55:56 +0200 Subject: [PATCH 07/18] pull request cleanup. --- apps/DataAggregator/packages.lock.json | 3 +- apps/DatabaseMigrations/packages.lock.json | 3 +- apps/GatewayApi/packages.lock.json | 3 +- .../Handlers/DefaultExtensionsHandler.cs | 4 +- .../Services/IExtensionsQuerier.cs | 2 +- .../gateway-api-schema.yaml | 4 +- .../packages.lock.json | 3 +- .../Model/ResourceOwnersCursor.cs | 87 +++++ ...dixDlt.NetworkGateway.GatewayApiSdk.csproj | 4 + .../packages.lock.json | 369 ++++++++++++++++++ .../CommonDbContext.cs | 23 +- .../LedgerExtension/Extensions.cs | 21 + .../PostgresLedgerExtenderService.cs | 59 ++- .../LedgerExtension/WriteHelper.cs | 18 +- .../20240812074026_InitialCreate.Designer.cs | 51 +-- .../20240812074026_InitialCreate.cs | 13 +- .../MigrationsDbContextModelSnapshot.cs | 47 +-- .../Models/ResourceOwners.cs | 11 +- .../Services/ExtensionsQuerier.cs | 97 ++--- .../packages.lock.json | 3 +- .../packages.lock.json | 3 +- .../packages.lock.json | 3 +- 22 files changed, 595 insertions(+), 236 deletions(-) create mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceOwnersCursor.cs diff --git a/apps/DataAggregator/packages.lock.json b/apps/DataAggregator/packages.lock.json index e54a84c18..c615124ea 100644 --- a/apps/DataAggregator/packages.lock.json +++ b/apps/DataAggregator/packages.lock.json @@ -660,7 +660,8 @@ "dependencies": { "JsonSubTypes": "[2.0.1, )", "Newtonsoft.Json": "[13.0.3, )", - "Polly": "[8.3.0, )" + "Polly": "[8.3.0, )", + "RadixDlt.NetworkGateway.Abstractions": "[1.7.0-develop, )" } }, "radixdlt.networkgateway.postgresintegration": { diff --git a/apps/DatabaseMigrations/packages.lock.json b/apps/DatabaseMigrations/packages.lock.json index 2139d7be7..5db080162 100644 --- a/apps/DatabaseMigrations/packages.lock.json +++ b/apps/DatabaseMigrations/packages.lock.json @@ -593,7 +593,8 @@ "dependencies": { "JsonSubTypes": "[2.0.1, )", "Newtonsoft.Json": "[13.0.3, )", - "Polly": "[8.3.0, )" + "Polly": "[8.3.0, )", + "RadixDlt.NetworkGateway.Abstractions": "[1.7.0-develop, )" } }, "radixdlt.networkgateway.postgresintegration": { diff --git a/apps/GatewayApi/packages.lock.json b/apps/GatewayApi/packages.lock.json index 0c3309045..798141145 100644 --- a/apps/GatewayApi/packages.lock.json +++ b/apps/GatewayApi/packages.lock.json @@ -718,7 +718,8 @@ "dependencies": { "JsonSubTypes": "[2.0.1, )", "Newtonsoft.Json": "[13.0.3, )", - "Polly": "[8.3.0, )" + "Polly": "[8.3.0, )", + "RadixDlt.NetworkGateway.Abstractions": "[1.7.0-develop, )" } }, "radixdlt.networkgateway.postgresintegration": { diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs index 7d0d25811..e6ed0e6d4 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs @@ -76,10 +76,12 @@ internal class DefaultExtensionsHandler(IExtensionsQuerier extensionsQuerier, IO { public async Task ResourceOwners(GatewayModel.ResourceOwnersRequest request, CancellationToken token) { + var cursor = GatewayModel.ResourceOwnersCursor.FromCursorString(request.Cursor); + return await extensionsQuerier.ResourceOwners( (EntityAddress)request.ResourceAddress, - GatewayModel.OffsetCursor.FromCursorString(request.Cursor)?.Offset ?? 0, endpointConfiguration.Value.ResolvePageSize(request.LimitPerPage), + cursor, token); } } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs index 95d51679d..ee62fe387 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs @@ -77,7 +77,7 @@ public interface IExtensionsQuerier { Task ResourceOwners( EntityAddress resourceAddress, - int offset, int limit, + GatewayModel.ResourceOwnersCursor? cursor, CancellationToken token = default); } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index 9e531443e..f693fb730 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -1910,7 +1910,9 @@ paths: operationId: ResourceOwnersPage summary: Get Resource Owners Page description: | - Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. + This endpoint operates only at current state version, it is not possible to browse historical data. + Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. tags: - Extensions requestBody: diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/packages.lock.json b/src/RadixDlt.NetworkGateway.GatewayApi/packages.lock.json index 164813298..cf40ca03b 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/packages.lock.json +++ b/src/RadixDlt.NetworkGateway.GatewayApi/packages.lock.json @@ -387,7 +387,8 @@ "dependencies": { "JsonSubTypes": "[2.0.1, )", "Newtonsoft.Json": "[13.0.3, )", - "Polly": "[8.3.0, )" + "Polly": "[8.3.0, )", + "RadixDlt.NetworkGateway.Abstractions": "[1.7.0-develop, )" } }, "FluentValidation": { diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceOwnersCursor.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceOwnersCursor.cs new file mode 100644 index 000000000..3508297e9 --- /dev/null +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceOwnersCursor.cs @@ -0,0 +1,87 @@ +/* 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.Runtime.Serialization; + +namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model; + +[DataContract] +public sealed record ResourceOwnersCursor(long? IdBoundary, string BalanceBoundary) +{ + [DataMember(Name = "id", EmitDefaultValue = false)] + public long? IdBoundary { get; set; } = IdBoundary; + + [DataMember(Name = "b", EmitDefaultValue = false)] + public string BalanceBoundary { get; set; } = BalanceBoundary; + + public static ResourceOwnersCursor FromCursorString(string cursorString) + { + return Serializations.FromBase64JsonOrDefault(cursorString); + } + + public string ToCursorString() + { + return Serializations.AsBase64Json(this); + } +} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/RadixDlt.NetworkGateway.GatewayApiSdk.csproj b/src/RadixDlt.NetworkGateway.GatewayApiSdk/RadixDlt.NetworkGateway.GatewayApiSdk.csproj index cb13d5f84..134e2b7c2 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/RadixDlt.NetworkGateway.GatewayApiSdk.csproj +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/RadixDlt.NetworkGateway.GatewayApiSdk.csproj @@ -15,4 +15,8 @@ + + + + diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/packages.lock.json b/src/RadixDlt.NetworkGateway.GatewayApiSdk/packages.lock.json index 9c331036d..c9a603679 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/packages.lock.json +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/packages.lock.json @@ -35,6 +35,263 @@ "StyleCop.Analyzers.Unstable": "1.2.0.556" } }, + "Microsoft.Extensions.Configuration.Abstractions": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "3lE/iLSutpgX1CC0NOW70FJoGARRHbyKmG7dc0klnUZ9Dd9hS6N/POPWhKhMLCEuNN5nXEY5agmlFtH562vqhQ==", + "dependencies": { + "Microsoft.Extensions.Primitives": "8.0.0" + } + }, + "Microsoft.Extensions.Configuration.Binder": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "mBMoXLsr5s1y2zOHWmKsE9veDcx8h1x/c3rz4baEdQKTeDcmQAPNbB54Pi/lhFO3K431eEq6PFbMgLaa6PHFfA==", + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0" + } + }, + "Microsoft.Extensions.Configuration.CommandLine": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "NZuZMz3Q8Z780nKX3ifV1fE7lS+6pynDHK71OfU4OZ1ItgvDOhyOC7E6z+JMZrAj63zRpwbdldYFk499t3+1dQ==", + "dependencies": { + "Microsoft.Extensions.Configuration": "8.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0" + } + }, + "Microsoft.Extensions.Configuration.EnvironmentVariables": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "plvZ0ZIpq+97gdPNNvhwvrEZ92kNml9hd1pe3idMA7svR0PztdzVLkoWLcRFgySYXUJc3kSM3Xw3mNFMo/bxRA==", + "dependencies": { + "Microsoft.Extensions.Configuration": "8.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0" + } + }, + "Microsoft.Extensions.Configuration.FileExtensions": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "McP+Lz/EKwvtCv48z0YImw+L1gi1gy5rHhNaNIY2CrjloV+XY8gydT8DjMR6zWeL13AFK+DioVpppwAuO1Gi1w==", + "dependencies": { + "Microsoft.Extensions.Configuration": "8.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "8.0.0", + "Microsoft.Extensions.FileProviders.Physical": "8.0.0", + "Microsoft.Extensions.Primitives": "8.0.0" + } + }, + "Microsoft.Extensions.Configuration.Json": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "C2wqUoh9OmRL1akaCcKSTmRU8z0kckfImG7zLNI8uyi47Lp+zd5LWAD17waPQEqCz3ioWOCrFUo+JJuoeZLOBw==", + "dependencies": { + "Microsoft.Extensions.Configuration": "8.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "8.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "8.0.0", + "System.Text.Json": "8.0.0" + } + }, + "Microsoft.Extensions.Configuration.UserSecrets": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "ihDHu2dJYQird9pl2CbdwuNDfvCZdOS0S7SPlNfhPt0B81UTT+yyZKz2pimFZGUp3AfuBRnqUCxB2SjsZKHVUw==", + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.Configuration.Json": "8.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "8.0.0", + "Microsoft.Extensions.FileProviders.Physical": "8.0.0" + } + }, + "Microsoft.Extensions.DependencyInjection": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "V8S3bsm50ig6JSyrbcJJ8bW2b9QLGouz+G1miK3UTaOWmMtFwNNNzUf4AleyDWUmTrWMLNnFSLEQtxmxgNQnNQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + } + }, + "Microsoft.Extensions.DependencyInjection.Abstractions": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "cjWrLkJXK0rs4zofsK4bSdg+jhDLTaxrkXu4gS6Y7MAlCvRyNNgwY/lJi5RDlQOnSZweHqoyvgvbdvQsRIW+hg==" + }, + "Microsoft.Extensions.Diagnostics": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "3PZp/YSkIXrF7QK7PfC1bkyRYwqOHpWFad8Qx+4wkuumAeXo1NHaxpS9LboNA9OvNSAu+QOVlXbMyoY+pHSqcw==", + "dependencies": { + "Microsoft.Extensions.Configuration": "8.0.0", + "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "8.0.0" + } + }, + "Microsoft.Extensions.Diagnostics.Abstractions": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "JHYCQG7HmugNYUhOl368g+NMxYE/N/AiclCYRNlgCY9eVyiBkOHMwK4x60RYMxv9EL3+rmj1mqHvdCiPpC+D4Q==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Options": "8.0.0", + "System.Diagnostics.DiagnosticSource": "8.0.0" + } + }, + "Microsoft.Extensions.FileProviders.Abstractions": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "ZbaMlhJlpisjuWbvXr4LdAst/1XxH3vZ6A0BsgTphZ2L4PGuxRLz7Jr/S7mkAAnOn78Vu0fKhEgNF5JO3zfjqQ==", + "dependencies": { + "Microsoft.Extensions.Primitives": "8.0.0" + } + }, + "Microsoft.Extensions.FileProviders.Physical": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "UboiXxpPUpwulHvIAVE36Knq0VSHaAmfrFkegLyBZeaADuKezJ/AIXYAW8F5GBlGk/VaibN2k/Zn1ca8YAfVdA==", + "dependencies": { + "Microsoft.Extensions.FileProviders.Abstractions": "8.0.0", + "Microsoft.Extensions.FileSystemGlobbing": "8.0.0", + "Microsoft.Extensions.Primitives": "8.0.0" + } + }, + "Microsoft.Extensions.FileSystemGlobbing": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "OK+670i7esqlQrPjdIKRbsyMCe9g5kSLpRRQGSr4Q58AOYEe/hCnfLZprh7viNisSUUQZmMrbbuDaIrP+V1ebQ==" + }, + "Microsoft.Extensions.Hosting.Abstractions": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "AG7HWwVRdCHlaA++1oKDxLsXIBxmDpMPb3VoyOoAghEWnkUvEAdYQUwnV4jJbAaa/nMYNiEh5ByoLauZBEiovg==", + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Diagnostics.Abstractions": "8.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.0" + } + }, + "Microsoft.Extensions.Logging": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "tvRkov9tAJ3xP51LCv3FJ2zINmv1P8Hi8lhhtcKGqM+ImiTCC84uOPEI4z8Cdq2C3o9e+Aa0Gw0rmrsJD77W+w==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection": "8.0.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.0", + "Microsoft.Extensions.Options": "8.0.0" + } + }, + "Microsoft.Extensions.Logging.Configuration": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "ixXXV0G/12g6MXK65TLngYN9V5hQQRuV+fZi882WIoVJT7h5JvoYoxTEwCgdqwLjSneqh1O+66gM8sMr9z/rsQ==", + "dependencies": { + "Microsoft.Extensions.Configuration": "8.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.Configuration.Binder": "8.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging": "8.0.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.0", + "Microsoft.Extensions.Options": "8.0.0", + "Microsoft.Extensions.Options.ConfigurationExtensions": "8.0.0" + } + }, + "Microsoft.Extensions.Logging.Console": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "e+48o7DztoYog+PY430lPxrM4mm3PbA6qucvQtUDDwVo4MO+ejMw7YGc/o2rnxbxj4isPxdfKFzTxvXMwAz83A==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging": "8.0.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging.Configuration": "8.0.0", + "Microsoft.Extensions.Options": "8.0.0", + "System.Text.Json": "8.0.0" + } + }, + "Microsoft.Extensions.Logging.Debug": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "dt0x21qBdudHLW/bjMJpkixv858RRr8eSomgVbU8qljOyfrfDGi1JQvpF9w8S7ziRPtRKisuWaOwFxJM82GxeA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging": "8.0.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.0" + } + }, + "Microsoft.Extensions.Logging.EventLog": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "3X9D3sl7EmOu7vQp5MJrmIJBl5XSdOhZPYXUeFfYa6Nnm9+tok8x3t3IVPLhm7UJtPOU61ohFchw8rNm9tIYOQ==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging": "8.0.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.0", + "Microsoft.Extensions.Options": "8.0.0", + "System.Diagnostics.EventLog": "8.0.0" + } + }, + "Microsoft.Extensions.Logging.EventSource": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "oKcPMrw+luz2DUAKhwFXrmFikZWnyc8l2RKoQwqU3KIZZjcfoJE0zRHAnqATfhRZhtcbjl/QkiY2Xjxp0xu+6w==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging": "8.0.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.0", + "Microsoft.Extensions.Options": "8.0.0", + "Microsoft.Extensions.Primitives": "8.0.0", + "System.Text.Json": "8.0.0" + } + }, + "Microsoft.Extensions.Options": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "JOVOfqpnqlVLUzINQ2fox8evY2SKLYJ3BV8QDe/Jyp21u1T7r45x/R/5QdteURMR5r01GxeJSBBUOCOyaNXA3g==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Primitives": "8.0.0" + } + }, + "Microsoft.Extensions.Options.ConfigurationExtensions": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "0f4DMRqEd50zQh+UyJc+/HiBsZ3vhAQALgdkcQEalSH1L2isdC7Yj54M3cyo5e+BeO5fcBQ7Dxly8XiBBcvRgw==", + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.Configuration.Binder": "8.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Options": "8.0.0", + "Microsoft.Extensions.Primitives": "8.0.0" + } + }, + "Microsoft.Extensions.Primitives": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" + }, + "Nito.AsyncEx.Tasks": { + "type": "Transitive", + "resolved": "5.1.2", + "contentHash": "jEkCfR2/M26OK/U4G7SEN063EU/F4LiVA06TtpZILMdX/quIHCg+wn31Zerl2LC+u1cyFancjTY3cNAr2/89PA==", + "dependencies": { + "Nito.Disposables": "2.2.1" + } + }, + "Nito.Collections.Deque": { + "type": "Transitive", + "resolved": "1.1.1", + "contentHash": "CU0/Iuv5VDynK8I8pDLwkgF0rZhbQoZahtodfL0M3x2gFkpBRApKs8RyMyNlAi1mwExE4gsmqQXk4aFVvW9a4Q==" + }, + "Nito.Disposables": { + "type": "Transitive", + "resolved": "2.2.1", + "contentHash": "6sZ5uynQeAE9dPWBQGKebNmxbY4xsvcc5VplB5WkYEESUS7oy4AwnFp0FhqxTSKm/PaFrFqLrYr696CYN8cugg==", + "dependencies": { + "System.Collections.Immutable": "1.7.1" + } + }, "Polly.Core": { "type": "Transitive", "resolved": "8.3.0", @@ -44,6 +301,118 @@ "type": "Transitive", "resolved": "1.2.0.556", "contentHash": "zvn9Mqs/ox/83cpYPignI8hJEM2A93s2HkHs8HYMOAQW0PkampyoErAiIyKxgTLqbbad29HX/shv/6LGSjPJNQ==" + }, + "System.Collections.Immutable": { + "type": "Transitive", + "resolved": "1.7.1", + "contentHash": "B43Zsz5EfMwyEbnObwRxW5u85fzJma3lrDeGcSAV1qkhSRTNY5uXAByTn9h9ddNdhM+4/YoLc/CI43umjwIl9Q==" + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "c9xLpVz6PL9lp/djOWtk5KPDZq3cSYpmXoJQY524EOtuFl5z9ZtsotpsyrDW40U1DRnQSYvcPKEUV0X//u6gkQ==" + }, + "System.Diagnostics.EventLog": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "fdYxcRjQqTTacKId/2IECojlDSFvp7LP5N78+0z/xH7v/Tuw5ZAxu23Y6PTCRinqyu2ePx+Gn1098NC6jM6d+A==" + }, + "System.Text.Encodings.Web": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ==" + }, + "System.Text.Json": { + "type": "Transitive", + "resolved": "8.0.0", + "contentHash": "OdrZO2WjkiEG6ajEFRABTRCi/wuXQPxeV6g8xvUJqdxMvvuCCEk86zPla8UiIQJz3durtUEbNyY/3lIhS0yZvQ==", + "dependencies": { + "System.Text.Encodings.Web": "8.0.0" + } + }, + "radixdlt.coreapisdk": { + "type": "Project", + "dependencies": { + "JsonSubTypes": "[2.0.1, )", + "Newtonsoft.Json": "[13.0.3, )", + "Polly": "[8.3.0, )" + } + }, + "radixdlt.networkgateway.abstractions": { + "type": "Project", + "dependencies": { + "FluentValidation": "[11.9.0, )", + "Microsoft.Extensions.Hosting": "[8.0.0, )", + "Microsoft.Extensions.Logging.Abstractions": "[8.0.0, )", + "Newtonsoft.Json": "[13.0.3, )", + "Nito.AsyncEx.Coordination": "[5.1.2, )", + "RadixDlt.CoreApiSdk": "[1.7.0-develop, )" + } + }, + "FluentValidation": { + "type": "CentralTransitive", + "requested": "[11.9.0, )", + "resolved": "11.9.0", + "contentHash": "VneVlTvwYDkfHV5av3QrQ0amALgrLX6LV94wlYyEsh0B/klJBW7C8y2eAtj5tOZ3jH6CAVpr4s1ZGgew/QWyig==" + }, + "Microsoft.Extensions.Configuration": { + "type": "CentralTransitive", + "requested": "[6.0.1, )", + "resolved": "8.0.0", + "contentHash": "0J/9YNXTMWSZP2p2+nvl8p71zpSwokZXZuJW+VjdErkegAnFdO1XlqtA62SJtgVYHdKu3uPxJHcMR/r35HwFBA==", + "dependencies": { + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.Primitives": "8.0.0" + } + }, + "Microsoft.Extensions.Hosting": { + "type": "CentralTransitive", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "ItYHpdqVp5/oFLT5QqbopnkKlyFG9EW/9nhM6/yfObeKt6Su0wkBio6AizgRHGNwhJuAtlE5VIjow5JOTrip6w==", + "dependencies": { + "Microsoft.Extensions.Configuration": "8.0.0", + "Microsoft.Extensions.Configuration.Abstractions": "8.0.0", + "Microsoft.Extensions.Configuration.Binder": "8.0.0", + "Microsoft.Extensions.Configuration.CommandLine": "8.0.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "8.0.0", + "Microsoft.Extensions.Configuration.FileExtensions": "8.0.0", + "Microsoft.Extensions.Configuration.Json": "8.0.0", + "Microsoft.Extensions.Configuration.UserSecrets": "8.0.0", + "Microsoft.Extensions.DependencyInjection": "8.0.0", + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0", + "Microsoft.Extensions.Diagnostics": "8.0.0", + "Microsoft.Extensions.FileProviders.Abstractions": "8.0.0", + "Microsoft.Extensions.FileProviders.Physical": "8.0.0", + "Microsoft.Extensions.Hosting.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging": "8.0.0", + "Microsoft.Extensions.Logging.Abstractions": "8.0.0", + "Microsoft.Extensions.Logging.Configuration": "8.0.0", + "Microsoft.Extensions.Logging.Console": "8.0.0", + "Microsoft.Extensions.Logging.Debug": "8.0.0", + "Microsoft.Extensions.Logging.EventLog": "8.0.0", + "Microsoft.Extensions.Logging.EventSource": "8.0.0", + "Microsoft.Extensions.Options": "8.0.0" + } + }, + "Microsoft.Extensions.Logging.Abstractions": { + "type": "CentralTransitive", + "requested": "[8.0.0, )", + "resolved": "8.0.0", + "contentHash": "arDBqTgFCyS0EvRV7O3MZturChstm50OJ0y9bDJvAcmEPJm0FFpFyjU/JLYyStNGGey081DvnQYlncNX5SJJGA==", + "dependencies": { + "Microsoft.Extensions.DependencyInjection.Abstractions": "8.0.0" + } + }, + "Nito.AsyncEx.Coordination": { + "type": "CentralTransitive", + "requested": "[5.1.2, )", + "resolved": "5.1.2", + "contentHash": "QMyUfsaxov//0ZMbOHWr9hJaBFteZd66DV1ay4J5wRODDb8+K/uHC7+3VsOflo6SVw/29mu8OWZp8vMDSuzc0w==", + "dependencies": { + "Nito.AsyncEx.Tasks": "5.1.2", + "Nito.Collections.Deque": "1.1.1" + } } } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs index 321cdddaa..d0598bbc7 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs @@ -633,32 +633,13 @@ private static void HookupHistory(ModelBuilder modelBuilder) .Entity() .HasIndex(e => new { e.EntityId, e.Discriminator, e.FromStateVersion }); - // TODO PP: - // best if we could have it in separate schema/dbcontext. - // it doesn't follow historical browse and might be easily split into separate. - // Same applies to pending transactions. - modelBuilder - .Entity() - .HasDiscriminator(DiscriminatorColumnName) - .HasValue(ResourceType.Fungible) - .HasValue(ResourceType.NonFungible); - - // TODO PP: - // do we need all these indexes? - // what order of fields? entityid, resource or reverse? modelBuilder .Entity() .HasIndex(e => new { e.EntityId, e.ResourceEntityId }) .IsUnique(); modelBuilder - .Entity() - .HasIndex(e => new { e.EntityId, e.ResourceEntityId, e.Balance }) - .HasFilter("discriminator = 'fungible'"); - - modelBuilder - .Entity() - .HasIndex(e => new { e.EntityId, e.ResourceEntityId, e.TotalCount }) - .HasFilter("discriminator = 'non_fungible'"); + .Entity() + .HasIndex(e => new { e.EntityId, e.ResourceEntityId, e.Balance }); } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Extensions.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Extensions.cs index 1a5a8c2ef..6e9615109 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Extensions.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Extensions.cs @@ -90,6 +90,27 @@ public static TVal GetOrAdd(this IDictionary dictionary, return value; } + public static TVal AddOrUpdate(this IDictionary dictionary, TKey key, Func newElementFactory, Action updateFactory) + where TKey : notnull + { + ArgumentNullException.ThrowIfNull(dictionary, nameof(dictionary)); + ArgumentNullException.ThrowIfNull(key, nameof(key)); + ArgumentNullException.ThrowIfNull(newElementFactory, nameof(newElementFactory)); + ArgumentNullException.ThrowIfNull(updateFactory, nameof(updateFactory)); + + if (dictionary.TryGetValue(key, out var existingValue)) + { + updateFactory(existingValue); + return existingValue; + } + + var value = newElementFactory(key); + + dictionary[key] = value; + + return value; + } + public static void AddRange(this IDictionary dictionary, IDictionary other) { ArgumentNullException.ThrowIfNull(dictionary, nameof(dictionary)); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index c168e7e17..7d985d43f 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -1438,40 +1438,31 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, } } - var resourceOwnersToAdd = entityResourceAggregatedVaultsHistoryToAdd - .GroupBy( - x => new { x.EntityId, x.ResourceEntityId }, - (key, group) => new - { - key, - newestEntry = group.MaxBy(x => x.FromStateVersion), - } - ) - .Select( - x => + var resourceOwnersToAdd = new Dictionary<(long EntityId, long ResourceEntityId), ResourceOwners>(); + + foreach (var x in entityResourceAggregatedVaultsHistoryToAdd) + { + TokenAmount balance = x switch + { + EntityFungibleResourceAggregatedVaultsHistory fungibleResourceAggregatedVaultsHistory => + fungibleResourceAggregatedVaultsHistory.Balance, + EntityNonFungibleResourceAggregatedVaultsHistory nonFungibleResourceAggregatedVaultsHistory => + TokenAmount.FromDecimalString(nonFungibleResourceAggregatedVaultsHistory.TotalCount.ToString()), + _ => throw new ArgumentOutOfRangeException(nameof(x), x, null), + }; + + resourceOwnersToAdd.AddOrUpdate( + (x.EntityId, x.ResourceEntityId), + _ => new ResourceOwners { - ResourceOwners result = x.newestEntry switch - { - EntityFungibleResourceAggregatedVaultsHistory fungible => new FungibleResourceOwners - { - Id = sequences.ResourceOwnersSequence++, - EntityId = fungible.EntityId, - ResourceEntityId = fungible.ResourceEntityId, - Balance = fungible.Balance, - }, - EntityNonFungibleResourceAggregatedVaultsHistory nonFungible => new NonFungibleResourceOwners - { - Id = sequences.ResourceOwnersSequence++, - EntityId = nonFungible.EntityId, - ResourceEntityId = nonFungible.ResourceEntityId, - TotalCount = nonFungible.TotalCount, - }, - _ => throw new ArgumentOutOfRangeException(nameof(x.newestEntry), x.newestEntry, null), - }; - - return result; - }) - .ToList(); + Id = sequences.ResourceOwnersSequence++, + EntityId = x.EntityId, + ResourceEntityId = x.ResourceEntityId, + Balance = balance, + }, + existing => existing.Balance = balance + ); + } var resourceEntitySupplyHistoryToAdd = resourceSupplyChanges .GroupBy(x => new { x.ResourceEntityId, x.StateVersion }) @@ -1532,7 +1523,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, rowsInserted += await writeHelper.CopyResourceEntitySupplyHistory(resourceEntitySupplyHistoryToAdd, token); rowsInserted += await writeHelper.CopyNonFungibleDataSchemaHistory(nonFungibleSchemaHistoryToAdd, token); rowsInserted += await writeHelper.CopyKeyValueStoreSchemaHistory(keyValueStoreSchemaHistoryToAdd, token); - rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd, token); + rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd.Select(x => x.Value).ToList(), token); rowsInserted += await entityStateProcessor.SaveEntities(); rowsInserted += await entityMetadataProcessor.SaveEntities(); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs index 8b0a543eb..17881e26e 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs @@ -754,7 +754,7 @@ CREATE TEMP TABLE tmp_resource_owners await using var writer = await _connection.BeginBinaryImportAsync( - "COPY tmp_resource_owners (id, entity_id, resource_entity_id, discriminator, balance, total_count) FROM STDIN (FORMAT BINARY)", + "COPY tmp_resource_owners (id, entity_id, resource_entity_id, balance) FROM STDIN (FORMAT BINARY)", token); foreach (var e in entities) @@ -763,18 +763,7 @@ await _connection.BeginBinaryImportAsync( await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); await writer.WriteAsync(e.ResourceEntityId, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(GetDiscriminator(e.GetType()), "resource_type", token); - - if (e is FungibleResourceOwners fe) - { - await writer.WriteAsync(fe.Balance.GetSubUnitsSafeForPostgres(), NpgsqlDbType.Numeric, token); - await writer.WriteNullAsync(token); - } - else if (e is NonFungibleResourceOwners nfe) - { - await writer.WriteNullAsync(token); - await writer.WriteAsync(nfe.TotalCount, NpgsqlDbType.Bigint, token); - } + await writer.WriteAsync(e.Balance.GetSubUnitsSafeForPostgres(), NpgsqlDbType.Numeric, token); } await writer.CompleteAsync(token); @@ -786,8 +775,7 @@ INSERT INTO resource_owners SELECT * FROM tmp_resource_owners ON CONFLICT (entity_id, resource_entity_id) DO UPDATE SET - balance = EXCLUDED.balance, - total_count = EXCLUDED.total_count;"; + balance = EXCLUDED.balance;"; await copyFromTempTablecommand.ExecuteNonQueryAsync(token); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs index eeb44ec25..a4d27de5c 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs @@ -81,11 +81,15 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations { [DbContext(typeof(MigrationsDbContext))] +<<<<<<<< HEAD:src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs <<<<<<<< HEAD:src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs [Migration("20240812074026_InitialCreate")] ======== [Migration("20240807102112_InitialCreate")] >>>>>>>> b8f1f86c (resource owners feature.):src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240807102112_InitialCreate.Designer.cs +======== + [Migration("20240809135419_InitialCreate")] +>>>>>>>> 86fb9ba2 (pull request cleanup.):src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240809135419_InitialCreate.Designer.cs partial class InitialCreate { /// @@ -1570,6 +1574,11 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("Balance") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("balance"); + b.Property("EntityId") .HasColumnType("bigint") .HasColumnName("entity_id"); @@ -1578,19 +1587,14 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("bigint") .HasColumnName("resource_entity_id"); - b.Property("discriminator") - .HasColumnType("resource_type"); - b.HasKey("Id"); b.HasIndex("EntityId", "ResourceEntityId") .IsUnique(); - b.ToTable("resource_owners"); + b.HasIndex("EntityId", "ResourceEntityId", "Balance"); - b.HasDiscriminator("discriminator"); - - b.UseTphMappingStrategy(); + b.ToTable("resource_owners"); }); modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SchemaEntryAggregateHistory", b => @@ -2649,39 +2653,6 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.Origin); }); - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.FungibleResourceOwners", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners"); - - b.Property("Balance") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("balance"); - - b.HasIndex("EntityId", "ResourceEntityId", "Balance") - .HasFilter("discriminator = 'fungible'"); - - b.ToTable("resource_owners"); - - b.HasDiscriminator().HasValue(ResourceType.Fungible); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleResourceOwners", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners"); - - b.Property("TotalCount") - .HasColumnType("bigint") - .HasColumnName("total_count"); - - b.HasIndex("EntityId", "ResourceEntityId", "TotalCount") - .HasFilter("discriminator = 'non_fungible'"); - - b.ToTable("resource_owners"); - - b.HasDiscriminator().HasValue(ResourceType.NonFungible); - }); - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.JsonStateHistory", b => { b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.StateHistory"); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs index cc8fbbe97..40c06d3d0 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs @@ -762,9 +762,7 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), entity_id = table.Column(type: "bigint", nullable: false), resource_entity_id = table.Column(type: "bigint", nullable: false), - discriminator = table.Column(type: "resource_type", nullable: false), - balance = table.Column(type: "numeric(1000)", precision: 1000, nullable: true), - total_count = table.Column(type: "bigint", nullable: true) + balance = table.Column(type: "numeric(1000)", precision: 1000, nullable: false) }, constraints: table => { @@ -1264,14 +1262,7 @@ protected override void Up(MigrationBuilder migrationBuilder) migrationBuilder.CreateIndex( name: "IX_resource_owners_entity_id_resource_entity_id_balance", table: "resource_owners", - columns: new[] { "entity_id", "resource_entity_id", "balance" }, - filter: "discriminator = 'fungible'"); - - migrationBuilder.CreateIndex( - name: "IX_resource_owners_entity_id_resource_entity_id_total_count", - table: "resource_owners", - columns: new[] { "entity_id", "resource_entity_id", "total_count" }, - filter: "discriminator = 'non_fungible'"); + columns: new[] { "entity_id", "resource_entity_id", "balance" }); migrationBuilder.CreateIndex( name: "IX_schema_entry_aggregate_history_entity_id_from_state_version", diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs index b7283fc30..44bf64799 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs @@ -1560,6 +1560,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + b.Property("Balance") + .HasPrecision(1000) + .HasColumnType("numeric") + .HasColumnName("balance"); + b.Property("EntityId") .HasColumnType("bigint") .HasColumnName("entity_id"); @@ -1568,19 +1573,14 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("bigint") .HasColumnName("resource_entity_id"); - b.Property("discriminator") - .HasColumnType("resource_type"); - b.HasKey("Id"); b.HasIndex("EntityId", "ResourceEntityId") .IsUnique(); - b.ToTable("resource_owners"); - - b.HasDiscriminator("discriminator"); + b.HasIndex("EntityId", "ResourceEntityId", "Balance"); - b.UseTphMappingStrategy(); + b.ToTable("resource_owners"); }); modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SchemaEntryAggregateHistory", b => @@ -2639,39 +2639,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasDiscriminator().HasValue(LedgerTransactionMarkerType.Origin); }); - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.FungibleResourceOwners", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners"); - - b.Property("Balance") - .HasPrecision(1000) - .HasColumnType("numeric") - .HasColumnName("balance"); - - b.HasIndex("EntityId", "ResourceEntityId", "Balance") - .HasFilter("discriminator = 'fungible'"); - - b.ToTable("resource_owners"); - - b.HasDiscriminator().HasValue(ResourceType.Fungible); - }); - - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.NonFungibleResourceOwners", b => - { - b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners"); - - b.Property("TotalCount") - .HasColumnType("bigint") - .HasColumnName("total_count"); - - b.HasIndex("EntityId", "ResourceEntityId", "TotalCount") - .HasFilter("discriminator = 'non_fungible'"); - - b.ToTable("resource_owners"); - - b.HasDiscriminator().HasValue(ResourceType.NonFungible); - }); - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.JsonStateHistory", b => { b.HasBaseType("RadixDlt.NetworkGateway.PostgresIntegration.Models.StateHistory"); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs index 261efb8ef..825523f2a 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs @@ -69,7 +69,7 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Models; [Table("resource_owners")] -internal abstract class ResourceOwners +internal class ResourceOwners { [Key] [Column("id")] @@ -80,16 +80,7 @@ internal abstract class ResourceOwners [Column("resource_entity_id")] public long ResourceEntityId { get; set; } -} -internal class FungibleResourceOwners : ResourceOwners -{ [Column("balance")] public TokenAmount Balance { get; set; } } - -internal class NonFungibleResourceOwners : ResourceOwners -{ - [Column("total_count")] - public long TotalCount { get; set; } -} diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs index a52b8c849..1391db1bb 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs @@ -66,9 +66,10 @@ using Microsoft.EntityFrameworkCore; using RadixDlt.NetworkGateway.Abstractions; using RadixDlt.NetworkGateway.Abstractions.Numerics; +using RadixDlt.NetworkGateway.GatewayApi.Exceptions; using RadixDlt.NetworkGateway.GatewayApi.Services; using RadixDlt.NetworkGateway.PostgresIntegration.Models; -using System; +using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -81,9 +82,7 @@ internal class ExtensionsQuerier : IExtensionsQuerier private readonly ReadOnlyDbContext _dbContext; private readonly IDapperWrapper _dapperWrapper; - private record FungibleResourceOwnersViewModel(EntityAddress EntityAddress, string Balance); - - private record NonFungibleResourceOwnersViewModel(EntityAddress EntityAddress, long TotalCount); + private record ResourceOwnersViewModel(long Id, EntityAddress EntityAddress, string Balance); public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapper) { @@ -93,8 +92,8 @@ public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapp public async Task ResourceOwners( EntityAddress resourceAddress, - int offset, int limit, + GatewayModel.ResourceOwnersCursor? cursor, CancellationToken token = default) { var resourceEntity = await _dbContext @@ -102,35 +101,47 @@ public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapp .AnnotateMetricName() .FirstOrDefaultAsync(e => e.Address == resourceAddress, token); - switch (resourceEntity) + if (resourceEntity == null) { - case GlobalFungibleResourceEntity: - { - var totalCount = await _dbContext.ResourceOwners.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); + throw new EntityNotFoundException(resourceAddress.ToString()); + } - var cd = new CommandDefinition( - commandText: @" + var totalCount = await _dbContext.ResourceOwners.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); + + var cd = new CommandDefinition( + commandText: @" SELECT + ro.id as Id, e.address AS EntityAddress, CAST(ro.balance AS text) AS Balance FROM resource_owners ro INNER JOIN entities e ON ro.entity_id = e.id -WHERE resource_entity_id = @resourceEntityId -ORDER BY ro.balance DESC -LIMIT @limit -OFFSET @offset", - parameters: new - { - resourceEntityId = resourceEntity.Id, - offset = offset, - limit = limit, - }, - cancellationToken: token); - - var fungibleResult = await _dapperWrapper.QueryAsync(_dbContext.Database.GetDbConnection(), cd); - - var casted = fungibleResult +WHERE ro.resource_entity_id = @resourceEntityId + AND (@balanceBoundary is null OR ((ro.balance, ro.id) < (Cast(@balanceBoundary AS numeric(1000,0)), @idBoundary))) +ORDER BY (ro.balance, ro.entity_id) DESC +LIMIT @limit", + parameters: new + { + resourceEntityId = resourceEntity.Id, + balanceBoundary = cursor?.BalanceBoundary, + idBoundary = cursor?.IdBoundary ?? long.MaxValue, + limit = limit, + }, + cancellationToken: token); + + var result = (await _dapperWrapper.QueryAsync(_dbContext.Database.GetDbConnection(), cd)).ToList(); + + var lastElement = result.LastOrDefault(); + var nextCursor = lastElement != null + ? new GatewayModel.ResourceOwnersCursor(lastElement.Id, TokenAmount.FromDecimalString(lastElement.Balance).ToString()).ToCursorString() + : null; + + switch (resourceEntity) + { + case GlobalFungibleResourceEntity: + { + var castedResult = result .Select( x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionFungibleResourceItem( amount: TokenAmount.FromSubUnitsString(x.Balance).ToString(), @@ -138,48 +149,24 @@ LIMIT @limit ) .ToList(); - var nextCursor = CursorGenerator.GenerateOffsetCursor(offset, limit, totalCount); - return new GatewayModel.ResourceOwnersResponse(new GatewayModel.ResourceOwnersCollection(totalCount, nextCursor, casted)); + return new GatewayModel.ResourceOwnersResponse(new GatewayModel.ResourceOwnersCollection(totalCount, nextCursor, castedResult)); } case GlobalNonFungibleResourceEntity: { - var totalCount = await _dbContext.ResourceOwners.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); - - var cd = new CommandDefinition( - commandText: @" -SELECT - e.address AS EntityAddress, - ro.total_count as TotalCount -FROM resource_owners ro -INNER JOIN entities e -ON ro.entity_id = e.id -WHERE resource_entity_id = @resourceEntityId -ORDER BY total_count DESC -LIMIT @limit -OFFSET @offset", - parameters: new - { - resourceEntityId = resourceEntity.Id, - offset = offset, - limit = limit, - }, - cancellationToken: token); - - var nonFungibleResult = (await _dapperWrapper.QueryAsync(_dbContext.Database.GetDbConnection(), cd)) + var castedResult = result .Select( x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionNonFungibleResourceItem( - nonFungibleIdsCount: x.TotalCount, + nonFungibleIdsCount: long.Parse(TokenAmount.FromSubUnitsString(x.Balance).ToString()), ownerAddress: x.EntityAddress) ) .ToList(); - var nextCursor = CursorGenerator.GenerateOffsetCursor(offset, limit, totalCount); - return new GatewayModel.ResourceOwnersResponse(new GatewayModel.ResourceOwnersCollection(totalCount, nextCursor, nonFungibleResult)); + return new GatewayModel.ResourceOwnersResponse(new GatewayModel.ResourceOwnersCollection(totalCount, nextCursor, castedResult)); } default: - throw new ArgumentOutOfRangeException(nameof(resourceEntity), resourceEntity, null); + throw new UnreachableException($"Either fungible or non fungible resource expected. But {resourceEntity.GetType()} found."); } } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/packages.lock.json b/src/RadixDlt.NetworkGateway.PostgresIntegration/packages.lock.json index 1898846f4..c11a83007 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/packages.lock.json +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/packages.lock.json @@ -669,7 +669,8 @@ "dependencies": { "JsonSubTypes": "[2.0.1, )", "Newtonsoft.Json": "[13.0.3, )", - "Polly": "[8.3.0, )" + "Polly": "[8.3.0, )", + "RadixDlt.NetworkGateway.Abstractions": "[1.7.0-develop, )" } }, "FluentValidation": { diff --git a/src/RadixDlt.NetworkGateway.PrometheusIntegration/packages.lock.json b/src/RadixDlt.NetworkGateway.PrometheusIntegration/packages.lock.json index 26a7b2699..dd3decce4 100644 --- a/src/RadixDlt.NetworkGateway.PrometheusIntegration/packages.lock.json +++ b/src/RadixDlt.NetworkGateway.PrometheusIntegration/packages.lock.json @@ -391,7 +391,8 @@ "dependencies": { "JsonSubTypes": "[2.0.1, )", "Newtonsoft.Json": "[13.0.3, )", - "Polly": "[8.3.0, )" + "Polly": "[8.3.0, )", + "RadixDlt.NetworkGateway.Abstractions": "[1.7.0-develop, )" } }, "FluentValidation": { diff --git a/tests/RadixDlt.NetworkGateway.UnitTests/packages.lock.json b/tests/RadixDlt.NetworkGateway.UnitTests/packages.lock.json index c3a0e9e3a..303bcf003 100644 --- a/tests/RadixDlt.NetworkGateway.UnitTests/packages.lock.json +++ b/tests/RadixDlt.NetworkGateway.UnitTests/packages.lock.json @@ -727,7 +727,8 @@ "dependencies": { "JsonSubTypes": "[2.0.1, )", "Newtonsoft.Json": "[13.0.3, )", - "Polly": "[8.3.0, )" + "Polly": "[8.3.0, )", + "RadixDlt.NetworkGateway.Abstractions": "[1.7.0-develop, )" } }, "radixdlt.networkgateway.postgresintegration": { From ddb73b2dbd767c1aa6d885599503c3016557cb39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Tue, 13 Aug 2024 11:00:56 +0200 Subject: [PATCH 08/18] fix migration. --- ... 20240813085815_InitialCreate.Designer.cs} | 12 +- ...ate.cs => 20240813085815_InitialCreate.cs} | 0 .../Migrations/IdempotentApplyMigrations.sql | 263 ++++++++++-------- .../MigrationsDbContextModelSnapshot.cs | 5 +- 4 files changed, 151 insertions(+), 129 deletions(-) rename src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/{20240812074026_InitialCreate.Designer.cs => 20240813085815_InitialCreate.Designer.cs} (99%) rename src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/{20240812074026_InitialCreate.cs => 20240813085815_InitialCreate.cs} (100%) diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.Designer.cs similarity index 99% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.Designer.cs index a4d27de5c..8864687c5 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.Designer.cs @@ -62,7 +62,7 @@ * permissions under this License. */ -// +// using System; using System.Collections.Generic; using System.Numerics; @@ -81,15 +81,7 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations { [DbContext(typeof(MigrationsDbContext))] -<<<<<<<< HEAD:src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs -<<<<<<<< HEAD:src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.Designer.cs - [Migration("20240812074026_InitialCreate")] -======== - [Migration("20240807102112_InitialCreate")] ->>>>>>>> b8f1f86c (resource owners feature.):src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240807102112_InitialCreate.Designer.cs -======== - [Migration("20240809135419_InitialCreate")] ->>>>>>>> 86fb9ba2 (pull request cleanup.):src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240809135419_InitialCreate.Designer.cs + [Migration("20240813085815_InitialCreate")] partial class InitialCreate { /// diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.cs similarity index 100% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240812074026_InitialCreate.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.cs diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql index 6b617af47..1b597a064 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql @@ -9,7 +9,7 @@ START TRANSACTION; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TYPE account_default_deposit_rule AS ENUM ('accept', 'reject', 'allow_existing'); CREATE TYPE account_resource_preference_rule AS ENUM ('allowed', 'disallowed'); CREATE TYPE authorized_depositor_badge_type AS ENUM ('resource', 'non_fungible'); @@ -37,7 +37,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE account_authorized_depositor_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -50,7 +50,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE account_authorized_depositor_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -66,7 +66,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE account_default_deposit_rule_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -79,7 +79,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE account_locker_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -93,7 +93,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE account_locker_entry_resource_vault_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -107,7 +107,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE account_locker_entry_touch_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -119,7 +119,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE account_resource_preference_rule_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -132,7 +132,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE account_resource_preference_rule_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -147,7 +147,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE component_method_royalty_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -160,7 +160,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE component_method_royalty_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -175,7 +175,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entities ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -201,7 +201,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_metadata_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -214,7 +214,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_metadata_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -230,7 +230,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_resource_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -246,7 +246,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_resource_aggregated_vaults_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -262,7 +262,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_resource_vault_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -276,7 +276,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_role_assignments_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -290,7 +290,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_role_assignments_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -306,7 +306,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_role_assignments_owner_role_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -319,7 +319,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE entity_vault_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -338,7 +338,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE key_value_store_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -351,7 +351,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE key_value_store_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -366,7 +366,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE key_value_store_schema_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -386,7 +386,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE ledger_transaction_markers ( id bigint GENERATED BY DEFAULT AS IDENTITY, state_version bigint NOT NULL, @@ -406,7 +406,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE ledger_transactions ( state_version bigint NOT NULL, epoch bigint NOT NULL, @@ -454,7 +454,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE non_fungible_id_data_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -469,7 +469,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE non_fungible_id_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -482,7 +482,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE non_fungible_id_location_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -495,7 +495,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE non_fungible_schema_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -511,7 +511,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE package_blueprint_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -524,7 +524,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE package_blueprint_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -544,7 +544,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE package_code_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -557,7 +557,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE package_code_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -573,7 +573,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE pending_transactions ( id bigint GENERATED BY DEFAULT AS IDENTITY, payload_hash text NOT NULL, @@ -601,7 +601,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE resource_entity_supply_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -616,7 +616,20 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + CREATE TABLE resource_owners ( + id bigint GENERATED BY DEFAULT AS IDENTITY, + entity_id bigint NOT NULL, + resource_entity_id bigint NOT NULL, + balance numeric(1000) NOT NULL, + CONSTRAINT "PK_resource_owners" PRIMARY KEY (id) + ); + END IF; +END $EF$; + +DO $EF$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE schema_entry_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -629,7 +642,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE schema_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -643,7 +656,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE state_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -662,7 +675,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE unverified_standard_metadata_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -675,7 +688,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE unverified_standard_metadata_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -692,7 +705,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE validator_cumulative_emission_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -708,7 +721,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE validator_public_key_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -722,7 +735,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE pending_transaction_payloads ( id bigint GENERATED BY DEFAULT AS IDENTITY, pending_transaction_id bigint, @@ -735,7 +748,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE TABLE validator_active_set_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -750,506 +763,520 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_aggregate_history_account_enti~" ON account_authorized_depositor_aggregate_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_~1" ON account_authorized_depositor_entry_history (account_entity_id, resource_entity_id, non_fungible_id, from_state_version) WHERE discriminator = 'non_fungible'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_~2" ON account_authorized_depositor_entry_history (account_entity_id, resource_entity_id, from_state_version) WHERE discriminator = 'resource'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_i~" ON account_authorized_depositor_entry_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_account_default_deposit_rule_history_account_entity_id_from~" ON account_default_deposit_rule_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE UNIQUE INDEX "IX_account_locker_entry_definition_account_locker_entity_id_ac~" ON account_locker_entry_definition (account_locker_entity_id, account_entity_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE UNIQUE INDEX "IX_account_locker_entry_resource_vault_definition_account_lock~" ON account_locker_entry_resource_vault_definition (account_locker_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_account_locker_entry_touch_history_account_locker_definitio~" ON account_locker_entry_touch_history (account_locker_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_account_resource_preference_rule_aggregate_history_account_~" ON account_resource_preference_rule_aggregate_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_account_resource_preference_rule_entry_history_account_enti~" ON account_resource_preference_rule_entry_history (account_entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_aggregate_history_entity_id_from_s~" ON component_method_royalty_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_entry_history_entity_id_from_state~" ON component_method_royalty_entry_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_entry_history_entity_id_method_nam~" ON component_method_royalty_entry_history (entity_id, method_name, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE UNIQUE INDEX "IX_entities_address" ON entities (address); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entities_from_state_version" ON entities (from_state_version) WHERE discriminator = 'global_validator'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_metadata_aggregate_history_entity_id_from_state_vers~" ON entity_metadata_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_metadata_history_entity_id_key_from_state_version" ON entity_metadata_history (entity_id, key, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_resource_aggregate_history_entity_id_from_state_vers~" ON entity_resource_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_resource_aggregated_vaults_history_entity_id_resourc~" ON entity_resource_aggregated_vaults_history (entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_resource_vault_aggregate_history_entity_id_resource_~" ON entity_resource_vault_aggregate_history (entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_aggregate_history_entity_id_from_st~" ON entity_role_assignments_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_entry_history_entity_id_key_role_ke~" ON entity_role_assignments_entry_history (entity_id, key_role, key_module, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_owner_role_history_entity_id_from_s~" ON entity_role_assignments_owner_role_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_global_entity_id_from_state_version" ON entity_vault_history (global_entity_id, from_state_version) WHERE is_royalty_vault = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_global_entity_id_vault_entity_id_from_~" ON entity_vault_history (global_entity_id, vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_id_resource_entity_id_from_state_versi~" ON entity_vault_history (id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_owner_entity_id_from_state_version" ON entity_vault_history (owner_entity_id, from_state_version) WHERE is_royalty_vault = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_owner_entity_id_vault_entity_id_from_s~" ON entity_vault_history (owner_entity_id, vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_vault_entity_id_from_state_version" ON entity_vault_history (vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_definition_key_value_store_entity_id_~" ON key_value_store_entry_definition (key_value_store_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_definition_key_value_store_entity_id~1" ON key_value_store_entry_definition (key_value_store_entity_id, key); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_history_key_value_store_entry_definit~" ON key_value_store_entry_history (key_value_store_entry_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_key_value_store_schema_history_key_value_store_entity_id_fr~" ON key_value_store_schema_history (key_value_store_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_entity_id_state_version" ON ledger_transaction_markers (entity_id, state_version) WHERE discriminator = 'event_global_emitter'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_entity_id_state_version1" ON ledger_transaction_markers (entity_id, state_version) WHERE discriminator = 'affected_global_entity'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_event_type_entity_id_state_versi~" ON ledger_transaction_markers (event_type, entity_id, state_version) WHERE discriminator = 'event'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_manifest_class" ON ledger_transaction_markers (manifest_class, state_version) WHERE discriminator = 'manifest_class'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_manifest_class_is_most_specific" ON ledger_transaction_markers (manifest_class, state_version) WHERE discriminator = 'manifest_class' and is_most_specific = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_operation_type_entity_id_state_v~" ON ledger_transaction_markers (operation_type, entity_id, state_version) WHERE discriminator = 'manifest_address'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_origin_type_state_version" ON ledger_transaction_markers (origin_type, state_version) WHERE discriminator = 'origin'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_state_version" ON ledger_transaction_markers (state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE UNIQUE INDEX "IX_ledger_transactions_epoch_round_in_epoch" ON ledger_transactions (epoch, round_in_epoch) WHERE index_in_round = 0; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transactions_intent_hash" ON ledger_transactions USING hash (intent_hash) WHERE intent_hash IS NOT NULL; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_ledger_transactions_round_timestamp" ON ledger_transactions (round_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_data_history_non_fungible_id_definition_id_~" ON non_fungible_id_data_history (non_fungible_id_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_definition_non_fungible_resource_entity_id_~" ON non_fungible_id_definition (non_fungible_resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE UNIQUE INDEX "IX_non_fungible_id_definition_non_fungible_resource_entity_id~1" ON non_fungible_id_definition (non_fungible_resource_entity_id, non_fungible_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_location_history_non_fungible_id_definition~" ON non_fungible_id_location_history (non_fungible_id_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_non_fungible_schema_history_resource_entity_id_from_state_v~" ON non_fungible_schema_history (resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_aggregate_history_package_entity_id_from_~" ON package_blueprint_aggregate_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_history_package_entity_id_from_state_vers~" ON package_blueprint_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_history_package_entity_id_name_version_fr~" ON package_blueprint_history (package_entity_id, name, version, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_package_code_aggregate_history_package_entity_id_from_state~" ON package_code_aggregate_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_package_code_history_package_entity_id_from_state_version" ON package_code_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE UNIQUE INDEX "IX_pending_transaction_payloads_pending_transaction_id" ON pending_transaction_payloads (pending_transaction_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_first_submitted_to_gateway_timestamp" ON pending_transactions (first_submitted_to_gateway_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_intent_hash" ON pending_transactions (intent_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE UNIQUE INDEX "IX_pending_transactions_payload_hash" ON pending_transactions (payload_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_resubmit_from_timestamp" ON pending_transactions (resubmit_from_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_resource_entity_supply_history_resource_entity_id_from_stat~" ON resource_entity_supply_history (resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + CREATE UNIQUE INDEX "IX_resource_owners_entity_id_resource_entity_id" ON resource_owners (entity_id, resource_entity_id); + END IF; +END $EF$; + +DO $EF$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + CREATE INDEX "IX_resource_owners_entity_id_resource_entity_id_balance" ON resource_owners (entity_id, resource_entity_id, balance); + END IF; +END $EF$; + +DO $EF$ +BEGIN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_schema_entry_aggregate_history_entity_id_from_state_version" ON schema_entry_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_schema_entry_definition_entity_id_schema_hash" ON schema_entry_definition (entity_id, schema_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_state_history_entity_id_from_state_version" ON state_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_unverified_standard_metadata_aggregate_history_entity_id_fr~" ON unverified_standard_metadata_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_unverified_standard_metadata_entry_history_entity_id_discri~" ON unverified_standard_metadata_entry_history (entity_id, discriminator, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_epoch" ON validator_active_set_history (epoch); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_from_state_version" ON validator_active_set_history (from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_validator_public_key_history_id" ON validator_active_set_history (validator_public_key_history_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_validator_cumulative_emission_history_validator_entity_id_e~" ON validator_cumulative_emission_history (validator_entity_id, epoch_number); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_validator_public_key_history_validator_entity_id_from_state~" ON validator_public_key_history (validator_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN CREATE INDEX "IX_validator_public_key_history_validator_entity_id_key_type_k~" ON validator_public_key_history (validator_entity_id, key_type, key); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240812074026_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") - VALUES ('20240812074026_InitialCreate', '8.0.2'); + VALUES ('20240813085815_InitialCreate', '8.0.2'); END IF; END $EF$; COMMIT; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs index 44bf64799..5517a79ad 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs @@ -62,14 +62,17 @@ * 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.Model; using RadixDlt.NetworkGateway.Abstractions.StandardMetadata; +using RadixDlt.NetworkGateway.PostgresIntegration; using RadixDlt.NetworkGateway.PostgresIntegration.Models; #nullable disable From bf730e14af6d4a6444db06d813b3b9498b86e81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Tue, 13 Aug 2024 14:33:41 +0200 Subject: [PATCH 09/18] handle scenario when component no longer owns resource, it will not be returned from endpoint. --- .../PostgresLedgerExtenderService.cs | 53 ++++++++--- .../LedgerExtension/Records.cs | 12 +++ .../LedgerExtension/WriteHelper.cs | 89 ++++++++++++++----- 3 files changed, 120 insertions(+), 34 deletions(-) diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index 7d985d43f..7dc0113d2 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -1438,7 +1438,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, } } - var resourceOwnersToAdd = new Dictionary<(long EntityId, long ResourceEntityId), ResourceOwners>(); + var resourceOwnersToAdd = new Dictionary(); foreach (var x in entityResourceAggregatedVaultsHistoryToAdd) { @@ -1451,17 +1451,50 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, _ => throw new ArgumentOutOfRangeException(nameof(x), x, null), }; + var isDeleted = balance.IsZero(); + resourceOwnersToAdd.AddOrUpdate( - (x.EntityId, x.ResourceEntityId), - _ => new ResourceOwners + new ResourceOwnersLookup(x.EntityId, x.ResourceEntityId), + _ => { - Id = sequences.ResourceOwnersSequence++, - EntityId = x.EntityId, - ResourceEntityId = x.ResourceEntityId, - Balance = balance, + if (isDeleted) + { + return new ResourceOwnersChange(IsDeleted: true, null); + } + + return new ResourceOwnersChange(IsDeleted: false, new ResourceOwners + { + Id = sequences.ResourceOwnersSequence++, + EntityId = x.EntityId, + ResourceEntityId = x.ResourceEntityId, + Balance = balance, + }); }, - existing => existing.Balance = balance - ); + existing => + { + if (isDeleted) + { + existing.IsDeleted = true; + existing.Entry = null; + return; + } + + existing.IsDeleted = false; + + if (existing.Entry != null) + { + existing.Entry.Balance = balance; + return; + } + + existing.Entry = new ResourceOwners + { + Id = sequences.ResourceOwnersSequence++, + EntityId = x.EntityId, + ResourceEntityId = x.ResourceEntityId, + Balance = balance, + }; + }); } var resourceEntitySupplyHistoryToAdd = resourceSupplyChanges @@ -1523,7 +1556,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, rowsInserted += await writeHelper.CopyResourceEntitySupplyHistory(resourceEntitySupplyHistoryToAdd, token); rowsInserted += await writeHelper.CopyNonFungibleDataSchemaHistory(nonFungibleSchemaHistoryToAdd, token); rowsInserted += await writeHelper.CopyKeyValueStoreSchemaHistory(keyValueStoreSchemaHistoryToAdd, token); - rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd.Select(x => x.Value).ToList(), token); + rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd, token); rowsInserted += await entityStateProcessor.SaveEntities(); rowsInserted += await entityMetadataProcessor.SaveEntities(); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs index ef8f005b8..039749388 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs @@ -63,6 +63,8 @@ */ using RadixDlt.NetworkGateway.Abstractions.Numerics; +using RadixDlt.NetworkGateway.PostgresIntegration.Models; +using System.Diagnostics.CodeAnalysis; namespace RadixDlt.NetworkGateway.PostgresIntegration.LedgerExtension; @@ -105,3 +107,13 @@ internal record struct EntityResourceVaultLookup(long EntityId, long ResourceEnt internal record struct NonFungibleStoreLookup(long NonFungibleEntityId, long StateVersion); internal record struct NonFungibleIdLookup(long ResourceEntityId, string NonFungibleId); + +internal record ResourceOwnersChange(bool IsDeleted, ResourceOwners? Entry) +{ + public bool IsDeleted { get; set; } = IsDeleted; + + [MemberNotNullWhen(true, nameof(IsDeleted))] + public ResourceOwners? Entry { get; set; } = Entry; +} + +internal record ResourceOwnersLookup(long EntityId, long ResourceEntityId); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs index 17881e26e..ec86eec6d 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs @@ -735,53 +735,94 @@ await _connection.BeginBinaryImportAsync( return entities.Count; } - public async Task CopyResourceOwners(ICollection entities, CancellationToken token) + public async Task CopyResourceOwners(Dictionary changes, CancellationToken token) { - if (!entities.Any()) + var entitiesToAdd = changes + .Where(x => !x.Value.IsDeleted) + .Select(x => x.Value.Entry!) + .ToList(); + + var entriesToRemove = changes + .Where(x => x.Value.IsDeleted) + .Select(x => x.Key) + .ToList(); + + if (!entitiesToAdd.Any() && !entriesToRemove.Any()) { return 0; } + var changesCount = entitiesToAdd.Count + entriesToRemove.Count; + var sw = Stopwatch.GetTimestamp(); - await using var createTempTableCommand = _connection.CreateCommand(); - createTempTableCommand.CommandText = @" + if (entitiesToAdd.Any()) + { + await using var createTempTableCommand = _connection.CreateCommand(); + createTempTableCommand.CommandText = @" CREATE TEMP TABLE tmp_resource_owners (LIKE resource_owners INCLUDING DEFAULTS) ON COMMIT DROP"; - await createTempTableCommand.ExecuteNonQueryAsync(token); + await createTempTableCommand.ExecuteNonQueryAsync(token); - await using var writer = - await _connection.BeginBinaryImportAsync( - "COPY tmp_resource_owners (id, entity_id, resource_entity_id, balance) FROM STDIN (FORMAT BINARY)", - token); + await using var writer = + await _connection.BeginBinaryImportAsync( + "COPY tmp_resource_owners (id, entity_id, resource_entity_id, balance) FROM STDIN (FORMAT BINARY)", + token); - foreach (var e in entities) - { - await writer.StartRowAsync(token); - await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(e.ResourceEntityId, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(e.Balance.GetSubUnitsSafeForPostgres(), NpgsqlDbType.Numeric, token); - } + foreach (var e in entitiesToAdd) + { + await writer.StartRowAsync(token); + await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.ResourceEntityId, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.Balance.GetSubUnitsSafeForPostgres(), NpgsqlDbType.Numeric, token); + } - await writer.CompleteAsync(token); - await writer.DisposeAsync(); + await writer.CompleteAsync(token); + await writer.DisposeAsync(); - await using var copyFromTempTablecommand = _connection.CreateCommand(); - copyFromTempTablecommand.CommandText = @" + await using var copyFromTempTablecommand = _connection.CreateCommand(); + copyFromTempTablecommand.CommandText = @" INSERT INTO resource_owners SELECT * FROM tmp_resource_owners ON CONFLICT (entity_id, resource_entity_id) DO UPDATE SET balance = EXCLUDED.balance;"; - await copyFromTempTablecommand.ExecuteNonQueryAsync(token); + await copyFromTempTablecommand.ExecuteNonQueryAsync(token); + } + + if (entriesToRemove.Any()) + { + entriesToRemove + .ToHashSet() + .Unzip( + x => x.ResourceEntityId, + x => x.EntityId, + out var resourceEntityIds, + out var entityIds); - await _observers.ForEachAsync(x => x.StageCompleted(nameof(CopyResourceOwners), Stopwatch.GetElapsedTime(sw), entities.Count)); + var deleteEntriesCommand = new CommandDefinition( + commandText: @" +WITH variables (resource_entity_id, entity_id) AS ( + SELECT UNNEST(@resourceEntityIds), UNNEST(@entityIds) +) +DELETE FROM resource_owners WHERE (resource_entity_id, entity_id) IN (SELECT resource_entity_id, entity_id FROM variables)", + parameters: new + { + resourceEntityIds = resourceEntityIds, + entityIds = entityIds, + }, + cancellationToken: token); - return entities.Count; + await _connection.ExecuteAsync(deleteEntriesCommand); + } + + await _observers.ForEachAsync(x => x.StageCompleted(nameof(CopyResourceOwners), Stopwatch.GetElapsedTime(sw), changesCount)); + + return changesCount; } public async Task UpdateSequences(SequencesHolder sequences, CancellationToken token) From a1fb03dce7f924626eec869e660d44c9f45a042d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Tue, 13 Aug 2024 14:45:39 +0200 Subject: [PATCH 10/18] return resource owners directly in response. --- .../gateway-api-schema.yaml | 8 +- .../generated/Api/ExtensionsApi.cs | 16 +- .../generated/Model/ResourceOwnersResponse.cs | 69 +++++-- .../Model/ResourceOwnersResponseAllOf.cs | 193 ------------------ .../StateKeyValueStoreDataRequestKeyItem.cs | 2 +- .../Services/ExtensionsQuerier.cs | 9 +- 6 files changed, 72 insertions(+), 225 deletions(-) delete mode 100644 src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index f693fb730..45519997c 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -4993,12 +4993,8 @@ components: ResourceOwnersResponse: allOf: - - type: object - required: - - owners - properties: - owners: - $ref: "#/components/schemas/ResourceOwnersCollection" + - $ref: "#/components/schemas/ResourceOwnersCollection" + # # Errors diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs index 8a8b2b5af..18c1e1bfe 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs @@ -95,7 +95,7 @@ public interface IExtensionsApiSync : IApiAccessor /// Get Resource Owners Page /// /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -106,7 +106,7 @@ public interface IExtensionsApiSync : IApiAccessor /// Get Resource Owners Page /// /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -125,7 +125,7 @@ public interface IExtensionsApiAsync : IApiAccessor /// Get Resource Owners Page /// /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -137,7 +137,7 @@ public interface IExtensionsApiAsync : IApiAccessor /// Get Resource Owners Page /// /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -358,7 +358,7 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ExceptionFactory ExceptionFa } /// - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -370,7 +370,7 @@ public ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceO } /// - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -414,7 +414,7 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -427,7 +427,7 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number Of Items (non fungibles) descending. + /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs index aa6cc10d5..59957ff35 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs @@ -103,22 +103,40 @@ protected ResourceOwnersResponse() { } /// /// Initializes a new instance of the class. /// - /// owners (required). - public ResourceOwnersResponse(ResourceOwnersCollection owners = default(ResourceOwnersCollection)) + /// 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 ResourceOwnersResponse(long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) { - // to ensure "owners" is required (not null) - if (owners == null) + // to ensure "items" is required (not null) + if (items == null) { - throw new ArgumentNullException("owners is a required property for ResourceOwnersResponse and cannot be null"); + throw new ArgumentNullException("items is a required property for ResourceOwnersResponse and cannot be null"); } - this.Owners = owners; + this.Items = items; + this.TotalCount = totalCount; + this.NextCursor = nextCursor; } /// - /// Gets or Sets Owners + /// Total number of items in underlying collection, fragment of which is available in `items` collection. /// - [DataMember(Name = "owners", IsRequired = true, EmitDefaultValue = true)] - public ResourceOwnersCollection Owners { get; set; } + /// 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 + /// + [DataMember(Name = "items", IsRequired = true, EmitDefaultValue = true)] + public List Items { get; set; } /// /// Returns the string presentation of the object @@ -128,7 +146,9 @@ public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append("class ResourceOwnersResponse {\n"); - sb.Append(" Owners: ").Append(Owners).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"); return sb.ToString(); } @@ -165,9 +185,20 @@ public bool Equals(ResourceOwnersResponse input) } return ( - this.Owners == input.Owners || - (this.Owners != null && - this.Owners.Equals(input.Owners)) + 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 && + input.Items != null && + this.Items.SequenceEqual(input.Items) ); } @@ -180,9 +211,17 @@ public override int GetHashCode() unchecked // Overflow is fine, just wrap { int hashCode = 41; - if (this.Owners != null) + 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.Owners.GetHashCode(); + hashCode = (hashCode * 59) + this.Items.GetHashCode(); } return hashCode; } diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs deleted file mode 100644 index 7f4d24057..000000000 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponseAllOf.cs +++ /dev/null @@ -1,193 +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.7.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 -{ - /// - /// ResourceOwnersResponseAllOf - /// - [DataContract(Name = "ResourceOwnersResponse_allOf")] - public partial class ResourceOwnersResponseAllOf : IEquatable - { - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected ResourceOwnersResponseAllOf() { } - /// - /// Initializes a new instance of the class. - /// - /// owners (required). - public ResourceOwnersResponseAllOf(ResourceOwnersCollection owners = default(ResourceOwnersCollection)) - { - // to ensure "owners" is required (not null) - if (owners == null) - { - throw new ArgumentNullException("owners is a required property for ResourceOwnersResponseAllOf and cannot be null"); - } - this.Owners = owners; - } - - /// - /// Gets or Sets Owners - /// - [DataMember(Name = "owners", IsRequired = true, EmitDefaultValue = true)] - public ResourceOwnersCollection Owners { 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 ResourceOwnersResponseAllOf {\n"); - sb.Append(" Owners: ").Append(Owners).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 ResourceOwnersResponseAllOf); - } - - /// - /// Returns true if ResourceOwnersResponseAllOf instances are equal - /// - /// Instance of ResourceOwnersResponseAllOf to be compared - /// Boolean - public bool Equals(ResourceOwnersResponseAllOf input) - { - if (input == null) - { - return false; - } - return - ( - this.Owners == input.Owners || - (this.Owners != null && - this.Owners.Equals(input.Owners)) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Owners != null) - { - hashCode = (hashCode * 59) + this.Owners.GetHashCode(); - } - return hashCode; - } - } - - } - -} diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs index ddaef8d13..f3cb26cf2 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/StateKeyValueStoreDataRequestKeyItem.cs @@ -90,7 +90,7 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// Provide either `key_hex` or `key_json`. If both are provided, `key_hex` is used and `key_json` is ignored. + /// Provide either `key_hex` or `key_json`. If both are provided, `key_hex` is used and `key_json` is ignored. /// [DataContract(Name = "StateKeyValueStoreDataRequestKeyItem")] public partial class StateKeyValueStoreDataRequestKeyItem : IEquatable diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs index 1391db1bb..3636de33d 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs @@ -106,6 +106,11 @@ public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapp throw new EntityNotFoundException(resourceAddress.ToString()); } + if (!resourceEntity.Address.IsResource) + { + throw new InvalidEntityException(resourceEntity.Address.ToString()); + } + var totalCount = await _dbContext.ResourceOwners.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); var cd = new CommandDefinition( @@ -149,7 +154,7 @@ ORDER BY (ro.balance, ro.entity_id) DESC ) .ToList(); - return new GatewayModel.ResourceOwnersResponse(new GatewayModel.ResourceOwnersCollection(totalCount, nextCursor, castedResult)); + return new GatewayModel.ResourceOwnersResponse(totalCount, nextCursor, castedResult); } case GlobalNonFungibleResourceEntity: @@ -162,7 +167,7 @@ ORDER BY (ro.balance, ro.entity_id) DESC ) .ToList(); - return new GatewayModel.ResourceOwnersResponse(new GatewayModel.ResourceOwnersCollection(totalCount, nextCursor, castedResult)); + return new GatewayModel.ResourceOwnersResponse(totalCount, nextCursor, castedResult); } default: From d6888ba07f3925ebdee86501086c452166ac5d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Wed, 14 Aug 2024 10:43:59 +0200 Subject: [PATCH 11/18] handle 0 balanace in sql merge command. --- .../PostgresLedgerExtenderService.cs | 53 ++-------- .../LedgerExtension/Records.cs | 12 --- .../LedgerExtension/WriteHelper.cs | 98 ++++++------------- 3 files changed, 39 insertions(+), 124 deletions(-) diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index 7dc0113d2..7d985d43f 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -1438,7 +1438,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, } } - var resourceOwnersToAdd = new Dictionary(); + var resourceOwnersToAdd = new Dictionary<(long EntityId, long ResourceEntityId), ResourceOwners>(); foreach (var x in entityResourceAggregatedVaultsHistoryToAdd) { @@ -1451,50 +1451,17 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, _ => throw new ArgumentOutOfRangeException(nameof(x), x, null), }; - var isDeleted = balance.IsZero(); - resourceOwnersToAdd.AddOrUpdate( - new ResourceOwnersLookup(x.EntityId, x.ResourceEntityId), - _ => + (x.EntityId, x.ResourceEntityId), + _ => new ResourceOwners { - if (isDeleted) - { - return new ResourceOwnersChange(IsDeleted: true, null); - } - - return new ResourceOwnersChange(IsDeleted: false, new ResourceOwners - { - Id = sequences.ResourceOwnersSequence++, - EntityId = x.EntityId, - ResourceEntityId = x.ResourceEntityId, - Balance = balance, - }); + Id = sequences.ResourceOwnersSequence++, + EntityId = x.EntityId, + ResourceEntityId = x.ResourceEntityId, + Balance = balance, }, - existing => - { - if (isDeleted) - { - existing.IsDeleted = true; - existing.Entry = null; - return; - } - - existing.IsDeleted = false; - - if (existing.Entry != null) - { - existing.Entry.Balance = balance; - return; - } - - existing.Entry = new ResourceOwners - { - Id = sequences.ResourceOwnersSequence++, - EntityId = x.EntityId, - ResourceEntityId = x.ResourceEntityId, - Balance = balance, - }; - }); + existing => existing.Balance = balance + ); } var resourceEntitySupplyHistoryToAdd = resourceSupplyChanges @@ -1556,7 +1523,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, rowsInserted += await writeHelper.CopyResourceEntitySupplyHistory(resourceEntitySupplyHistoryToAdd, token); rowsInserted += await writeHelper.CopyNonFungibleDataSchemaHistory(nonFungibleSchemaHistoryToAdd, token); rowsInserted += await writeHelper.CopyKeyValueStoreSchemaHistory(keyValueStoreSchemaHistoryToAdd, token); - rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd, token); + rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd.Select(x => x.Value).ToList(), token); rowsInserted += await entityStateProcessor.SaveEntities(); rowsInserted += await entityMetadataProcessor.SaveEntities(); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs index 039749388..ef8f005b8 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs @@ -63,8 +63,6 @@ */ using RadixDlt.NetworkGateway.Abstractions.Numerics; -using RadixDlt.NetworkGateway.PostgresIntegration.Models; -using System.Diagnostics.CodeAnalysis; namespace RadixDlt.NetworkGateway.PostgresIntegration.LedgerExtension; @@ -107,13 +105,3 @@ internal record struct EntityResourceVaultLookup(long EntityId, long ResourceEnt internal record struct NonFungibleStoreLookup(long NonFungibleEntityId, long StateVersion); internal record struct NonFungibleIdLookup(long ResourceEntityId, string NonFungibleId); - -internal record ResourceOwnersChange(bool IsDeleted, ResourceOwners? Entry) -{ - public bool IsDeleted { get; set; } = IsDeleted; - - [MemberNotNullWhen(true, nameof(IsDeleted))] - public ResourceOwners? Entry { get; set; } = Entry; -} - -internal record ResourceOwnersLookup(long EntityId, long ResourceEntityId); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs index ec86eec6d..e42dc5669 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs @@ -735,94 +735,54 @@ await _connection.BeginBinaryImportAsync( return entities.Count; } - public async Task CopyResourceOwners(Dictionary changes, CancellationToken token) + public async Task CopyResourceOwners(ICollection entities, CancellationToken token) { - var entitiesToAdd = changes - .Where(x => !x.Value.IsDeleted) - .Select(x => x.Value.Entry!) - .ToList(); - - var entriesToRemove = changes - .Where(x => x.Value.IsDeleted) - .Select(x => x.Key) - .ToList(); - - if (!entitiesToAdd.Any() && !entriesToRemove.Any()) + if (!entities.Any()) { return 0; } - var changesCount = entitiesToAdd.Count + entriesToRemove.Count; - var sw = Stopwatch.GetTimestamp(); - if (entitiesToAdd.Any()) - { - await using var createTempTableCommand = _connection.CreateCommand(); - createTempTableCommand.CommandText = @" + await using var createTempTableCommand = _connection.CreateCommand(); + createTempTableCommand.CommandText = @" CREATE TEMP TABLE tmp_resource_owners (LIKE resource_owners INCLUDING DEFAULTS) ON COMMIT DROP"; - await createTempTableCommand.ExecuteNonQueryAsync(token); - - await using var writer = - await _connection.BeginBinaryImportAsync( - "COPY tmp_resource_owners (id, entity_id, resource_entity_id, balance) FROM STDIN (FORMAT BINARY)", - token); + await createTempTableCommand.ExecuteNonQueryAsync(token); - foreach (var e in entitiesToAdd) - { - await writer.StartRowAsync(token); - await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(e.ResourceEntityId, NpgsqlDbType.Bigint, token); - await writer.WriteAsync(e.Balance.GetSubUnitsSafeForPostgres(), NpgsqlDbType.Numeric, token); - } - - await writer.CompleteAsync(token); - await writer.DisposeAsync(); - - await using var copyFromTempTablecommand = _connection.CreateCommand(); - copyFromTempTablecommand.CommandText = @" -INSERT INTO resource_owners -SELECT * -FROM tmp_resource_owners -ON CONFLICT (entity_id, resource_entity_id) DO UPDATE SET - balance = EXCLUDED.balance;"; + await using var writer = + await _connection.BeginBinaryImportAsync( + "COPY tmp_resource_owners (id, entity_id, resource_entity_id, balance) FROM STDIN (FORMAT BINARY)", + token); - await copyFromTempTablecommand.ExecuteNonQueryAsync(token); + foreach (var e in entities) + { + await writer.StartRowAsync(token); + await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.ResourceEntityId, NpgsqlDbType.Bigint, token); + await writer.WriteAsync(e.Balance.GetSubUnitsSafeForPostgres(), NpgsqlDbType.Numeric, token); } - if (entriesToRemove.Any()) - { - entriesToRemove - .ToHashSet() - .Unzip( - x => x.ResourceEntityId, - x => x.EntityId, - out var resourceEntityIds, - out var entityIds); + await writer.CompleteAsync(token); + await writer.DisposeAsync(); - var deleteEntriesCommand = new CommandDefinition( - commandText: @" -WITH variables (resource_entity_id, entity_id) AS ( - SELECT UNNEST(@resourceEntityIds), UNNEST(@entityIds) -) -DELETE FROM resource_owners WHERE (resource_entity_id, entity_id) IN (SELECT resource_entity_id, entity_id FROM variables)", - parameters: new - { - resourceEntityIds = resourceEntityIds, - entityIds = entityIds, - }, - cancellationToken: token); + await using var mergeCommand = _connection.CreateCommand(); + mergeCommand.CommandText = @" +MERGE INTO resource_owners ro +USING tmp_resource_owners tmp +ON ro.entity_id = tmp.entity_id AND ro.resource_entity_id = tmp.resource_entity_id +WHEN MATCHED AND tmp.balance = 0 THEN DELETE +WHEN MATCHED AND tmp.balance != 0 THEN UPDATE SET balance = tmp.balance +WHEN NOT MATCHED AND tmp.balance != 0 THEN INSERT VALUES(id, entity_id, resource_entity_id, balance);"; - await _connection.ExecuteAsync(deleteEntriesCommand); - } + await mergeCommand.ExecuteNonQueryAsync(token); - await _observers.ForEachAsync(x => x.StageCompleted(nameof(CopyResourceOwners), Stopwatch.GetElapsedTime(sw), changesCount)); + await _observers.ForEachAsync(x => x.StageCompleted(nameof(CopyResourceOwners), Stopwatch.GetElapsedTime(sw), entities.Count)); - return changesCount; + return entities.Count; } public async Task UpdateSequences(SequencesHolder sequences, CancellationToken token) From 5bb2889dcfb6ab7abccbcb489352de293956052d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Wed, 14 Aug 2024 11:14:14 +0200 Subject: [PATCH 12/18] code cleanup. --- .../PostgresLedgerExtenderService.cs | 6 +- .../LedgerExtension/Records.cs | 2 + .../ResourceOwnersProcessor.cs | 231 ------------------ .../Services/ExtensionsQuerier.cs | 27 +- 4 files changed, 20 insertions(+), 246 deletions(-) delete mode 100644 src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index 7d985d43f..3531a5dfe 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -1438,7 +1438,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, } } - var resourceOwnersToAdd = new Dictionary<(long EntityId, long ResourceEntityId), ResourceOwners>(); + var resourceOwnersToAdd = new Dictionary(); foreach (var x in entityResourceAggregatedVaultsHistoryToAdd) { @@ -1452,7 +1452,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, }; resourceOwnersToAdd.AddOrUpdate( - (x.EntityId, x.ResourceEntityId), + new ResourceOwnersLookup(x.EntityId, x.ResourceEntityId), _ => new ResourceOwners { Id = sequences.ResourceOwnersSequence++, @@ -1523,7 +1523,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, rowsInserted += await writeHelper.CopyResourceEntitySupplyHistory(resourceEntitySupplyHistoryToAdd, token); rowsInserted += await writeHelper.CopyNonFungibleDataSchemaHistory(nonFungibleSchemaHistoryToAdd, token); rowsInserted += await writeHelper.CopyKeyValueStoreSchemaHistory(keyValueStoreSchemaHistoryToAdd, token); - rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd.Select(x => x.Value).ToList(), token); + rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd.Values, token); rowsInserted += await entityStateProcessor.SaveEntities(); rowsInserted += await entityMetadataProcessor.SaveEntities(); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs index ef8f005b8..ca41cea33 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs @@ -105,3 +105,5 @@ internal record struct EntityResourceVaultLookup(long EntityId, long ResourceEnt internal record struct NonFungibleStoreLookup(long NonFungibleEntityId, long StateVersion); internal record struct NonFungibleIdLookup(long ResourceEntityId, string NonFungibleId); + +internal record struct ResourceOwnersLookup(long ResourceEntityId, long EntityId); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs deleted file mode 100644 index 93cc9a687..000000000 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ResourceOwnersProcessor.cs +++ /dev/null @@ -1,231 +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 NpgsqlTypes; -// using RadixDlt.NetworkGateway.Abstractions; -// using RadixDlt.NetworkGateway.Abstractions.Extensions; -// using RadixDlt.NetworkGateway.PostgresIntegration.Models; -// using System; -// using System.Collections.Generic; -// using System.Diagnostics; -// using System.Threading.Tasks; -// using CoreModel = RadixDlt.CoreApiSdk.Model; -// -// namespace RadixDlt.NetworkGateway.PostgresIntegration.LedgerExtension; -// -// public record ResourceOwner(EntityAddress OwnerAddress); -// -// public record FungibleResourceOwner(EntityAddress OwnerAddress, string Amount) : ResourceOwner(OwnerAddress); -// -// public record NonFungibleResourceOwner(EntityAddress OwnerAddress, long NfidCount) : ResourceOwner(OwnerAddress); -// -// internal class ResourceOwnersProcessor -// { -// private readonly ProcessorContext _context; -// private readonly ReferencedEntityDictionary _referencedEntities; -// private readonly Dictionary> _resourceOwners; -// -// private List _toAdd = new(); -// -// public ResourceOwnersProcessor(ProcessorContext context, ReferencedEntityDictionary referencedEntities) -// { -// _context = context; -// _referencedEntities = referencedEntities; -// } -// -// public void VisitUpsert(CoreModel.IUpsertedSubstate substate, ReferencedEntity referencedEntity, long stateVersion) -// { -// var substateData = substate.Value.SubstateData; -// -// if (substateData is CoreModel.GenericScryptoComponentFieldStateSubstate componentState) -// { -// if (substate.SystemStructure is not CoreModel.ObjectFieldStructure objectFieldStructure) -// { -// throw new UnreachableException($"Generic Scrypto components are expected to have ObjectFieldStructure. Got: {substate.SystemStructure.GetType()}"); -// } -// -// var schemaDetails = objectFieldStructure.ValueSchema.GetSchemaDetails(); -// -// _toAdd.Add(new SborStateHistory -// { -// Id = _context.Sequences.StateHistorySequence++, -// FromStateVersion = stateVersion, -// EntityId = referencedEntity.DatabaseId, -// SborState = componentState.Value.DataStruct.StructData.GetDataBytes(), -// SchemaHash = schemaDetails.SchemaHash.ConvertFromHex(), -// SborTypeKind = schemaDetails.SborTypeKind.ToModel(), -// TypeIndex = schemaDetails.TypeIndex, -// SchemaDefiningEntityId = _referencedEntities.Get((EntityAddress)schemaDetails.SchemaDefiningEntityAddress).DatabaseId, -// }); -// } -// -// if (substateData is CoreModel.ValidatorFieldStateSubstate validator) -// { -// _toAdd.Add(new JsonStateHistory -// { -// Id = _context.Sequences.StateHistorySequence++, -// FromStateVersion = stateVersion, -// EntityId = referencedEntity.DatabaseId, -// JsonState = validator.Value.ToJson(), -// }); -// } -// -// if (substateData is CoreModel.AccountFieldStateSubstate accountFieldState) -// { -// _toAdd.Add(new JsonStateHistory -// { -// Id = _context.Sequences.StateHistorySequence++, -// FromStateVersion = stateVersion, -// EntityId = referencedEntity.DatabaseId, -// JsonState = accountFieldState.Value.ToJson(), -// }); -// } -// -// if (substateData is CoreModel.AccessControllerFieldStateSubstate accessControllerFieldState) -// { -// _toAdd.Add(new JsonStateHistory -// { -// Id = _context.Sequences.StateHistorySequence++, -// FromStateVersion = stateVersion, -// EntityId = referencedEntity.DatabaseId, -// JsonState = accessControllerFieldState.Value.ToJson(), -// }); -// } -// -// if (substateData is CoreModel.OneResourcePoolFieldStateSubstate oneResourcePoolFieldStateSubstate) -// { -// _toAdd.Add(new JsonStateHistory -// { -// Id = _context.Sequences.StateHistorySequence++, -// FromStateVersion = stateVersion, -// EntityId = referencedEntity.DatabaseId, -// JsonState = oneResourcePoolFieldStateSubstate.Value.ToJson(), -// }); -// } -// -// if (substateData is CoreModel.TwoResourcePoolFieldStateSubstate twoResourcePoolFieldStateSubstate) -// { -// _toAdd.Add(new JsonStateHistory -// { -// Id = _context.Sequences.StateHistorySequence++, -// FromStateVersion = stateVersion, -// EntityId = referencedEntity.DatabaseId, -// JsonState = twoResourcePoolFieldStateSubstate.Value.ToJson(), -// }); -// } -// -// if (substateData is CoreModel.MultiResourcePoolFieldStateSubstate multiResourcePoolFieldStateSubstate) -// { -// _toAdd.Add(new JsonStateHistory -// { -// Id = _context.Sequences.StateHistorySequence++, -// FromStateVersion = stateVersion, -// EntityId = referencedEntity.DatabaseId, -// JsonState = multiResourcePoolFieldStateSubstate.Value.ToJson(), -// }); -// } -// } -// -// public async Task SaveEntities() -// { -// var rowsInserted = 0; -// -// rowsInserted += await CopyStateHistory(); -// -// return rowsInserted; -// } -// -// private Task CopyStateHistory() => _context.WriteHelper.Copy( -// _toAdd, -// "COPY state_history (id, from_state_version, entity_id, discriminator, json_state, sbor_state, type_index, schema_hash, sbor_type_kind, schema_defining_entity_id) FROM STDIN (FORMAT BINARY)", -// async (writer, e, token) => -// { -// await writer.WriteAsync(e.Id, NpgsqlDbType.Bigint, token); -// await writer.WriteAsync(e.FromStateVersion, NpgsqlDbType.Bigint, token); -// await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); -// await writer.WriteAsync(_context.WriteHelper.GetDiscriminator(e.GetType()), "state_type", token); -// -// switch (e) -// { -// case JsonStateHistory jsonStateHistory: -// await writer.WriteAsync(jsonStateHistory.JsonState, NpgsqlDbType.Jsonb, token); -// await writer.WriteNullAsync(token); -// await writer.WriteNullAsync(token); -// await writer.WriteNullAsync(token); -// await writer.WriteNullAsync(token); -// await writer.WriteNullAsync(token); -// break; -// case SborStateHistory sborStateHistory: -// await writer.WriteNullAsync(token); -// await writer.WriteAsync(sborStateHistory.SborState, NpgsqlDbType.Bytea, token); -// await writer.WriteAsync(sborStateHistory.TypeIndex, NpgsqlDbType.Bigint, token); -// await writer.WriteAsync(sborStateHistory.SchemaHash, NpgsqlDbType.Bytea, token); -// await writer.WriteAsync(sborStateHistory.SborTypeKind, "sbor_type_kind", token); -// await writer.WriteAsync(sborStateHistory.SchemaDefiningEntityId, NpgsqlDbType.Bigint, token); -// break; -// default: -// throw new ArgumentOutOfRangeException(nameof(e), e, null); -// } -// }); -// } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs index 3636de33d..4d9c01cf6 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs @@ -113,8 +113,9 @@ public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapp var totalCount = await _dbContext.ResourceOwners.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); - var cd = new CommandDefinition( - commandText: @" + var entriesAndOneMore = await _dapperWrapper.ToList( + _dbContext, + @" SELECT ro.id as Id, e.address AS EntityAddress, @@ -123,30 +124,31 @@ FROM resource_owners ro INNER JOIN entities e ON ro.entity_id = e.id WHERE ro.resource_entity_id = @resourceEntityId - AND (@balanceBoundary is null OR ((ro.balance, ro.id) < (Cast(@balanceBoundary AS numeric(1000,0)), @idBoundary))) + AND (@balanceBoundary is null OR ((ro.balance, ro.id) <= (Cast(@balanceBoundary AS numeric(1000,0)), @idBoundary))) ORDER BY (ro.balance, ro.entity_id) DESC LIMIT @limit", - parameters: new + new { resourceEntityId = resourceEntity.Id, balanceBoundary = cursor?.BalanceBoundary, idBoundary = cursor?.IdBoundary ?? long.MaxValue, - limit = limit, + limit = limit + 1, }, - cancellationToken: token); + token); - var result = (await _dapperWrapper.QueryAsync(_dbContext.Database.GetDbConnection(), cd)).ToList(); + var lastElement = entriesAndOneMore.LastOrDefault(); + var nextPageExists = entriesAndOneMore.Count == limit + 1 && lastElement != null; - var lastElement = result.LastOrDefault(); - var nextCursor = lastElement != null - ? new GatewayModel.ResourceOwnersCursor(lastElement.Id, TokenAmount.FromDecimalString(lastElement.Balance).ToString()).ToCursorString() + var nextCursor = nextPageExists + ? new GatewayModel.ResourceOwnersCursor(lastElement!.Id, TokenAmount.FromDecimalString(lastElement.Balance).ToString()).ToCursorString() : null; switch (resourceEntity) { case GlobalFungibleResourceEntity: { - var castedResult = result + var castedResult = entriesAndOneMore + .Take(limit) .Select( x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionFungibleResourceItem( amount: TokenAmount.FromSubUnitsString(x.Balance).ToString(), @@ -159,7 +161,8 @@ ORDER BY (ro.balance, ro.entity_id) DESC case GlobalNonFungibleResourceEntity: { - var castedResult = result + var castedResult = entriesAndOneMore + .Take(limit) .Select( x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionNonFungibleResourceItem( nonFungibleIdsCount: long.Parse(TokenAmount.FromSubUnitsString(x.Balance).ToString()), From be97fd4faed2e373ab2be22a2319c98759f1920d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Thu, 15 Aug 2024 10:24:14 +0200 Subject: [PATCH 13/18] use TokenAmount.MaxValue for cursor max value. --- .../Numerics/TokenAmount.cs | 3 ++- .../gateway-api-schema.yaml | 6 +++--- .../Services/ExtensionsQuerier.cs | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs b/src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs index aa5c09685..4a4bb8ca4 100644 --- a/src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs +++ b/src/RadixDlt.NetworkGateway.Abstractions/Numerics/TokenAmount.cs @@ -75,6 +75,7 @@ namespace RadixDlt.NetworkGateway.Abstractions.Numerics; public static readonly TokenAmount Zero; public static readonly TokenAmount NaN; public static readonly TokenAmount OneFullUnit; + public static readonly TokenAmount MaxValue; private const int DecimalPrecision = 18; @@ -83,7 +84,7 @@ namespace RadixDlt.NetworkGateway.Abstractions.Numerics; static TokenAmount() { _divisor = BigInteger.Pow(10, DecimalPrecision); - + MaxValue = new TokenAmount(BigInteger.Pow(2, 192), 0); Zero = new TokenAmount(0); NaN = new TokenAmount(true); OneFullUnit = new TokenAmount(_divisor); diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index 45519997c..e676e9ec3 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -1910,9 +1910,9 @@ paths: operationId: ResourceOwnersPage summary: Get Resource Owners Page description: | - Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. - This endpoint operates only at current state version, it is not possible to browse historical data. - Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. + This endpoint operates only at the current state version, it is not possible to browse historical data. + Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. tags: - Extensions requestBody: diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs index 4d9c01cf6..b145acf7a 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs @@ -124,13 +124,13 @@ FROM resource_owners ro INNER JOIN entities e ON ro.entity_id = e.id WHERE ro.resource_entity_id = @resourceEntityId - AND (@balanceBoundary is null OR ((ro.balance, ro.id) <= (Cast(@balanceBoundary AS numeric(1000,0)), @idBoundary))) + AND (ro.balance, ro.id) <= (Cast(@balanceBoundary AS numeric(1000,0)), @idBoundary) ORDER BY (ro.balance, ro.entity_id) DESC LIMIT @limit", new { resourceEntityId = resourceEntity.Id, - balanceBoundary = cursor?.BalanceBoundary, + balanceBoundary = cursor?.BalanceBoundary ?? TokenAmount.MaxValue.ToString(), idBoundary = cursor?.IdBoundary ?? long.MaxValue, limit = limit + 1, }, From b0ffbc55993d8091daffe7e0a27e42626fe55217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Thu, 15 Aug 2024 17:11:08 +0200 Subject: [PATCH 14/18] include lastUpdatedAtStateVersion in resource owners response. --- .../gateway-api-schema.yaml | 4 + .../generated/Api/ExtensionsApi.cs | 16 +- ...rceOwnersCollectionFungibleResourceItem.cs | 3 +- .../Model/ResourceOwnersCollectionItem.cs | 16 +- ...OwnersCollectionNonFungibleResourceItem.cs | 3 +- .../PostgresLedgerExtenderService.cs | 8 +- .../LedgerExtension/WriteHelper.cs | 7 +- ... 20240815152003_InitialCreate.Designer.cs} | 6 +- ...ate.cs => 20240815152003_InitialCreate.cs} | 9 +- .../Migrations/IdempotentApplyMigrations.sql | 243 +++++++++--------- .../MigrationsDbContextModelSnapshot.cs | 4 + .../Models/ResourceOwners.cs | 3 + .../Services/ExtensionsQuerier.cs | 11 +- 13 files changed, 187 insertions(+), 146 deletions(-) rename src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/{20240813085815_InitialCreate.Designer.cs => 20240815152003_InitialCreate.Designer.cs} (99%) rename src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/{20240813085815_InitialCreate.cs => 20240815152003_InitialCreate.cs} (99%) diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index e676e9ec3..f1fc87e5f 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -3169,11 +3169,15 @@ components: required: - type - owner_address + - last_updated_at_state_version properties: type: $ref: "#/components/schemas/ResourceOwnersResourceType" owner_address: $ref: "#/components/schemas/Address" + last_updated_at_state_version: + type: integer + format: int64 discriminator: propertyName: type mapping: diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs index 18c1e1bfe..927fde058 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs @@ -95,7 +95,7 @@ public interface IExtensionsApiSync : IApiAccessor /// Get Resource Owners Page /// /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + /// Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -106,7 +106,7 @@ public interface IExtensionsApiSync : IApiAccessor /// Get Resource Owners Page /// /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + /// Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -125,7 +125,7 @@ public interface IExtensionsApiAsync : IApiAccessor /// Get Resource Owners Page /// /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + /// Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -137,7 +137,7 @@ public interface IExtensionsApiAsync : IApiAccessor /// Get Resource Owners Page /// /// - /// Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + /// Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -358,7 +358,7 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ExceptionFactory ExceptionFa } /// - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + /// Get Resource Owners Page Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -370,7 +370,7 @@ public ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceO } /// - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + /// Get Resource Owners Page Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -414,7 +414,7 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + /// Get Resource Owners Page Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// @@ -427,7 +427,7 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse - /// Get Resource Owners Page Returns list of all owners of given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at current state version, it is not possible to browse historical data. Because of that it is not possible to offer stable pagination as data constantly changes. Values might change which might result in gaps or some entries being returned twice. + /// Get Resource Owners Page Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call /// diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs index eca4e61fc..770a4f0b8 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs @@ -110,7 +110,8 @@ protected ResourceOwnersCollectionFungibleResourceItem() { } /// String-encoded decimal representing the amount of a related fungible resource. (required). /// type (required) (default to ResourceOwnersResourceType.FungibleResource). /// Bech32m-encoded human readable version of the address. (required). - public ResourceOwnersCollectionFungibleResourceItem(string amount = default(string), ResourceOwnersResourceType type = ResourceOwnersResourceType.FungibleResource, string ownerAddress = default(string)) : base(type, ownerAddress) + /// lastUpdatedAtStateVersion (required). + public ResourceOwnersCollectionFungibleResourceItem(string amount = default(string), ResourceOwnersResourceType type = ResourceOwnersResourceType.FungibleResource, string ownerAddress = default(string), long lastUpdatedAtStateVersion = default(long)) : base(type, ownerAddress, lastUpdatedAtStateVersion) { // to ensure "amount" is required (not null) if (amount == null) diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs index d0e99efb6..408afd968 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs @@ -117,7 +117,8 @@ protected ResourceOwnersCollectionItem() { } /// /// type (required). /// Bech32m-encoded human readable version of the address. (required). - public ResourceOwnersCollectionItem(ResourceOwnersResourceType type = default(ResourceOwnersResourceType), string ownerAddress = default(string)) + /// lastUpdatedAtStateVersion (required). + public ResourceOwnersCollectionItem(ResourceOwnersResourceType type = default(ResourceOwnersResourceType), string ownerAddress = default(string), long lastUpdatedAtStateVersion = default(long)) { this.Type = type; // to ensure "ownerAddress" is required (not null) @@ -126,6 +127,7 @@ protected ResourceOwnersCollectionItem() { } throw new ArgumentNullException("ownerAddress is a required property for ResourceOwnersCollectionItem and cannot be null"); } this.OwnerAddress = ownerAddress; + this.LastUpdatedAtStateVersion = lastUpdatedAtStateVersion; } /// @@ -135,6 +137,12 @@ protected ResourceOwnersCollectionItem() { } [DataMember(Name = "owner_address", IsRequired = true, EmitDefaultValue = true)] public string OwnerAddress { get; set; } + /// + /// Gets or Sets LastUpdatedAtStateVersion + /// + [DataMember(Name = "last_updated_at_state_version", IsRequired = true, EmitDefaultValue = true)] + public long LastUpdatedAtStateVersion { get; set; } + /// /// Returns the string presentation of the object /// @@ -145,6 +153,7 @@ public override string ToString() sb.Append("class ResourceOwnersCollectionItem {\n"); sb.Append(" Type: ").Append(Type).Append("\n"); sb.Append(" OwnerAddress: ").Append(OwnerAddress).Append("\n"); + sb.Append(" LastUpdatedAtStateVersion: ").Append(LastUpdatedAtStateVersion).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -188,6 +197,10 @@ public bool Equals(ResourceOwnersCollectionItem input) this.OwnerAddress == input.OwnerAddress || (this.OwnerAddress != null && this.OwnerAddress.Equals(input.OwnerAddress)) + ) && + ( + this.LastUpdatedAtStateVersion == input.LastUpdatedAtStateVersion || + this.LastUpdatedAtStateVersion.Equals(input.LastUpdatedAtStateVersion) ); } @@ -205,6 +218,7 @@ public override int GetHashCode() { hashCode = (hashCode * 59) + this.OwnerAddress.GetHashCode(); } + hashCode = (hashCode * 59) + this.LastUpdatedAtStateVersion.GetHashCode(); return hashCode; } } diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs index 085604504..7b354149d 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs @@ -110,7 +110,8 @@ protected ResourceOwnersCollectionNonFungibleResourceItem() { } /// nonFungibleIdsCount (required). /// type (required) (default to ResourceOwnersResourceType.NonFungibleResource). /// Bech32m-encoded human readable version of the address. (required). - public ResourceOwnersCollectionNonFungibleResourceItem(long nonFungibleIdsCount = default(long), ResourceOwnersResourceType type = ResourceOwnersResourceType.NonFungibleResource, string ownerAddress = default(string)) : base(type, ownerAddress) + /// lastUpdatedAtStateVersion (required). + public ResourceOwnersCollectionNonFungibleResourceItem(long nonFungibleIdsCount = default(long), ResourceOwnersResourceType type = ResourceOwnersResourceType.NonFungibleResource, string ownerAddress = default(string), long lastUpdatedAtStateVersion = default(long)) : base(type, ownerAddress, lastUpdatedAtStateVersion) { this.NonFungibleIdsCount = nonFungibleIdsCount; } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index 3531a5dfe..b9bc3227e 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -1459,9 +1459,13 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, EntityId = x.EntityId, ResourceEntityId = x.ResourceEntityId, Balance = balance, + LastUpdatedAtStateVersion = x.FromStateVersion, }, - existing => existing.Balance = balance - ); + existing => + { + existing.Balance = balance; + existing.LastUpdatedAtStateVersion = x.FromStateVersion; + }); } var resourceEntitySupplyHistoryToAdd = resourceSupplyChanges diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs index e42dc5669..41b19a514 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs @@ -754,7 +754,7 @@ CREATE TEMP TABLE tmp_resource_owners await using var writer = await _connection.BeginBinaryImportAsync( - "COPY tmp_resource_owners (id, entity_id, resource_entity_id, balance) FROM STDIN (FORMAT BINARY)", + "COPY tmp_resource_owners (id, entity_id, resource_entity_id, balance, last_updated_at_state_version) FROM STDIN (FORMAT BINARY)", token); foreach (var e in entities) @@ -764,6 +764,7 @@ await _connection.BeginBinaryImportAsync( await writer.WriteAsync(e.EntityId, NpgsqlDbType.Bigint, token); await writer.WriteAsync(e.ResourceEntityId, NpgsqlDbType.Bigint, token); await writer.WriteAsync(e.Balance.GetSubUnitsSafeForPostgres(), NpgsqlDbType.Numeric, token); + await writer.WriteAsync(e.LastUpdatedAtStateVersion, NpgsqlDbType.Bigint, token); } await writer.CompleteAsync(token); @@ -775,8 +776,8 @@ MERGE INTO resource_owners ro USING tmp_resource_owners tmp ON ro.entity_id = tmp.entity_id AND ro.resource_entity_id = tmp.resource_entity_id WHEN MATCHED AND tmp.balance = 0 THEN DELETE -WHEN MATCHED AND tmp.balance != 0 THEN UPDATE SET balance = tmp.balance -WHEN NOT MATCHED AND tmp.balance != 0 THEN INSERT VALUES(id, entity_id, resource_entity_id, balance);"; +WHEN MATCHED AND tmp.balance != 0 THEN UPDATE SET balance = tmp.balance, last_updated_at_state_version = tmp.last_updated_at_state_version +WHEN NOT MATCHED AND tmp.balance != 0 THEN INSERT VALUES(id, entity_id, resource_entity_id, balance, last_updated_at_state_version);"; await mergeCommand.ExecuteNonQueryAsync(token); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.Designer.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.Designer.cs similarity index 99% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.Designer.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.Designer.cs index 8864687c5..c43e3b755 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.Designer.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.Designer.cs @@ -81,7 +81,7 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations { [DbContext(typeof(MigrationsDbContext))] - [Migration("20240813085815_InitialCreate")] + [Migration("20240815152003_InitialCreate")] partial class InitialCreate { /// @@ -1575,6 +1575,10 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) .HasColumnType("bigint") .HasColumnName("entity_id"); + b.Property("LastUpdatedAtStateVersion") + .HasColumnType("bigint") + .HasColumnName("last_updated_at_state_version"); + b.Property("ResourceEntityId") .HasColumnType("bigint") .HasColumnName("resource_entity_id"); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.cs similarity index 99% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.cs index 40c06d3d0..8001927b8 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240813085815_InitialCreate.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.cs @@ -62,14 +62,14 @@ * permissions under this License. */ +using System; +using System.Collections.Generic; +using System.Numerics; using Microsoft.EntityFrameworkCore.Migrations; using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using RadixDlt.NetworkGateway.Abstractions.Model; using RadixDlt.NetworkGateway.Abstractions.StandardMetadata; using RadixDlt.NetworkGateway.PostgresIntegration.Models; -using System; -using System.Collections.Generic; -using System.Numerics; #nullable disable @@ -762,7 +762,8 @@ protected override void Up(MigrationBuilder migrationBuilder) .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), entity_id = table.Column(type: "bigint", nullable: false), resource_entity_id = table.Column(type: "bigint", nullable: false), - balance = table.Column(type: "numeric(1000)", precision: 1000, nullable: false) + balance = table.Column(type: "numeric(1000)", precision: 1000, nullable: false), + last_updated_at_state_version = table.Column(type: "bigint", nullable: false) }, constraints: table => { diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql index 1b597a064..d495318d6 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql @@ -9,7 +9,7 @@ START TRANSACTION; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TYPE account_default_deposit_rule AS ENUM ('accept', 'reject', 'allow_existing'); CREATE TYPE account_resource_preference_rule AS ENUM ('allowed', 'disallowed'); CREATE TYPE authorized_depositor_badge_type AS ENUM ('resource', 'non_fungible'); @@ -37,7 +37,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE account_authorized_depositor_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -50,7 +50,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE account_authorized_depositor_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -66,7 +66,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE account_default_deposit_rule_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -79,7 +79,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE account_locker_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -93,7 +93,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE account_locker_entry_resource_vault_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -107,7 +107,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE account_locker_entry_touch_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -119,7 +119,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE account_resource_preference_rule_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -132,7 +132,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE account_resource_preference_rule_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -147,7 +147,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE component_method_royalty_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -160,7 +160,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE component_method_royalty_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -175,7 +175,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entities ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -201,7 +201,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_metadata_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -214,7 +214,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_metadata_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -230,7 +230,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_resource_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -246,7 +246,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_resource_aggregated_vaults_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -262,7 +262,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_resource_vault_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -276,7 +276,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_role_assignments_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -290,7 +290,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_role_assignments_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -306,7 +306,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_role_assignments_owner_role_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -319,7 +319,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE entity_vault_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -338,7 +338,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE key_value_store_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -351,7 +351,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE key_value_store_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -366,7 +366,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE key_value_store_schema_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -386,7 +386,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE ledger_transaction_markers ( id bigint GENERATED BY DEFAULT AS IDENTITY, state_version bigint NOT NULL, @@ -406,7 +406,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE ledger_transactions ( state_version bigint NOT NULL, epoch bigint NOT NULL, @@ -454,7 +454,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE non_fungible_id_data_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -469,7 +469,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE non_fungible_id_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -482,7 +482,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE non_fungible_id_location_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -495,7 +495,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE non_fungible_schema_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -511,7 +511,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE package_blueprint_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -524,7 +524,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE package_blueprint_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -544,7 +544,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE package_code_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -557,7 +557,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE package_code_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -573,7 +573,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE pending_transactions ( id bigint GENERATED BY DEFAULT AS IDENTITY, payload_hash text NOT NULL, @@ -601,7 +601,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE resource_entity_supply_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -616,12 +616,13 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE resource_owners ( id bigint GENERATED BY DEFAULT AS IDENTITY, entity_id bigint NOT NULL, resource_entity_id bigint NOT NULL, balance numeric(1000) NOT NULL, + last_updated_at_state_version bigint NOT NULL, CONSTRAINT "PK_resource_owners" PRIMARY KEY (id) ); END IF; @@ -629,7 +630,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE schema_entry_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -642,7 +643,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE schema_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -656,7 +657,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE state_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -675,7 +676,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE unverified_standard_metadata_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -688,7 +689,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE unverified_standard_metadata_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -705,7 +706,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE validator_cumulative_emission_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -721,7 +722,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE validator_public_key_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -735,7 +736,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE pending_transaction_payloads ( id bigint GENERATED BY DEFAULT AS IDENTITY, pending_transaction_id bigint, @@ -748,7 +749,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE TABLE validator_active_set_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -763,520 +764,520 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_aggregate_history_account_enti~" ON account_authorized_depositor_aggregate_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_~1" ON account_authorized_depositor_entry_history (account_entity_id, resource_entity_id, non_fungible_id, from_state_version) WHERE discriminator = 'non_fungible'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_~2" ON account_authorized_depositor_entry_history (account_entity_id, resource_entity_id, from_state_version) WHERE discriminator = 'resource'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_i~" ON account_authorized_depositor_entry_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_account_default_deposit_rule_history_account_entity_id_from~" ON account_default_deposit_rule_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE UNIQUE INDEX "IX_account_locker_entry_definition_account_locker_entity_id_ac~" ON account_locker_entry_definition (account_locker_entity_id, account_entity_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE UNIQUE INDEX "IX_account_locker_entry_resource_vault_definition_account_lock~" ON account_locker_entry_resource_vault_definition (account_locker_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_account_locker_entry_touch_history_account_locker_definitio~" ON account_locker_entry_touch_history (account_locker_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_account_resource_preference_rule_aggregate_history_account_~" ON account_resource_preference_rule_aggregate_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_account_resource_preference_rule_entry_history_account_enti~" ON account_resource_preference_rule_entry_history (account_entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_aggregate_history_entity_id_from_s~" ON component_method_royalty_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_entry_history_entity_id_from_state~" ON component_method_royalty_entry_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_entry_history_entity_id_method_nam~" ON component_method_royalty_entry_history (entity_id, method_name, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE UNIQUE INDEX "IX_entities_address" ON entities (address); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entities_from_state_version" ON entities (from_state_version) WHERE discriminator = 'global_validator'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_metadata_aggregate_history_entity_id_from_state_vers~" ON entity_metadata_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_metadata_history_entity_id_key_from_state_version" ON entity_metadata_history (entity_id, key, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_resource_aggregate_history_entity_id_from_state_vers~" ON entity_resource_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_resource_aggregated_vaults_history_entity_id_resourc~" ON entity_resource_aggregated_vaults_history (entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_resource_vault_aggregate_history_entity_id_resource_~" ON entity_resource_vault_aggregate_history (entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_aggregate_history_entity_id_from_st~" ON entity_role_assignments_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_entry_history_entity_id_key_role_ke~" ON entity_role_assignments_entry_history (entity_id, key_role, key_module, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_owner_role_history_entity_id_from_s~" ON entity_role_assignments_owner_role_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_global_entity_id_from_state_version" ON entity_vault_history (global_entity_id, from_state_version) WHERE is_royalty_vault = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_global_entity_id_vault_entity_id_from_~" ON entity_vault_history (global_entity_id, vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_id_resource_entity_id_from_state_versi~" ON entity_vault_history (id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_owner_entity_id_from_state_version" ON entity_vault_history (owner_entity_id, from_state_version) WHERE is_royalty_vault = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_owner_entity_id_vault_entity_id_from_s~" ON entity_vault_history (owner_entity_id, vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_vault_entity_id_from_state_version" ON entity_vault_history (vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_definition_key_value_store_entity_id_~" ON key_value_store_entry_definition (key_value_store_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_definition_key_value_store_entity_id~1" ON key_value_store_entry_definition (key_value_store_entity_id, key); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_history_key_value_store_entry_definit~" ON key_value_store_entry_history (key_value_store_entry_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_key_value_store_schema_history_key_value_store_entity_id_fr~" ON key_value_store_schema_history (key_value_store_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_entity_id_state_version" ON ledger_transaction_markers (entity_id, state_version) WHERE discriminator = 'event_global_emitter'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_entity_id_state_version1" ON ledger_transaction_markers (entity_id, state_version) WHERE discriminator = 'affected_global_entity'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_event_type_entity_id_state_versi~" ON ledger_transaction_markers (event_type, entity_id, state_version) WHERE discriminator = 'event'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_manifest_class" ON ledger_transaction_markers (manifest_class, state_version) WHERE discriminator = 'manifest_class'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_manifest_class_is_most_specific" ON ledger_transaction_markers (manifest_class, state_version) WHERE discriminator = 'manifest_class' and is_most_specific = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_operation_type_entity_id_state_v~" ON ledger_transaction_markers (operation_type, entity_id, state_version) WHERE discriminator = 'manifest_address'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_origin_type_state_version" ON ledger_transaction_markers (origin_type, state_version) WHERE discriminator = 'origin'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_state_version" ON ledger_transaction_markers (state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE UNIQUE INDEX "IX_ledger_transactions_epoch_round_in_epoch" ON ledger_transactions (epoch, round_in_epoch) WHERE index_in_round = 0; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transactions_intent_hash" ON ledger_transactions USING hash (intent_hash) WHERE intent_hash IS NOT NULL; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_ledger_transactions_round_timestamp" ON ledger_transactions (round_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_data_history_non_fungible_id_definition_id_~" ON non_fungible_id_data_history (non_fungible_id_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_definition_non_fungible_resource_entity_id_~" ON non_fungible_id_definition (non_fungible_resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE UNIQUE INDEX "IX_non_fungible_id_definition_non_fungible_resource_entity_id~1" ON non_fungible_id_definition (non_fungible_resource_entity_id, non_fungible_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_location_history_non_fungible_id_definition~" ON non_fungible_id_location_history (non_fungible_id_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_non_fungible_schema_history_resource_entity_id_from_state_v~" ON non_fungible_schema_history (resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_aggregate_history_package_entity_id_from_~" ON package_blueprint_aggregate_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_history_package_entity_id_from_state_vers~" ON package_blueprint_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_history_package_entity_id_name_version_fr~" ON package_blueprint_history (package_entity_id, name, version, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_package_code_aggregate_history_package_entity_id_from_state~" ON package_code_aggregate_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_package_code_history_package_entity_id_from_state_version" ON package_code_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE UNIQUE INDEX "IX_pending_transaction_payloads_pending_transaction_id" ON pending_transaction_payloads (pending_transaction_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_first_submitted_to_gateway_timestamp" ON pending_transactions (first_submitted_to_gateway_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_intent_hash" ON pending_transactions (intent_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE UNIQUE INDEX "IX_pending_transactions_payload_hash" ON pending_transactions (payload_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_resubmit_from_timestamp" ON pending_transactions (resubmit_from_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_resource_entity_supply_history_resource_entity_id_from_stat~" ON resource_entity_supply_history (resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE UNIQUE INDEX "IX_resource_owners_entity_id_resource_entity_id" ON resource_owners (entity_id, resource_entity_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_resource_owners_entity_id_resource_entity_id_balance" ON resource_owners (entity_id, resource_entity_id, balance); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_schema_entry_aggregate_history_entity_id_from_state_version" ON schema_entry_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_schema_entry_definition_entity_id_schema_hash" ON schema_entry_definition (entity_id, schema_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_state_history_entity_id_from_state_version" ON state_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_unverified_standard_metadata_aggregate_history_entity_id_fr~" ON unverified_standard_metadata_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_unverified_standard_metadata_entry_history_entity_id_discri~" ON unverified_standard_metadata_entry_history (entity_id, discriminator, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_epoch" ON validator_active_set_history (epoch); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_from_state_version" ON validator_active_set_history (from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_validator_public_key_history_id" ON validator_active_set_history (validator_public_key_history_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_validator_cumulative_emission_history_validator_entity_id_e~" ON validator_cumulative_emission_history (validator_entity_id, epoch_number); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_validator_public_key_history_validator_entity_id_from_state~" ON validator_public_key_history (validator_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN CREATE INDEX "IX_validator_public_key_history_validator_entity_id_key_type_k~" ON validator_public_key_history (validator_entity_id, key_type, key); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240813085815_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") - VALUES ('20240813085815_InitialCreate', '8.0.2'); + VALUES ('20240815152003_InitialCreate', '8.0.2'); END IF; END $EF$; COMMIT; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs index 5517a79ad..1cb3dd53d 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs @@ -1572,6 +1572,10 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("bigint") .HasColumnName("entity_id"); + b.Property("LastUpdatedAtStateVersion") + .HasColumnType("bigint") + .HasColumnName("last_updated_at_state_version"); + b.Property("ResourceEntityId") .HasColumnType("bigint") .HasColumnName("resource_entity_id"); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs index 825523f2a..0db17b393 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs @@ -83,4 +83,7 @@ internal class ResourceOwners [Column("balance")] public TokenAmount Balance { get; set; } + + [Column("last_updated_at_state_version")] + public long LastUpdatedAtStateVersion { get; set; } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs index b145acf7a..36d158e60 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs @@ -82,7 +82,7 @@ internal class ExtensionsQuerier : IExtensionsQuerier private readonly ReadOnlyDbContext _dbContext; private readonly IDapperWrapper _dapperWrapper; - private record ResourceOwnersViewModel(long Id, EntityAddress EntityAddress, string Balance); + private record ResourceOwnersViewModel(long Id, EntityAddress EntityAddress, string Balance, long LastUpdatedAtStateVersion); public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapper) { @@ -119,7 +119,8 @@ public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapp SELECT ro.id as Id, e.address AS EntityAddress, - CAST(ro.balance AS text) AS Balance + CAST(ro.balance AS text) AS Balance, + ro.last_updated_at_state_version AS LastUpdatedAtStateVersion FROM resource_owners ro INNER JOIN entities e ON ro.entity_id = e.id @@ -152,7 +153,8 @@ ORDER BY (ro.balance, ro.entity_id) DESC .Select( x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionFungibleResourceItem( amount: TokenAmount.FromSubUnitsString(x.Balance).ToString(), - ownerAddress: x.EntityAddress) + ownerAddress: x.EntityAddress, + lastUpdatedAtStateVersion: x.LastUpdatedAtStateVersion) ) .ToList(); @@ -166,7 +168,8 @@ ORDER BY (ro.balance, ro.entity_id) DESC .Select( x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionNonFungibleResourceItem( nonFungibleIdsCount: long.Parse(TokenAmount.FromSubUnitsString(x.Balance).ToString()), - ownerAddress: x.EntityAddress) + ownerAddress: x.EntityAddress, + lastUpdatedAtStateVersion: x.LastUpdatedAtStateVersion) ) .ToList(); From 9bf6aa2235fdd14fa82c927ada022d76c219d8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Fri, 16 Aug 2024 12:50:00 +0200 Subject: [PATCH 15/18] rename resource owners to resource holders. --- CHANGELOG.md | 4 +- .../Controllers/ExtensionsController.cs | 6 +- .../Handlers/DefaultExtensionsHandler.cs | 6 +- .../Handlers/IExtensionsHandler.cs | 2 +- .../Services/IExtensionsQuerier.cs | 4 +- ...lidator.cs => ResourceHoldersValidator.cs} | 4 +- .../gateway-api-schema.yaml | 48 ++-- ...nersCursor.cs => ResourceHoldersCursor.cs} | 6 +- .../generated/Api/ExtensionsApi.cs | 100 +++---- ...ection.cs => ResourceHoldersCollection.cs} | 28 +- ...f.cs => ResourceHoldersCollectionAllOf.cs} | 28 +- ...eHoldersCollectionFungibleResourceItem.cs} | 34 +-- ...em.cs => ResourceHoldersCollectionItem.cs} | 60 ++--- ...ldersCollectionNonFungibleResourceItem.cs} | 32 +-- ...CollectionNonFungibleResourceItemAllOf.cs} | 24 +- ...rsRequest.cs => ResourceHoldersRequest.cs} | 20 +- ...llOf.cs => ResourceHoldersRequestAllOf.cs} | 20 +- ...Type.cs => ResourceHoldersResourceType.cs} | 4 +- ...Response.cs => ResourceHoldersResponse.cs} | 28 +- .../CommonDbContext.cs | 6 +- .../PostgresLedgerExtenderService.cs | 12 +- .../LedgerExtension/ReadHelper.cs | 2 +- .../LedgerExtension/Records.cs | 2 +- .../LedgerExtension/SequencesHolder.cs | 2 +- .../LedgerExtension/WriteHelper.cs | 18 +- ... 20240816104539_InitialCreate.Designer.cs} | 6 +- ...ate.cs => 20240816104539_InitialCreate.cs} | 14 +- .../Migrations/IdempotentApplyMigrations.sql | 250 +++++++++--------- .../MigrationsDbContextModelSnapshot.cs | 4 +- .../{ResourceOwners.cs => ResourceHolder.cs} | 4 +- .../Services/ExtensionsQuerier.cs | 26 +- 31 files changed, 402 insertions(+), 402 deletions(-) rename src/RadixDlt.NetworkGateway.GatewayApi/Validators/{ResourceOwnersValidator.cs => ResourceHoldersValidator.cs} (95%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/{ResourceOwnersCursor.cs => ResourceHoldersCursor.cs} (94%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersCollection.cs => ResourceHoldersCollection.cs} (92%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersCollectionAllOf.cs => ResourceHoldersCollectionAllOf.cs} (90%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersCollectionFungibleResourceItem.cs => ResourceHoldersCollectionFungibleResourceItem.cs} (85%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersCollectionItem.cs => ResourceHoldersCollectionItem.cs} (81%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersCollectionNonFungibleResourceItem.cs => ResourceHoldersCollectionNonFungibleResourceItem.cs} (85%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs => ResourceHoldersCollectionNonFungibleResourceItemAllOf.cs} (89%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersRequest.cs => ResourceHoldersRequest.cs} (94%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersRequestAllOf.cs => ResourceHoldersRequestAllOf.cs} (93%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersResourceType.cs => ResourceHoldersResourceType.cs} (98%) rename src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/{ResourceOwnersResponse.cs => ResourceHoldersResponse.cs} (92%) rename src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/{20240815152003_InitialCreate.Designer.cs => 20240816104539_InitialCreate.Designer.cs} (99%) rename src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/{20240815152003_InitialCreate.cs => 20240816104539_InitialCreate.cs} (99%) rename src/RadixDlt.NetworkGateway.PostgresIntegration/Models/{ResourceOwners.cs => ResourceHolder.cs} (98%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bf80a0c8..0d1555f2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ Release built: _not released yet_ - Added support for the Native Resource Details in the `/state/entity/details` endpoint, returned when the `native_resource_details` opt-in is enabled. - Brand-new `native_resource_details` property on the `details` property. - Includes **unit** redemption value for the Validator LSU token and the unit tokens of various Pools. -- Added new endpoint `/extensions/resource-owners/page` which returns information about all owners of the queried resource. +- Added new endpoint `/extensions/resource-holders/page` which returns information about all holders of the queried resource. ### Database changes - Replaced relationship-related columns (`*_entity_id`) in the `entities` table with more generic collection implementation using `correlated_entity_*` columns. @@ -31,7 +31,7 @@ Release built: _not released yet_ - Added new `unverified_standard_metadata_*` tables. They hold **some** of the metadata entries using db-friendly (normalized) model. See https://docs.radixdlt.com/docs/metadata-standards - Extended list of supported entity correlations in the `entities` table. - Renamed values of the `entity_relationship` enum type. -- Added new `resource_owners` table. It keeps information about all owners of each fungible and non fungible resource. +- Added new `resource_holders` table. It keeps information about all holders of each fungible and non fungible resource. ## 1.6.3 Release built: 06.08.2024 diff --git a/apps/GatewayApi/Controllers/ExtensionsController.cs b/apps/GatewayApi/Controllers/ExtensionsController.cs index ef9723e30..bad0ada01 100644 --- a/apps/GatewayApi/Controllers/ExtensionsController.cs +++ b/apps/GatewayApi/Controllers/ExtensionsController.cs @@ -74,9 +74,9 @@ namespace GatewayApi.Controllers; [Route("extensions")] public class ExtensionsController(IExtensionsHandler extensionsHandler) : ControllerBase { - [HttpPost("resource-owners/page")] - public async Task ResourceOwnersPage(GatewayModel.ResourceOwnersRequest request, CancellationToken token) + [HttpPost("resource-holders/page")] + public async Task ResourceHoldersPage(GatewayModel.ResourceHoldersRequest request, CancellationToken token) { - return await extensionsHandler.ResourceOwners(request, token); + return await extensionsHandler.ResourceHolders(request, token); } } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs index e6ed0e6d4..7a893c56c 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs @@ -74,11 +74,11 @@ namespace RadixDlt.NetworkGateway.GatewayApi.Handlers; internal class DefaultExtensionsHandler(IExtensionsQuerier extensionsQuerier, IOptionsSnapshot endpointConfiguration) : IExtensionsHandler { - public async Task ResourceOwners(GatewayModel.ResourceOwnersRequest request, CancellationToken token) + public async Task ResourceHolders(GatewayModel.ResourceHoldersRequest request, CancellationToken token) { - var cursor = GatewayModel.ResourceOwnersCursor.FromCursorString(request.Cursor); + var cursor = GatewayModel.ResourceHoldersCursor.FromCursorString(request.Cursor); - return await extensionsQuerier.ResourceOwners( + return await extensionsQuerier.ResourceHolders( (EntityAddress)request.ResourceAddress, endpointConfiguration.Value.ResolvePageSize(request.LimitPerPage), cursor, diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs index 2795f3e76..f41a17d35 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/IExtensionsHandler.cs @@ -70,5 +70,5 @@ namespace RadixDlt.NetworkGateway.GatewayApi.Handlers; public interface IExtensionsHandler { - Task ResourceOwners(GatewayModel.ResourceOwnersRequest request, CancellationToken token); + Task ResourceHolders(GatewayModel.ResourceHoldersRequest request, CancellationToken token); } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs index ee62fe387..e23cec33e 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Services/IExtensionsQuerier.cs @@ -75,9 +75,9 @@ namespace RadixDlt.NetworkGateway.GatewayApi.Services; public interface IExtensionsQuerier { - Task ResourceOwners( + Task ResourceHolders( EntityAddress resourceAddress, int limit, - GatewayModel.ResourceOwnersCursor? cursor, + GatewayModel.ResourceHoldersCursor? cursor, CancellationToken token = default); } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceOwnersValidator.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceHoldersValidator.cs similarity index 95% rename from src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceOwnersValidator.cs rename to src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceHoldersValidator.cs index 3efca3eb8..2393e0f8c 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceOwnersValidator.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Validators/ResourceHoldersValidator.cs @@ -67,9 +67,9 @@ namespace RadixDlt.NetworkGateway.GatewayApi.Validators; -internal class ResourceOwnersRequestValidator : AbstractValidator +internal class ResourceHoldersRequestValidator : AbstractValidator { - public ResourceOwnersRequestValidator(RadixAddressValidator radixAddressValidator) + public ResourceHoldersRequestValidator(RadixAddressValidator radixAddressValidator) { RuleFor(x => x.ResourceAddress) .NotNull() diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index f1fc87e5f..5a8f3b55c 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -1905,12 +1905,12 @@ paths: "4XX": $ref: "#/components/responses/ErrorResponse" - /extensions/resource-owners/page: + /extensions/resource-holders/page: post: - operationId: ResourceOwnersPage - summary: Get Resource Owners Page + operationId: ResourceHoldersPage + summary: Get Resource Holders Page description: | - Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. + Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. tags: @@ -1920,14 +1920,14 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/ResourceOwnersRequest" + $ref: "#/components/schemas/ResourceHoldersRequest" responses: "200": - description: Resource owners + description: Resource holders content: application/json: schema: - $ref: "#/components/schemas/ResourceOwnersResponse" + $ref: "#/components/schemas/ResourceHoldersResponse" "4XX": $ref: "#/components/responses/ErrorResponse" @@ -3147,7 +3147,7 @@ components: type: integer format: int64 - ResourceOwnersCollection: + ResourceHoldersCollection: allOf: - $ref: "#/components/schemas/ResultSetCursorMixin" - type: object @@ -3157,23 +3157,23 @@ components: items: type: array items: - $ref: "#/components/schemas/ResourceOwnersCollectionItem" + $ref: "#/components/schemas/ResourceHoldersCollectionItem" - ResourceOwnersResourceType: + ResourceHoldersResourceType: type: string enum: - FungibleResource - NonFungibleResource - ResourceOwnersCollectionItem: + ResourceHoldersCollectionItem: type: object required: - type - - owner_address + - holder_address - last_updated_at_state_version properties: type: - $ref: "#/components/schemas/ResourceOwnersResourceType" - owner_address: + $ref: "#/components/schemas/ResourceHoldersResourceType" + holder_address: $ref: "#/components/schemas/Address" last_updated_at_state_version: type: integer @@ -3181,13 +3181,13 @@ components: discriminator: propertyName: type mapping: - # Must match ResourceOwnersResourceType - FungibleResource: "#/components/schemas/ResourceOwnersCollectionFungibleResourceItem" - NonFungibleResource: "#/components/schemas/ResourceOwnersCollectionNonFungibleResourceItem" + # Must match ResourceHoldersResourceType + FungibleResource: "#/components/schemas/ResourceHoldersCollectionFungibleResourceItem" + NonFungibleResource: "#/components/schemas/ResourceHoldersCollectionNonFungibleResourceItem" - ResourceOwnersCollectionFungibleResourceItem: + ResourceHoldersCollectionFungibleResourceItem: allOf: - - $ref: "#/components/schemas/ResourceOwnersCollectionItem" + - $ref: "#/components/schemas/ResourceHoldersCollectionItem" - type: object required: - amount @@ -3196,9 +3196,9 @@ components: $ref: "#/components/schemas/BigDecimal" - ResourceOwnersCollectionNonFungibleResourceItem: + ResourceHoldersCollectionNonFungibleResourceItem: allOf: - - $ref: "#/components/schemas/ResourceOwnersCollectionItem" + - $ref: "#/components/schemas/ResourceHoldersCollectionItem" - type: object required: - non_fungible_ids_count @@ -4987,7 +4987,7 @@ components: validators: $ref: "#/components/schemas/ValidatorUptimeCollection" - ResourceOwnersRequest: + ResourceHoldersRequest: allOf: - $ref: "#/components/schemas/CursorLimitMixin" - type: object @@ -4995,9 +4995,9 @@ components: resource_address: $ref: "#/components/schemas/Address" - ResourceOwnersResponse: + ResourceHoldersResponse: allOf: - - $ref: "#/components/schemas/ResourceOwnersCollection" + - $ref: "#/components/schemas/ResourceHoldersCollection" # diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceOwnersCursor.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceHoldersCursor.cs similarity index 94% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceOwnersCursor.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceHoldersCursor.cs index 3508297e9..7d601e351 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceOwnersCursor.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/Model/ResourceHoldersCursor.cs @@ -67,7 +67,7 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model; [DataContract] -public sealed record ResourceOwnersCursor(long? IdBoundary, string BalanceBoundary) +public sealed record ResourceHoldersCursor(long? IdBoundary, string BalanceBoundary) { [DataMember(Name = "id", EmitDefaultValue = false)] public long? IdBoundary { get; set; } = IdBoundary; @@ -75,9 +75,9 @@ public sealed record ResourceOwnersCursor(long? IdBoundary, string BalanceBounda [DataMember(Name = "b", EmitDefaultValue = false)] public string BalanceBoundary { get; set; } = BalanceBoundary; - public static ResourceOwnersCursor FromCursorString(string cursorString) + public static ResourceHoldersCursor FromCursorString(string cursorString) { - return Serializations.FromBase64JsonOrDefault(cursorString); + return Serializations.FromBase64JsonOrDefault(cursorString); } public string ToCursorString() diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs index 927fde058..3b45bfa07 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Api/ExtensionsApi.cs @@ -92,26 +92,26 @@ public interface IExtensionsApiSync : IApiAccessor { #region Synchronous Operations /// - /// Get Resource Owners Page + /// Get Resource Holders Page /// /// - /// Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + /// Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call - /// - /// ResourceOwnersResponse - ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceOwnersRequest); + /// + /// ResourceHoldersResponse + ResourceHoldersResponse ResourceHoldersPage(ResourceHoldersRequest resourceHoldersRequest); /// - /// Get Resource Owners Page + /// Get Resource Holders Page /// /// - /// Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + /// Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call - /// - /// ApiResponse of ResourceOwnersResponse - ApiResponse ResourceOwnersPageWithHttpInfo(ResourceOwnersRequest resourceOwnersRequest); + /// + /// ApiResponse of ResourceHoldersResponse + ApiResponse ResourceHoldersPageWithHttpInfo(ResourceHoldersRequest resourceHoldersRequest); #endregion Synchronous Operations } @@ -122,28 +122,28 @@ public interface IExtensionsApiAsync : IApiAccessor { #region Asynchronous Operations /// - /// Get Resource Owners Page + /// Get Resource Holders Page /// /// - /// Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + /// Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call - /// + /// /// Cancellation Token to cancel the request. - /// Task of ResourceOwnersResponse - System.Threading.Tasks.Task ResourceOwnersPageAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// Task of ResourceHoldersResponse + System.Threading.Tasks.Task ResourceHoldersPageAsync(ResourceHoldersRequest resourceHoldersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// - /// Get Resource Owners Page + /// Get Resource Holders Page /// /// - /// Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + /// Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call - /// + /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ResourceOwnersResponse) - System.Threading.Tasks.Task> ResourceOwnersPageWithHttpInfoAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// Task of ApiResponse (ResourceHoldersResponse) + System.Threading.Tasks.Task> ResourceHoldersPageWithHttpInfoAsync(ResourceHoldersRequest resourceHoldersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } @@ -358,28 +358,28 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ExceptionFactory ExceptionFa } /// - /// Get Resource Owners Page Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + /// Get Resource Holders Page Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call - /// - /// ResourceOwnersResponse - public ResourceOwnersResponse ResourceOwnersPage(ResourceOwnersRequest resourceOwnersRequest) + /// + /// ResourceHoldersResponse + public ResourceHoldersResponse ResourceHoldersPage(ResourceHoldersRequest resourceHoldersRequest) { - RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = ResourceOwnersPageWithHttpInfo(resourceOwnersRequest); + RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = ResourceHoldersPageWithHttpInfo(resourceHoldersRequest); return localVarResponse.Data; } /// - /// Get Resource Owners Page Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + /// Get Resource Holders Page Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call - /// - /// ApiResponse of ResourceOwnersResponse - public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse ResourceOwnersPageWithHttpInfo(ResourceOwnersRequest resourceOwnersRequest) + /// + /// ApiResponse of ResourceHoldersResponse + public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse ResourceHoldersPageWithHttpInfo(ResourceHoldersRequest resourceHoldersRequest) { - // verify the required parameter 'resourceOwnersRequest' is set - if (resourceOwnersRequest == null) - throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceOwnersRequest' when calling ExtensionsApi->ResourceOwnersPage"); + // verify the required parameter 'resourceHoldersRequest' is set + if (resourceHoldersRequest == null) + throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceHoldersRequest' when calling ExtensionsApi->ResourceHoldersPage"); RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions localVarRequestOptions = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions(); @@ -398,15 +398,15 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse("/extensions/resource-owners/page", localVarRequestOptions, this.Configuration); + var localVarResponse = this.Client.Post("/extensions/resource-holders/page", localVarRequestOptions, this.Configuration); if (this.ExceptionFactory != null) { - Exception _exception = this.ExceptionFactory("ResourceOwnersPage", localVarResponse); + Exception _exception = this.ExceptionFactory("ResourceHoldersPage", localVarResponse); if (_exception != null) throw _exception; } @@ -414,30 +414,30 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse - /// Get Resource Owners Page Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + /// Get Resource Holders Page Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call - /// + /// /// Cancellation Token to cancel the request. - /// Task of ResourceOwnersResponse - public async System.Threading.Tasks.Task ResourceOwnersPageAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + /// Task of ResourceHoldersResponse + public async System.Threading.Tasks.Task ResourceHoldersPageAsync(ResourceHoldersRequest resourceHoldersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { - RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = await ResourceOwnersPageWithHttpInfoAsync(resourceOwnersRequest, cancellationToken).ConfigureAwait(false); + RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse localVarResponse = await ResourceHoldersPageWithHttpInfoAsync(resourceHoldersRequest, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; } /// - /// Get Resource Owners Page Returns list of all owners of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + /// Get Resource Holders Page Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. This endpoint operates only at the current state version, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. /// /// Thrown when fails to make API call - /// + /// /// Cancellation Token to cancel the request. - /// Task of ApiResponse (ResourceOwnersResponse) - public async System.Threading.Tasks.Task> ResourceOwnersPageWithHttpInfoAsync(ResourceOwnersRequest resourceOwnersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + /// Task of ApiResponse (ResourceHoldersResponse) + public async System.Threading.Tasks.Task> ResourceHoldersPageWithHttpInfoAsync(ResourceHoldersRequest resourceHoldersRequest, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { - // verify the required parameter 'resourceOwnersRequest' is set - if (resourceOwnersRequest == null) - throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceOwnersRequest' when calling ExtensionsApi->ResourceOwnersPage"); + // verify the required parameter 'resourceHoldersRequest' is set + if (resourceHoldersRequest == null) + throw new RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiException(400, "Missing required parameter 'resourceHoldersRequest' when calling ExtensionsApi->ResourceHoldersPage"); RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions localVarRequestOptions = new RadixDlt.NetworkGateway.GatewayApiSdk.Client.RequestOptions(); @@ -458,16 +458,16 @@ public RadixDlt.NetworkGateway.GatewayApiSdk.Client.ApiResponse("/extensions/resource-owners/page", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + var localVarResponse = await this.AsynchronousClient.PostAsync("/extensions/resource-holders/page", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); if (this.ExceptionFactory != null) { - Exception _exception = this.ExceptionFactory("ResourceOwnersPage", localVarResponse); + Exception _exception = this.ExceptionFactory("ResourceHoldersPage", localVarResponse); if (_exception != null) throw _exception; } diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollection.cs similarity index 92% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollection.cs index 0e9b6857b..fdc1dcfa0 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollection.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollection.cs @@ -90,28 +90,28 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersCollection + /// ResourceHoldersCollection /// - [DataContract(Name = "ResourceOwnersCollection")] - public partial class ResourceOwnersCollection : IEquatable + [DataContract(Name = "ResourceHoldersCollection")] + public partial class ResourceHoldersCollection : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// [JsonConstructorAttribute] - protected ResourceOwnersCollection() { } + protected ResourceHoldersCollection() { } /// - /// Initializes a new instance of the class. + /// 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 ResourceOwnersCollection(long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) + public ResourceHoldersCollection(long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) { // to ensure "items" is required (not null) if (items == null) { - throw new ArgumentNullException("items is a required property for ResourceOwnersCollection and cannot be null"); + throw new ArgumentNullException("items is a required property for ResourceHoldersCollection and cannot be null"); } this.Items = items; this.TotalCount = totalCount; @@ -136,7 +136,7 @@ protected ResourceOwnersCollection() { } /// Gets or Sets Items /// [DataMember(Name = "items", IsRequired = true, EmitDefaultValue = true)] - public List Items { get; set; } + public List Items { get; set; } /// /// Returns the string presentation of the object @@ -145,7 +145,7 @@ protected ResourceOwnersCollection() { } public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ResourceOwnersCollection {\n"); + sb.Append("class ResourceHoldersCollection {\n"); sb.Append(" TotalCount: ").Append(TotalCount).Append("\n"); sb.Append(" NextCursor: ").Append(NextCursor).Append("\n"); sb.Append(" Items: ").Append(Items).Append("\n"); @@ -169,15 +169,15 @@ public virtual string ToJson() /// Boolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersCollection); + return this.Equals(input as ResourceHoldersCollection); } /// - /// Returns true if ResourceOwnersCollection instances are equal + /// Returns true if ResourceHoldersCollection instances are equal /// - /// Instance of ResourceOwnersCollection to be compared + /// Instance of ResourceHoldersCollection to be compared /// Boolean - public bool Equals(ResourceOwnersCollection input) + public bool Equals(ResourceHoldersCollection input) { if (input == null) { diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionAllOf.cs similarity index 90% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionAllOf.cs index 5dd99b6f8..21f8d343a 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionAllOf.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionAllOf.cs @@ -90,26 +90,26 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersCollectionAllOf + /// ResourceHoldersCollectionAllOf /// - [DataContract(Name = "ResourceOwnersCollection_allOf")] - public partial class ResourceOwnersCollectionAllOf : IEquatable + [DataContract(Name = "ResourceHoldersCollection_allOf")] + public partial class ResourceHoldersCollectionAllOf : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// [JsonConstructorAttribute] - protected ResourceOwnersCollectionAllOf() { } + protected ResourceHoldersCollectionAllOf() { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// items (required). - public ResourceOwnersCollectionAllOf(List items = default(List)) + public ResourceHoldersCollectionAllOf(List items = default(List)) { // to ensure "items" is required (not null) if (items == null) { - throw new ArgumentNullException("items is a required property for ResourceOwnersCollectionAllOf and cannot be null"); + throw new ArgumentNullException("items is a required property for ResourceHoldersCollectionAllOf and cannot be null"); } this.Items = items; } @@ -118,7 +118,7 @@ protected ResourceOwnersCollectionAllOf() { } /// Gets or Sets Items /// [DataMember(Name = "items", IsRequired = true, EmitDefaultValue = true)] - public List Items { get; set; } + public List Items { get; set; } /// /// Returns the string presentation of the object @@ -127,7 +127,7 @@ protected ResourceOwnersCollectionAllOf() { } public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ResourceOwnersCollectionAllOf {\n"); + sb.Append("class ResourceHoldersCollectionAllOf {\n"); sb.Append(" Items: ").Append(Items).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -149,15 +149,15 @@ public virtual string ToJson() /// Boolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersCollectionAllOf); + return this.Equals(input as ResourceHoldersCollectionAllOf); } /// - /// Returns true if ResourceOwnersCollectionAllOf instances are equal + /// Returns true if ResourceHoldersCollectionAllOf instances are equal /// - /// Instance of ResourceOwnersCollectionAllOf to be compared + /// Instance of ResourceHoldersCollectionAllOf to be compared /// Boolean - public bool Equals(ResourceOwnersCollectionAllOf input) + public bool Equals(ResourceHoldersCollectionAllOf input) { if (input == null) { diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionFungibleResourceItem.cs similarity index 85% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionFungibleResourceItem.cs index 770a4f0b8..b91e00c75 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionFungibleResourceItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionFungibleResourceItem.cs @@ -91,32 +91,32 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersCollectionFungibleResourceItem + /// ResourceHoldersCollectionFungibleResourceItem /// - [DataContract(Name = "ResourceOwnersCollectionFungibleResourceItem")] + [DataContract(Name = "ResourceHoldersCollectionFungibleResourceItem")] [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionFungibleResourceItem), "FungibleResource")] - [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionNonFungibleResourceItem), "NonFungibleResource")] - public partial class ResourceOwnersCollectionFungibleResourceItem : ResourceOwnersCollectionItem, IEquatable + [JsonSubtypes.KnownSubType(typeof(ResourceHoldersCollectionFungibleResourceItem), "FungibleResource")] + [JsonSubtypes.KnownSubType(typeof(ResourceHoldersCollectionNonFungibleResourceItem), "NonFungibleResource")] + public partial class ResourceHoldersCollectionFungibleResourceItem : ResourceHoldersCollectionItem, IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// [JsonConstructorAttribute] - protected ResourceOwnersCollectionFungibleResourceItem() { } + protected ResourceHoldersCollectionFungibleResourceItem() { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// String-encoded decimal representing the amount of a related fungible resource. (required). - /// type (required) (default to ResourceOwnersResourceType.FungibleResource). - /// Bech32m-encoded human readable version of the address. (required). + /// type (required) (default to ResourceHoldersResourceType.FungibleResource). + /// Bech32m-encoded human readable version of the address. (required). /// lastUpdatedAtStateVersion (required). - public ResourceOwnersCollectionFungibleResourceItem(string amount = default(string), ResourceOwnersResourceType type = ResourceOwnersResourceType.FungibleResource, string ownerAddress = default(string), long lastUpdatedAtStateVersion = default(long)) : base(type, ownerAddress, lastUpdatedAtStateVersion) + public ResourceHoldersCollectionFungibleResourceItem(string amount = default(string), ResourceHoldersResourceType type = ResourceHoldersResourceType.FungibleResource, string holderAddress = default(string), long lastUpdatedAtStateVersion = default(long)) : base(type, holderAddress, lastUpdatedAtStateVersion) { // to ensure "amount" is required (not null) if (amount == null) { - throw new ArgumentNullException("amount is a required property for ResourceOwnersCollectionFungibleResourceItem and cannot be null"); + throw new ArgumentNullException("amount is a required property for ResourceHoldersCollectionFungibleResourceItem and cannot be null"); } this.Amount = amount; } @@ -135,7 +135,7 @@ protected ResourceOwnersCollectionFungibleResourceItem() { } public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ResourceOwnersCollectionFungibleResourceItem {\n"); + sb.Append("class ResourceHoldersCollectionFungibleResourceItem {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); sb.Append(" Amount: ").Append(Amount).Append("\n"); sb.Append("}\n"); @@ -158,15 +158,15 @@ public override string ToJson() /// Boolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersCollectionFungibleResourceItem); + return this.Equals(input as ResourceHoldersCollectionFungibleResourceItem); } /// - /// Returns true if ResourceOwnersCollectionFungibleResourceItem instances are equal + /// Returns true if ResourceHoldersCollectionFungibleResourceItem instances are equal /// - /// Instance of ResourceOwnersCollectionFungibleResourceItem to be compared + /// Instance of ResourceHoldersCollectionFungibleResourceItem to be compared /// Boolean - public bool Equals(ResourceOwnersCollectionFungibleResourceItem input) + public bool Equals(ResourceHoldersCollectionFungibleResourceItem input) { if (input == null) { diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionItem.cs similarity index 81% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionItem.cs index 408afd968..22a904ab8 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionItem.cs @@ -91,42 +91,42 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersCollectionItem + /// ResourceHoldersCollectionItem /// - [DataContract(Name = "ResourceOwnersCollectionItem")] + [DataContract(Name = "ResourceHoldersCollectionItem")] [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionFungibleResourceItem), "FungibleResource")] - [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionNonFungibleResourceItem), "NonFungibleResource")] - [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionFungibleResourceItem), "ResourceOwnersCollectionFungibleResourceItem")] - [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionNonFungibleResourceItem), "ResourceOwnersCollectionNonFungibleResourceItem")] - public partial class ResourceOwnersCollectionItem : IEquatable + [JsonSubtypes.KnownSubType(typeof(ResourceHoldersCollectionFungibleResourceItem), "FungibleResource")] + [JsonSubtypes.KnownSubType(typeof(ResourceHoldersCollectionNonFungibleResourceItem), "NonFungibleResource")] + [JsonSubtypes.KnownSubType(typeof(ResourceHoldersCollectionFungibleResourceItem), "ResourceHoldersCollectionFungibleResourceItem")] + [JsonSubtypes.KnownSubType(typeof(ResourceHoldersCollectionNonFungibleResourceItem), "ResourceHoldersCollectionNonFungibleResourceItem")] + public partial class ResourceHoldersCollectionItem : IEquatable { /// /// Gets or Sets Type /// [DataMember(Name = "type", IsRequired = true, EmitDefaultValue = true)] - public ResourceOwnersResourceType Type { get; set; } + public ResourceHoldersResourceType Type { get; set; } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// [JsonConstructorAttribute] - protected ResourceOwnersCollectionItem() { } + protected ResourceHoldersCollectionItem() { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// type (required). - /// Bech32m-encoded human readable version of the address. (required). + /// Bech32m-encoded human readable version of the address. (required). /// lastUpdatedAtStateVersion (required). - public ResourceOwnersCollectionItem(ResourceOwnersResourceType type = default(ResourceOwnersResourceType), string ownerAddress = default(string), long lastUpdatedAtStateVersion = default(long)) + public ResourceHoldersCollectionItem(ResourceHoldersResourceType type = default(ResourceHoldersResourceType), string holderAddress = default(string), long lastUpdatedAtStateVersion = default(long)) { this.Type = type; - // to ensure "ownerAddress" is required (not null) - if (ownerAddress == null) + // to ensure "holderAddress" is required (not null) + if (holderAddress == null) { - throw new ArgumentNullException("ownerAddress is a required property for ResourceOwnersCollectionItem and cannot be null"); + throw new ArgumentNullException("holderAddress is a required property for ResourceHoldersCollectionItem and cannot be null"); } - this.OwnerAddress = ownerAddress; + this.HolderAddress = holderAddress; this.LastUpdatedAtStateVersion = lastUpdatedAtStateVersion; } @@ -134,8 +134,8 @@ protected ResourceOwnersCollectionItem() { } /// Bech32m-encoded human readable version of the address. /// /// Bech32m-encoded human readable version of the address. - [DataMember(Name = "owner_address", IsRequired = true, EmitDefaultValue = true)] - public string OwnerAddress { get; set; } + [DataMember(Name = "holder_address", IsRequired = true, EmitDefaultValue = true)] + public string HolderAddress { get; set; } /// /// Gets or Sets LastUpdatedAtStateVersion @@ -150,9 +150,9 @@ protected ResourceOwnersCollectionItem() { } public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ResourceOwnersCollectionItem {\n"); + sb.Append("class ResourceHoldersCollectionItem {\n"); sb.Append(" Type: ").Append(Type).Append("\n"); - sb.Append(" OwnerAddress: ").Append(OwnerAddress).Append("\n"); + sb.Append(" HolderAddress: ").Append(HolderAddress).Append("\n"); sb.Append(" LastUpdatedAtStateVersion: ").Append(LastUpdatedAtStateVersion).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -174,15 +174,15 @@ public virtual string ToJson() /// Boolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersCollectionItem); + return this.Equals(input as ResourceHoldersCollectionItem); } /// - /// Returns true if ResourceOwnersCollectionItem instances are equal + /// Returns true if ResourceHoldersCollectionItem instances are equal /// - /// Instance of ResourceOwnersCollectionItem to be compared + /// Instance of ResourceHoldersCollectionItem to be compared /// Boolean - public bool Equals(ResourceOwnersCollectionItem input) + public bool Equals(ResourceHoldersCollectionItem input) { if (input == null) { @@ -194,9 +194,9 @@ public bool Equals(ResourceOwnersCollectionItem input) this.Type.Equals(input.Type) ) && ( - this.OwnerAddress == input.OwnerAddress || - (this.OwnerAddress != null && - this.OwnerAddress.Equals(input.OwnerAddress)) + this.HolderAddress == input.HolderAddress || + (this.HolderAddress != null && + this.HolderAddress.Equals(input.HolderAddress)) ) && ( this.LastUpdatedAtStateVersion == input.LastUpdatedAtStateVersion || @@ -214,9 +214,9 @@ public override int GetHashCode() { int hashCode = 41; hashCode = (hashCode * 59) + this.Type.GetHashCode(); - if (this.OwnerAddress != null) + if (this.HolderAddress != null) { - hashCode = (hashCode * 59) + this.OwnerAddress.GetHashCode(); + hashCode = (hashCode * 59) + this.HolderAddress.GetHashCode(); } hashCode = (hashCode * 59) + this.LastUpdatedAtStateVersion.GetHashCode(); return hashCode; diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionNonFungibleResourceItem.cs similarity index 85% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionNonFungibleResourceItem.cs index 7b354149d..494db1a68 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItem.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionNonFungibleResourceItem.cs @@ -91,27 +91,27 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersCollectionNonFungibleResourceItem + /// ResourceHoldersCollectionNonFungibleResourceItem /// - [DataContract(Name = "ResourceOwnersCollectionNonFungibleResourceItem")] + [DataContract(Name = "ResourceHoldersCollectionNonFungibleResourceItem")] [JsonConverter(typeof(JsonSubtypes), "type")] - [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionFungibleResourceItem), "FungibleResource")] - [JsonSubtypes.KnownSubType(typeof(ResourceOwnersCollectionNonFungibleResourceItem), "NonFungibleResource")] - public partial class ResourceOwnersCollectionNonFungibleResourceItem : ResourceOwnersCollectionItem, IEquatable + [JsonSubtypes.KnownSubType(typeof(ResourceHoldersCollectionFungibleResourceItem), "FungibleResource")] + [JsonSubtypes.KnownSubType(typeof(ResourceHoldersCollectionNonFungibleResourceItem), "NonFungibleResource")] + public partial class ResourceHoldersCollectionNonFungibleResourceItem : ResourceHoldersCollectionItem, IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// [JsonConstructorAttribute] - protected ResourceOwnersCollectionNonFungibleResourceItem() { } + protected ResourceHoldersCollectionNonFungibleResourceItem() { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// nonFungibleIdsCount (required). - /// type (required) (default to ResourceOwnersResourceType.NonFungibleResource). - /// Bech32m-encoded human readable version of the address. (required). + /// type (required) (default to ResourceHoldersResourceType.NonFungibleResource). + /// Bech32m-encoded human readable version of the address. (required). /// lastUpdatedAtStateVersion (required). - public ResourceOwnersCollectionNonFungibleResourceItem(long nonFungibleIdsCount = default(long), ResourceOwnersResourceType type = ResourceOwnersResourceType.NonFungibleResource, string ownerAddress = default(string), long lastUpdatedAtStateVersion = default(long)) : base(type, ownerAddress, lastUpdatedAtStateVersion) + public ResourceHoldersCollectionNonFungibleResourceItem(long nonFungibleIdsCount = default(long), ResourceHoldersResourceType type = ResourceHoldersResourceType.NonFungibleResource, string holderAddress = default(string), long lastUpdatedAtStateVersion = default(long)) : base(type, holderAddress, lastUpdatedAtStateVersion) { this.NonFungibleIdsCount = nonFungibleIdsCount; } @@ -129,7 +129,7 @@ protected ResourceOwnersCollectionNonFungibleResourceItem() { } public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ResourceOwnersCollectionNonFungibleResourceItem {\n"); + sb.Append("class ResourceHoldersCollectionNonFungibleResourceItem {\n"); sb.Append(" ").Append(base.ToString().Replace("\n", "\n ")).Append("\n"); sb.Append(" NonFungibleIdsCount: ").Append(NonFungibleIdsCount).Append("\n"); sb.Append("}\n"); @@ -152,15 +152,15 @@ public override string ToJson() /// Boolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersCollectionNonFungibleResourceItem); + return this.Equals(input as ResourceHoldersCollectionNonFungibleResourceItem); } /// - /// Returns true if ResourceOwnersCollectionNonFungibleResourceItem instances are equal + /// Returns true if ResourceHoldersCollectionNonFungibleResourceItem instances are equal /// - /// Instance of ResourceOwnersCollectionNonFungibleResourceItem to be compared + /// Instance of ResourceHoldersCollectionNonFungibleResourceItem to be compared /// Boolean - public bool Equals(ResourceOwnersCollectionNonFungibleResourceItem input) + public bool Equals(ResourceHoldersCollectionNonFungibleResourceItem input) { if (input == null) { diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionNonFungibleResourceItemAllOf.cs similarity index 89% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionNonFungibleResourceItemAllOf.cs index 67bc808f8..1f5fa0e65 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersCollectionNonFungibleResourceItemAllOf.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersCollectionNonFungibleResourceItemAllOf.cs @@ -90,21 +90,21 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersCollectionNonFungibleResourceItemAllOf + /// ResourceHoldersCollectionNonFungibleResourceItemAllOf /// - [DataContract(Name = "ResourceOwnersCollectionNonFungibleResourceItem_allOf")] - public partial class ResourceOwnersCollectionNonFungibleResourceItemAllOf : IEquatable + [DataContract(Name = "ResourceHoldersCollectionNonFungibleResourceItem_allOf")] + public partial class ResourceHoldersCollectionNonFungibleResourceItemAllOf : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// [JsonConstructorAttribute] - protected ResourceOwnersCollectionNonFungibleResourceItemAllOf() { } + protected ResourceHoldersCollectionNonFungibleResourceItemAllOf() { } /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// nonFungibleIdsCount (required). - public ResourceOwnersCollectionNonFungibleResourceItemAllOf(long nonFungibleIdsCount = default(long)) + public ResourceHoldersCollectionNonFungibleResourceItemAllOf(long nonFungibleIdsCount = default(long)) { this.NonFungibleIdsCount = nonFungibleIdsCount; } @@ -122,7 +122,7 @@ protected ResourceOwnersCollectionNonFungibleResourceItemAllOf() { } public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ResourceOwnersCollectionNonFungibleResourceItemAllOf {\n"); + sb.Append("class ResourceHoldersCollectionNonFungibleResourceItemAllOf {\n"); sb.Append(" NonFungibleIdsCount: ").Append(NonFungibleIdsCount).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -144,15 +144,15 @@ public virtual string ToJson() /// Boolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersCollectionNonFungibleResourceItemAllOf); + return this.Equals(input as ResourceHoldersCollectionNonFungibleResourceItemAllOf); } /// - /// Returns true if ResourceOwnersCollectionNonFungibleResourceItemAllOf instances are equal + /// Returns true if ResourceHoldersCollectionNonFungibleResourceItemAllOf instances are equal /// - /// Instance of ResourceOwnersCollectionNonFungibleResourceItemAllOf to be compared + /// Instance of ResourceHoldersCollectionNonFungibleResourceItemAllOf to be compared /// Boolean - public bool Equals(ResourceOwnersCollectionNonFungibleResourceItemAllOf input) + public bool Equals(ResourceHoldersCollectionNonFungibleResourceItemAllOf input) { if (input == null) { diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersRequest.cs similarity index 94% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersRequest.cs index ccaffbb7b..a4ebf69be 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequest.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersRequest.cs @@ -90,18 +90,18 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersRequest + /// ResourceHoldersRequest /// - [DataContract(Name = "ResourceOwnersRequest")] - public partial class ResourceOwnersRequest : IEquatable + [DataContract(Name = "ResourceHoldersRequest")] + public partial class ResourceHoldersRequest : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// This cursor allows forward pagination, by providing the cursor from the previous request.. /// The page size requested.. /// Bech32m-encoded human readable version of the address.. - public ResourceOwnersRequest(string cursor = default(string), int? limitPerPage = default(int?), string resourceAddress = default(string)) + public ResourceHoldersRequest(string cursor = default(string), int? limitPerPage = default(int?), string resourceAddress = default(string)) { this.Cursor = cursor; this.LimitPerPage = limitPerPage; @@ -136,7 +136,7 @@ public partial class ResourceOwnersRequest : IEquatable public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ResourceOwnersRequest {\n"); + sb.Append("class ResourceHoldersRequest {\n"); sb.Append(" Cursor: ").Append(Cursor).Append("\n"); sb.Append(" LimitPerPage: ").Append(LimitPerPage).Append("\n"); sb.Append(" ResourceAddress: ").Append(ResourceAddress).Append("\n"); @@ -160,15 +160,15 @@ public virtual string ToJson() /// Boolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersRequest); + return this.Equals(input as ResourceHoldersRequest); } /// - /// Returns true if ResourceOwnersRequest instances are equal + /// Returns true if ResourceHoldersRequest instances are equal /// - /// Instance of ResourceOwnersRequest to be compared + /// Instance of ResourceHoldersRequest to be compared /// Boolean - public bool Equals(ResourceOwnersRequest input) + public bool Equals(ResourceHoldersRequest input) { if (input == null) { diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersRequestAllOf.cs similarity index 93% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersRequestAllOf.cs index d97055c21..38a8a55bd 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersRequestAllOf.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersRequestAllOf.cs @@ -90,16 +90,16 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersRequestAllOf + /// ResourceHoldersRequestAllOf /// - [DataContract(Name = "ResourceOwnersRequest_allOf")] - public partial class ResourceOwnersRequestAllOf : IEquatable + [DataContract(Name = "ResourceHoldersRequest_allOf")] + public partial class ResourceHoldersRequestAllOf : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// /// Bech32m-encoded human readable version of the address.. - public ResourceOwnersRequestAllOf(string resourceAddress = default(string)) + public ResourceHoldersRequestAllOf(string resourceAddress = default(string)) { this.ResourceAddress = resourceAddress; } @@ -118,7 +118,7 @@ public partial class ResourceOwnersRequestAllOf : IEquatableBoolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersRequestAllOf); + return this.Equals(input as ResourceHoldersRequestAllOf); } /// - /// Returns true if ResourceOwnersRequestAllOf instances are equal + /// Returns true if ResourceHoldersRequestAllOf instances are equal /// - /// Instance of ResourceOwnersRequestAllOf to be compared + /// Instance of ResourceHoldersRequestAllOf to be compared /// Boolean - public bool Equals(ResourceOwnersRequestAllOf input) + public bool Equals(ResourceHoldersRequestAllOf input) { if (input == null) { diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersResourceType.cs similarity index 98% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersResourceType.cs index 7a037d3af..f126dfd64 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResourceType.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersResourceType.cs @@ -90,10 +90,10 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// Defines ResourceOwnersResourceType + /// Defines ResourceHoldersResourceType /// [JsonConverter(typeof(StringEnumConverter))] - public enum ResourceOwnersResourceType + public enum ResourceHoldersResourceType { /// /// Enum FungibleResource for value: FungibleResource diff --git a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersResponse.cs similarity index 92% rename from src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs rename to src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersResponse.cs index 59957ff35..eadf629fd 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceOwnersResponse.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApiSdk/generated/Model/ResourceHoldersResponse.cs @@ -90,28 +90,28 @@ namespace RadixDlt.NetworkGateway.GatewayApiSdk.Model { /// - /// ResourceOwnersResponse + /// ResourceHoldersResponse /// - [DataContract(Name = "ResourceOwnersResponse")] - public partial class ResourceOwnersResponse : IEquatable + [DataContract(Name = "ResourceHoldersResponse")] + public partial class ResourceHoldersResponse : IEquatable { /// - /// Initializes a new instance of the class. + /// Initializes a new instance of the class. /// [JsonConstructorAttribute] - protected ResourceOwnersResponse() { } + protected ResourceHoldersResponse() { } /// - /// Initializes a new instance of the class. + /// 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 ResourceOwnersResponse(long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) + public ResourceHoldersResponse(long? totalCount = default(long?), string nextCursor = default(string), List items = default(List)) { // to ensure "items" is required (not null) if (items == null) { - throw new ArgumentNullException("items is a required property for ResourceOwnersResponse and cannot be null"); + throw new ArgumentNullException("items is a required property for ResourceHoldersResponse and cannot be null"); } this.Items = items; this.TotalCount = totalCount; @@ -136,7 +136,7 @@ protected ResourceOwnersResponse() { } /// Gets or Sets Items /// [DataMember(Name = "items", IsRequired = true, EmitDefaultValue = true)] - public List Items { get; set; } + public List Items { get; set; } /// /// Returns the string presentation of the object @@ -145,7 +145,7 @@ protected ResourceOwnersResponse() { } public override string ToString() { StringBuilder sb = new StringBuilder(); - sb.Append("class ResourceOwnersResponse {\n"); + sb.Append("class ResourceHoldersResponse {\n"); sb.Append(" TotalCount: ").Append(TotalCount).Append("\n"); sb.Append(" NextCursor: ").Append(NextCursor).Append("\n"); sb.Append(" Items: ").Append(Items).Append("\n"); @@ -169,15 +169,15 @@ public virtual string ToJson() /// Boolean public override bool Equals(object input) { - return this.Equals(input as ResourceOwnersResponse); + return this.Equals(input as ResourceHoldersResponse); } /// - /// Returns true if ResourceOwnersResponse instances are equal + /// Returns true if ResourceHoldersResponse instances are equal /// - /// Instance of ResourceOwnersResponse to be compared + /// Instance of ResourceHoldersResponse to be compared /// Boolean - public bool Equals(ResourceOwnersResponse input) + public bool Equals(ResourceHoldersResponse input) { if (input == null) { diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs index d0598bbc7..e87d39462 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/CommonDbContext.cs @@ -174,7 +174,7 @@ internal abstract class CommonDbContext : DbContext public DbSet UnverifiedStandardMetadataEntryHistory => Set(); - public DbSet ResourceOwners => Set(); + public DbSet ResourceHolders => Set(); public CommonDbContext(DbContextOptions options) : base(options) @@ -634,12 +634,12 @@ private static void HookupHistory(ModelBuilder modelBuilder) .HasIndex(e => new { e.EntityId, e.Discriminator, e.FromStateVersion }); modelBuilder - .Entity() + .Entity() .HasIndex(e => new { e.EntityId, e.ResourceEntityId }) .IsUnique(); modelBuilder - .Entity() + .Entity() .HasIndex(e => new { e.EntityId, e.ResourceEntityId, e.Balance }); } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index b9bc3227e..844ae41d7 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -1438,7 +1438,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, } } - var resourceOwnersToAdd = new Dictionary(); + var resourceHoldersToAdd = new Dictionary(); foreach (var x in entityResourceAggregatedVaultsHistoryToAdd) { @@ -1451,11 +1451,11 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, _ => throw new ArgumentOutOfRangeException(nameof(x), x, null), }; - resourceOwnersToAdd.AddOrUpdate( - new ResourceOwnersLookup(x.EntityId, x.ResourceEntityId), - _ => new ResourceOwners + resourceHoldersToAdd.AddOrUpdate( + new ResourceHoldersLookup(x.EntityId, x.ResourceEntityId), + _ => new ResourceHolder { - Id = sequences.ResourceOwnersSequence++, + Id = sequences.ResourceHoldersSequence++, EntityId = x.EntityId, ResourceEntityId = x.ResourceEntityId, Balance = balance, @@ -1527,7 +1527,7 @@ void AggregateEntityResourceVaultInternal(long entityId, long resourceEntityId, rowsInserted += await writeHelper.CopyResourceEntitySupplyHistory(resourceEntitySupplyHistoryToAdd, token); rowsInserted += await writeHelper.CopyNonFungibleDataSchemaHistory(nonFungibleSchemaHistoryToAdd, token); rowsInserted += await writeHelper.CopyKeyValueStoreSchemaHistory(keyValueStoreSchemaHistoryToAdd, token); - rowsInserted += await writeHelper.CopyResourceOwners(resourceOwnersToAdd.Values, token); + rowsInserted += await writeHelper.CopyResourceHolders(resourceHoldersToAdd.Values, token); rowsInserted += await entityStateProcessor.SaveEntities(); rowsInserted += await entityMetadataProcessor.SaveEntities(); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ReadHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ReadHelper.cs index c5c6370d2..670780ca5 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ReadHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/ReadHelper.cs @@ -441,7 +441,7 @@ public async Task LoadSequences(CancellationToken token) nextval('account_authorized_depositor_aggregate_history_id_seq') AS AccountAuthorizedDepositorAggregateHistorySequence, nextval('unverified_standard_metadata_aggregate_history_id_seq') AS UnverifiedStandardMetadataAggregateHistorySequence, nextval('unverified_standard_metadata_entry_history_id_seq') AS UnverifiedStandardMetadataEntryHistorySequence, - nextval('resource_owners_id_seq') AS ResourceOwnersSequence + nextval('resource_holders_id_seq') AS ResourceHoldersSequence ", cancellationToken: token); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs index ca41cea33..fdaeed7c1 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/Records.cs @@ -106,4 +106,4 @@ internal record struct NonFungibleStoreLookup(long NonFungibleEntityId, long Sta internal record struct NonFungibleIdLookup(long ResourceEntityId, string NonFungibleId); -internal record struct ResourceOwnersLookup(long ResourceEntityId, long EntityId); +internal record struct ResourceHoldersLookup(long ResourceEntityId, long EntityId); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/SequencesHolder.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/SequencesHolder.cs index 4339ba339..cfdbc737c 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/SequencesHolder.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/SequencesHolder.cs @@ -148,5 +148,5 @@ internal class SequencesHolder public long UnverifiedStandardMetadataEntryHistorySequence { get; set; } - public long ResourceOwnersSequence { get; set; } + public long ResourceHoldersSequence { get; set; } } diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs index 41b19a514..b5014abf8 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/WriteHelper.cs @@ -735,7 +735,7 @@ await _connection.BeginBinaryImportAsync( return entities.Count; } - public async Task CopyResourceOwners(ICollection entities, CancellationToken token) + public async Task CopyResourceHolders(ICollection entities, CancellationToken token) { if (!entities.Any()) { @@ -746,15 +746,15 @@ public async Task CopyResourceOwners(ICollection entities, await using var createTempTableCommand = _connection.CreateCommand(); createTempTableCommand.CommandText = @" -CREATE TEMP TABLE tmp_resource_owners -(LIKE resource_owners INCLUDING DEFAULTS) +CREATE TEMP TABLE tmp_resource_holders +(LIKE resource_holders INCLUDING DEFAULTS) ON COMMIT DROP"; await createTempTableCommand.ExecuteNonQueryAsync(token); await using var writer = await _connection.BeginBinaryImportAsync( - "COPY tmp_resource_owners (id, entity_id, resource_entity_id, balance, last_updated_at_state_version) FROM STDIN (FORMAT BINARY)", + "COPY tmp_resource_holders (id, entity_id, resource_entity_id, balance, last_updated_at_state_version) FROM STDIN (FORMAT BINARY)", token); foreach (var e in entities) @@ -772,8 +772,8 @@ await _connection.BeginBinaryImportAsync( await using var mergeCommand = _connection.CreateCommand(); mergeCommand.CommandText = @" -MERGE INTO resource_owners ro -USING tmp_resource_owners tmp +MERGE INTO resource_holders ro +USING tmp_resource_holders tmp ON ro.entity_id = tmp.entity_id AND ro.resource_entity_id = tmp.resource_entity_id WHEN MATCHED AND tmp.balance = 0 THEN DELETE WHEN MATCHED AND tmp.balance != 0 THEN UPDATE SET balance = tmp.balance, last_updated_at_state_version = tmp.last_updated_at_state_version @@ -781,7 +781,7 @@ USING tmp_resource_owners tmp await mergeCommand.ExecuteNonQueryAsync(token); - await _observers.ForEachAsync(x => x.StageCompleted(nameof(CopyResourceOwners), Stopwatch.GetElapsedTime(sw), entities.Count)); + await _observers.ForEachAsync(x => x.StageCompleted(nameof(CopyResourceHolders), Stopwatch.GetElapsedTime(sw), entities.Count)); return entities.Count; } @@ -834,7 +834,7 @@ public async Task UpdateSequences(SequencesHolder sequences, CancellationToken t setval('account_authorized_depositor_aggregate_history_id_seq', @accountAuthorizedDepositorAggregateHistorySequence), setval('unverified_standard_metadata_aggregate_history_id_seq', @unverifiedStandardMetadataAggregateHistorySequence), setval('unverified_standard_metadata_entry_history_id_seq', @unverifiedStandardMetadataEntryHistorySequence), - setval('resource_owners_id_seq', @resourceOwnersSequence) + setval('resource_holders_id_seq', @resourceHoldersSequence) ", parameters: new { @@ -879,7 +879,7 @@ public async Task UpdateSequences(SequencesHolder sequences, CancellationToken t accountAuthorizedDepositorAggregateHistorySequence = sequences.AccountAuthorizedDepositorAggregateHistorySequence, unverifiedStandardMetadataAggregateHistorySequence = sequences.UnverifiedStandardMetadataAggregateHistorySequence, unverifiedStandardMetadataEntryHistorySequence = sequences.UnverifiedStandardMetadataEntryHistorySequence, - resourceOwnersSequence = sequences.ResourceOwnersSequence, + resourceHoldersSequence = sequences.ResourceHoldersSequence, }, cancellationToken: token); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.Designer.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.Designer.cs similarity index 99% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.Designer.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.Designer.cs index c43e3b755..479937d46 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.Designer.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.Designer.cs @@ -81,7 +81,7 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Migrations { [DbContext(typeof(MigrationsDbContext))] - [Migration("20240815152003_InitialCreate")] + [Migration("20240816104539_InitialCreate")] partial class InitialCreate { /// @@ -1557,7 +1557,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.ToTable("resource_entity_supply_history"); }); - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners", b => + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceHolder", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1590,7 +1590,7 @@ protected override void BuildTargetModel(ModelBuilder modelBuilder) b.HasIndex("EntityId", "ResourceEntityId", "Balance"); - b.ToTable("resource_owners"); + b.ToTable("resource_holders"); }); modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SchemaEntryAggregateHistory", b => diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.cs similarity index 99% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.cs index 8001927b8..b0598805d 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240815152003_InitialCreate.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/20240816104539_InitialCreate.cs @@ -755,7 +755,7 @@ protected override void Up(MigrationBuilder migrationBuilder) }); migrationBuilder.CreateTable( - name: "resource_owners", + name: "resource_holders", columns: table => new { id = table.Column(type: "bigint", nullable: false) @@ -767,7 +767,7 @@ protected override void Up(MigrationBuilder migrationBuilder) }, constraints: table => { - table.PrimaryKey("PK_resource_owners", x => x.id); + table.PrimaryKey("PK_resource_holders", x => x.id); }); migrationBuilder.CreateTable( @@ -1255,14 +1255,14 @@ protected override void Up(MigrationBuilder migrationBuilder) columns: new[] { "resource_entity_id", "from_state_version" }); migrationBuilder.CreateIndex( - name: "IX_resource_owners_entity_id_resource_entity_id", - table: "resource_owners", + name: "IX_resource_holders_entity_id_resource_entity_id", + table: "resource_holders", columns: new[] { "entity_id", "resource_entity_id" }, unique: true); migrationBuilder.CreateIndex( - name: "IX_resource_owners_entity_id_resource_entity_id_balance", - table: "resource_owners", + name: "IX_resource_holders_entity_id_resource_entity_id_balance", + table: "resource_holders", columns: new[] { "entity_id", "resource_entity_id", "balance" }); migrationBuilder.CreateIndex( @@ -1430,7 +1430,7 @@ protected override void Down(MigrationBuilder migrationBuilder) name: "resource_entity_supply_history"); migrationBuilder.DropTable( - name: "resource_owners"); + name: "resource_holders"); migrationBuilder.DropTable( name: "schema_entry_aggregate_history"); diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql index d495318d6..09a1d8d8e 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/IdempotentApplyMigrations.sql @@ -9,7 +9,7 @@ START TRANSACTION; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TYPE account_default_deposit_rule AS ENUM ('accept', 'reject', 'allow_existing'); CREATE TYPE account_resource_preference_rule AS ENUM ('allowed', 'disallowed'); CREATE TYPE authorized_depositor_badge_type AS ENUM ('resource', 'non_fungible'); @@ -37,7 +37,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE account_authorized_depositor_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -50,7 +50,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE account_authorized_depositor_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -66,7 +66,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE account_default_deposit_rule_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -79,7 +79,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE account_locker_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -93,7 +93,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE account_locker_entry_resource_vault_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -107,7 +107,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE account_locker_entry_touch_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -119,7 +119,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE account_resource_preference_rule_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -132,7 +132,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE account_resource_preference_rule_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -147,7 +147,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE component_method_royalty_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -160,7 +160,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE component_method_royalty_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -175,7 +175,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entities ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -201,7 +201,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_metadata_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -214,7 +214,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_metadata_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -230,7 +230,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_resource_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -246,7 +246,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_resource_aggregated_vaults_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -262,7 +262,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_resource_vault_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -276,7 +276,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_role_assignments_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -290,7 +290,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_role_assignments_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -306,7 +306,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_role_assignments_owner_role_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -319,7 +319,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE entity_vault_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -338,7 +338,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE key_value_store_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -351,7 +351,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE key_value_store_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -366,7 +366,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE key_value_store_schema_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -386,7 +386,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE ledger_transaction_markers ( id bigint GENERATED BY DEFAULT AS IDENTITY, state_version bigint NOT NULL, @@ -406,7 +406,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE ledger_transactions ( state_version bigint NOT NULL, epoch bigint NOT NULL, @@ -454,7 +454,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE non_fungible_id_data_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -469,7 +469,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE non_fungible_id_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -482,7 +482,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE non_fungible_id_location_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -495,7 +495,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE non_fungible_schema_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -511,7 +511,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE package_blueprint_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -524,7 +524,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE package_blueprint_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -544,7 +544,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE package_code_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -557,7 +557,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE package_code_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -573,7 +573,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE pending_transactions ( id bigint GENERATED BY DEFAULT AS IDENTITY, payload_hash text NOT NULL, @@ -601,7 +601,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE resource_entity_supply_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -616,21 +616,21 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN - CREATE TABLE resource_owners ( + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + CREATE TABLE resource_holders ( id bigint GENERATED BY DEFAULT AS IDENTITY, entity_id bigint NOT NULL, resource_entity_id bigint NOT NULL, balance numeric(1000) NOT NULL, last_updated_at_state_version bigint NOT NULL, - CONSTRAINT "PK_resource_owners" PRIMARY KEY (id) + CONSTRAINT "PK_resource_holders" PRIMARY KEY (id) ); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE schema_entry_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -643,7 +643,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE schema_entry_definition ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -657,7 +657,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE state_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -676,7 +676,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE unverified_standard_metadata_aggregate_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -689,7 +689,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE unverified_standard_metadata_entry_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -706,7 +706,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE validator_cumulative_emission_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -722,7 +722,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE validator_public_key_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -736,7 +736,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE pending_transaction_payloads ( id bigint GENERATED BY DEFAULT AS IDENTITY, pending_transaction_id bigint, @@ -749,7 +749,7 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE TABLE validator_active_set_history ( id bigint GENERATED BY DEFAULT AS IDENTITY, from_state_version bigint NOT NULL, @@ -764,520 +764,520 @@ END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_aggregate_history_account_enti~" ON account_authorized_depositor_aggregate_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_~1" ON account_authorized_depositor_entry_history (account_entity_id, resource_entity_id, non_fungible_id, from_state_version) WHERE discriminator = 'non_fungible'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_~2" ON account_authorized_depositor_entry_history (account_entity_id, resource_entity_id, from_state_version) WHERE discriminator = 'resource'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_account_authorized_depositor_entry_history_account_entity_i~" ON account_authorized_depositor_entry_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_account_default_deposit_rule_history_account_entity_id_from~" ON account_default_deposit_rule_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE UNIQUE INDEX "IX_account_locker_entry_definition_account_locker_entity_id_ac~" ON account_locker_entry_definition (account_locker_entity_id, account_entity_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE UNIQUE INDEX "IX_account_locker_entry_resource_vault_definition_account_lock~" ON account_locker_entry_resource_vault_definition (account_locker_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_account_locker_entry_touch_history_account_locker_definitio~" ON account_locker_entry_touch_history (account_locker_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_account_resource_preference_rule_aggregate_history_account_~" ON account_resource_preference_rule_aggregate_history (account_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_account_resource_preference_rule_entry_history_account_enti~" ON account_resource_preference_rule_entry_history (account_entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_aggregate_history_entity_id_from_s~" ON component_method_royalty_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_entry_history_entity_id_from_state~" ON component_method_royalty_entry_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_component_method_royalty_entry_history_entity_id_method_nam~" ON component_method_royalty_entry_history (entity_id, method_name, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE UNIQUE INDEX "IX_entities_address" ON entities (address); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entities_from_state_version" ON entities (from_state_version) WHERE discriminator = 'global_validator'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_metadata_aggregate_history_entity_id_from_state_vers~" ON entity_metadata_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_metadata_history_entity_id_key_from_state_version" ON entity_metadata_history (entity_id, key, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_resource_aggregate_history_entity_id_from_state_vers~" ON entity_resource_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_resource_aggregated_vaults_history_entity_id_resourc~" ON entity_resource_aggregated_vaults_history (entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_resource_vault_aggregate_history_entity_id_resource_~" ON entity_resource_vault_aggregate_history (entity_id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_aggregate_history_entity_id_from_st~" ON entity_role_assignments_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_entry_history_entity_id_key_role_ke~" ON entity_role_assignments_entry_history (entity_id, key_role, key_module, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_role_assignments_owner_role_history_entity_id_from_s~" ON entity_role_assignments_owner_role_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_global_entity_id_from_state_version" ON entity_vault_history (global_entity_id, from_state_version) WHERE is_royalty_vault = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_global_entity_id_vault_entity_id_from_~" ON entity_vault_history (global_entity_id, vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_id_resource_entity_id_from_state_versi~" ON entity_vault_history (id, resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_owner_entity_id_from_state_version" ON entity_vault_history (owner_entity_id, from_state_version) WHERE is_royalty_vault = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_owner_entity_id_vault_entity_id_from_s~" ON entity_vault_history (owner_entity_id, vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_entity_vault_history_vault_entity_id_from_state_version" ON entity_vault_history (vault_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_definition_key_value_store_entity_id_~" ON key_value_store_entry_definition (key_value_store_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_definition_key_value_store_entity_id~1" ON key_value_store_entry_definition (key_value_store_entity_id, key); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_key_value_store_entry_history_key_value_store_entry_definit~" ON key_value_store_entry_history (key_value_store_entry_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_key_value_store_schema_history_key_value_store_entity_id_fr~" ON key_value_store_schema_history (key_value_store_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_entity_id_state_version" ON ledger_transaction_markers (entity_id, state_version) WHERE discriminator = 'event_global_emitter'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_entity_id_state_version1" ON ledger_transaction_markers (entity_id, state_version) WHERE discriminator = 'affected_global_entity'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_event_type_entity_id_state_versi~" ON ledger_transaction_markers (event_type, entity_id, state_version) WHERE discriminator = 'event'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_manifest_class" ON ledger_transaction_markers (manifest_class, state_version) WHERE discriminator = 'manifest_class'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_manifest_class_is_most_specific" ON ledger_transaction_markers (manifest_class, state_version) WHERE discriminator = 'manifest_class' and is_most_specific = true; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_operation_type_entity_id_state_v~" ON ledger_transaction_markers (operation_type, entity_id, state_version) WHERE discriminator = 'manifest_address'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_origin_type_state_version" ON ledger_transaction_markers (origin_type, state_version) WHERE discriminator = 'origin'; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transaction_markers_state_version" ON ledger_transaction_markers (state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE UNIQUE INDEX "IX_ledger_transactions_epoch_round_in_epoch" ON ledger_transactions (epoch, round_in_epoch) WHERE index_in_round = 0; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transactions_intent_hash" ON ledger_transactions USING hash (intent_hash) WHERE intent_hash IS NOT NULL; END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_ledger_transactions_round_timestamp" ON ledger_transactions (round_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_data_history_non_fungible_id_definition_id_~" ON non_fungible_id_data_history (non_fungible_id_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_definition_non_fungible_resource_entity_id_~" ON non_fungible_id_definition (non_fungible_resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE UNIQUE INDEX "IX_non_fungible_id_definition_non_fungible_resource_entity_id~1" ON non_fungible_id_definition (non_fungible_resource_entity_id, non_fungible_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_non_fungible_id_location_history_non_fungible_id_definition~" ON non_fungible_id_location_history (non_fungible_id_definition_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_non_fungible_schema_history_resource_entity_id_from_state_v~" ON non_fungible_schema_history (resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_aggregate_history_package_entity_id_from_~" ON package_blueprint_aggregate_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_history_package_entity_id_from_state_vers~" ON package_blueprint_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_package_blueprint_history_package_entity_id_name_version_fr~" ON package_blueprint_history (package_entity_id, name, version, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_package_code_aggregate_history_package_entity_id_from_state~" ON package_code_aggregate_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_package_code_history_package_entity_id_from_state_version" ON package_code_history (package_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE UNIQUE INDEX "IX_pending_transaction_payloads_pending_transaction_id" ON pending_transaction_payloads (pending_transaction_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_first_submitted_to_gateway_timestamp" ON pending_transactions (first_submitted_to_gateway_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_intent_hash" ON pending_transactions (intent_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE UNIQUE INDEX "IX_pending_transactions_payload_hash" ON pending_transactions (payload_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_pending_transactions_resubmit_from_timestamp" ON pending_transactions (resubmit_from_timestamp); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_resource_entity_supply_history_resource_entity_id_from_stat~" ON resource_entity_supply_history (resource_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN - CREATE UNIQUE INDEX "IX_resource_owners_entity_id_resource_entity_id" ON resource_owners (entity_id, resource_entity_id); + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + CREATE UNIQUE INDEX "IX_resource_holders_entity_id_resource_entity_id" ON resource_holders (entity_id, resource_entity_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN - CREATE INDEX "IX_resource_owners_entity_id_resource_entity_id_balance" ON resource_owners (entity_id, resource_entity_id, balance); + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN + CREATE INDEX "IX_resource_holders_entity_id_resource_entity_id_balance" ON resource_holders (entity_id, resource_entity_id, balance); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_schema_entry_aggregate_history_entity_id_from_state_version" ON schema_entry_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_schema_entry_definition_entity_id_schema_hash" ON schema_entry_definition (entity_id, schema_hash); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_state_history_entity_id_from_state_version" ON state_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_unverified_standard_metadata_aggregate_history_entity_id_fr~" ON unverified_standard_metadata_aggregate_history (entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_unverified_standard_metadata_entry_history_entity_id_discri~" ON unverified_standard_metadata_entry_history (entity_id, discriminator, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_epoch" ON validator_active_set_history (epoch); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_from_state_version" ON validator_active_set_history (from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_validator_active_set_history_validator_public_key_history_id" ON validator_active_set_history (validator_public_key_history_id); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_validator_cumulative_emission_history_validator_entity_id_e~" ON validator_cumulative_emission_history (validator_entity_id, epoch_number); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_validator_public_key_history_validator_entity_id_from_state~" ON validator_public_key_history (validator_entity_id, from_state_version); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN CREATE INDEX "IX_validator_public_key_history_validator_entity_id_key_type_k~" ON validator_public_key_history (validator_entity_id, key_type, key); END IF; END $EF$; DO $EF$ BEGIN - IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240815152003_InitialCreate') THEN + IF NOT EXISTS(SELECT 1 FROM "__EFMigrationsHistory" WHERE "MigrationId" = '20240816104539_InitialCreate') THEN INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion") - VALUES ('20240815152003_InitialCreate', '8.0.2'); + VALUES ('20240816104539_InitialCreate', '8.0.2'); END IF; END $EF$; COMMIT; diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs index 1cb3dd53d..41c32f112 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Migrations/MigrationsDbContextModelSnapshot.cs @@ -1554,7 +1554,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("resource_entity_supply_history"); }); - modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceOwners", b => + modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.ResourceHolder", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -1587,7 +1587,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("EntityId", "ResourceEntityId", "Balance"); - b.ToTable("resource_owners"); + b.ToTable("resource_holders"); }); modelBuilder.Entity("RadixDlt.NetworkGateway.PostgresIntegration.Models.SchemaEntryAggregateHistory", b => diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceHolder.cs similarity index 98% rename from src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs rename to src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceHolder.cs index 0db17b393..38ad77d52 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceOwners.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Models/ResourceHolder.cs @@ -68,8 +68,8 @@ namespace RadixDlt.NetworkGateway.PostgresIntegration.Models; -[Table("resource_owners")] -internal class ResourceOwners +[Table("resource_holders")] +internal class ResourceHolder { [Key] [Column("id")] diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs index 36d158e60..6dd4d8859 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/ExtensionsQuerier.cs @@ -82,7 +82,7 @@ internal class ExtensionsQuerier : IExtensionsQuerier private readonly ReadOnlyDbContext _dbContext; private readonly IDapperWrapper _dapperWrapper; - private record ResourceOwnersViewModel(long Id, EntityAddress EntityAddress, string Balance, long LastUpdatedAtStateVersion); + private record ResourceHoldersViewModel(long Id, EntityAddress EntityAddress, string Balance, long LastUpdatedAtStateVersion); public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapper) { @@ -90,10 +90,10 @@ public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapp _dapperWrapper = dapperWrapper; } - public async Task ResourceOwners( + public async Task ResourceHolders( EntityAddress resourceAddress, int limit, - GatewayModel.ResourceOwnersCursor? cursor, + GatewayModel.ResourceHoldersCursor? cursor, CancellationToken token = default) { var resourceEntity = await _dbContext @@ -111,9 +111,9 @@ public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapp throw new InvalidEntityException(resourceEntity.Address.ToString()); } - var totalCount = await _dbContext.ResourceOwners.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); + var totalCount = await _dbContext.ResourceHolders.CountAsync(x => x.ResourceEntityId == resourceEntity.Id, token); - var entriesAndOneMore = await _dapperWrapper.ToList( + var entriesAndOneMore = await _dapperWrapper.ToList( _dbContext, @" SELECT @@ -121,7 +121,7 @@ public ExtensionsQuerier(ReadOnlyDbContext dbContext, IDapperWrapper dapperWrapp e.address AS EntityAddress, CAST(ro.balance AS text) AS Balance, ro.last_updated_at_state_version AS LastUpdatedAtStateVersion -FROM resource_owners ro +FROM resource_holders ro INNER JOIN entities e ON ro.entity_id = e.id WHERE ro.resource_entity_id = @resourceEntityId @@ -141,7 +141,7 @@ ORDER BY (ro.balance, ro.entity_id) DESC var nextPageExists = entriesAndOneMore.Count == limit + 1 && lastElement != null; var nextCursor = nextPageExists - ? new GatewayModel.ResourceOwnersCursor(lastElement!.Id, TokenAmount.FromDecimalString(lastElement.Balance).ToString()).ToCursorString() + ? new GatewayModel.ResourceHoldersCursor(lastElement!.Id, TokenAmount.FromDecimalString(lastElement.Balance).ToString()).ToCursorString() : null; switch (resourceEntity) @@ -151,14 +151,14 @@ ORDER BY (ro.balance, ro.entity_id) DESC var castedResult = entriesAndOneMore .Take(limit) .Select( - x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionFungibleResourceItem( + x => (GatewayModel.ResourceHoldersCollectionItem)new GatewayModel.ResourceHoldersCollectionFungibleResourceItem( amount: TokenAmount.FromSubUnitsString(x.Balance).ToString(), - ownerAddress: x.EntityAddress, + holderAddress: x.EntityAddress, lastUpdatedAtStateVersion: x.LastUpdatedAtStateVersion) ) .ToList(); - return new GatewayModel.ResourceOwnersResponse(totalCount, nextCursor, castedResult); + return new GatewayModel.ResourceHoldersResponse(totalCount, nextCursor, castedResult); } case GlobalNonFungibleResourceEntity: @@ -166,14 +166,14 @@ ORDER BY (ro.balance, ro.entity_id) DESC var castedResult = entriesAndOneMore .Take(limit) .Select( - x => (GatewayModel.ResourceOwnersCollectionItem)new GatewayModel.ResourceOwnersCollectionNonFungibleResourceItem( + x => (GatewayModel.ResourceHoldersCollectionItem)new GatewayModel.ResourceHoldersCollectionNonFungibleResourceItem( nonFungibleIdsCount: long.Parse(TokenAmount.FromSubUnitsString(x.Balance).ToString()), - ownerAddress: x.EntityAddress, + holderAddress: x.EntityAddress, lastUpdatedAtStateVersion: x.LastUpdatedAtStateVersion) ) .ToList(); - return new GatewayModel.ResourceOwnersResponse(totalCount, nextCursor, castedResult); + return new GatewayModel.ResourceHoldersResponse(totalCount, nextCursor, castedResult); } default: From 504fd4cfa977876f620083f6f4372388474ce207 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Fri, 16 Aug 2024 14:15:18 +0200 Subject: [PATCH 16/18] fix docs and change max page size to 1000. --- .../Configuration/EndpointOptions.cs | 5 ++++- .../Handlers/DefaultExtensionsHandler.cs | 2 +- .../gateway-api-schema.yaml | 12 +++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Configuration/EndpointOptions.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Configuration/EndpointOptions.cs index 0ca846331..e39e651b6 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Configuration/EndpointOptions.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Configuration/EndpointOptions.cs @@ -107,12 +107,15 @@ public sealed class EndpointOptions [ConfigurationKeyName("ValidatorsUptimePageSize")] public int ValidatorsUptimeMaxPageSize { get; set; } = 200; + [ConfigurationKeyName("ResourceHoldersMaxPageSize")] + public int ResourceHoldersMaxPageSize { get; set; } = 1000; + [ConfigurationKeyName("TransactionStreamMaxFilterCount")] public int TransactionStreamMaxFilterCount { get; set; } = 10; public int ResolvePageSize(int? requestPageSize) => ResolvePageSize(requestPageSize, DefaultPageSize, MaxPageSize); - public int ResolveNonFungibleIdsPageSize(int? requestPageSize) => ResolvePageSize(requestPageSize, DefaultNonFungibleIdsPageSize, MaxPageSize); + public int ResolveResourceHoldersPageSize(int? requestPageSize) => ResolvePageSize(requestPageSize, DefaultPageSize, ResourceHoldersMaxPageSize); public int ResolveHeavyPageSize(int? requestPageSize) => ResolvePageSize(requestPageSize, DefaultHeavyCollectionsPageSize, MaxHeavyCollectionsPageSize); diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs index 7a893c56c..acd4995f4 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs +++ b/src/RadixDlt.NetworkGateway.GatewayApi/Handlers/DefaultExtensionsHandler.cs @@ -80,7 +80,7 @@ internal class DefaultExtensionsHandler(IExtensionsQuerier extensionsQuerier, IO return await extensionsQuerier.ResourceHolders( (EntityAddress)request.ResourceAddress, - endpointConfiguration.Value.ResolvePageSize(request.LimitPerPage), + endpointConfiguration.Value.ResolveResourceHoldersPageSize(request.LimitPerPage), cursor, token); } diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index 5a8f3b55c..9082ce553 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -71,7 +71,7 @@ tags: - **Stream** (`/transaction/*`) - For reading committed transactions. - **State** (`/state/*`) - For reading the current or past ledger state of the network. - **Statistics** (`/statistics/*`) - For calculating particular statistics against the current or past ledger state of the network. - - **Extensions** (`/Extensions/*`) - For additional endpoints that do not fit into other categories. They do not support historical browsing. + - **Extensions** (`/Extensions/*`) - For endpoints that do not fit into other categories, for example, they may not support historic state. - name: Concepts x-displayName: Concepts x-traitTag: true # Don't display endpoints under this tag @@ -1199,7 +1199,7 @@ tags: description: Calculate particular statistics based on current or historic ledger state. - name: Extensions x-displayName: Extensions Endpoints - description: Additional endpoints that do not fit into other categories. + description: Endpoints that do not fit into other categories, for example, those which provide custom aggregation or indexing, or don't support historic state. paths: "/status/gateway-status": @@ -1910,9 +1910,11 @@ paths: operationId: ResourceHoldersPage summary: Get Resource Holders Page description: | - Returns list of all holders of a given resource, ordered by Amount (fungibles)/ Number of items (non fungibles) descending. - This endpoint operates only at the current state version, it is not possible to browse historical data. - Because of that, it is not possible to offer stable pagination as data constantly changes. Values might change, which might result in gaps or some entries being returned twice. + A paginated endpoint to discover which global entities hold the most of a given resource. + More specifically, it returns a page of global entities which hold the given resource, ordered descending by the total fungible balance / total count of non-fungibles stored in vaults in the state tree of that entity (excluding unclaimed royalty balances). + This endpoint operates only at the **current state version**, it is not possible to browse historical data. + Because of that, it is not possible to offer stable pagination as data constantly changes. Balances might change between pages being read, which might result in gaps or some entries being returned twice. + The default maximum page size is 1000. tags: - Extensions requestBody: From 0a3402d110a4aa17bff59c75cfa6b925adc2c0f0 Mon Sep 17 00:00:00 2001 From: David Edey Date: Fri, 16 Aug 2024 13:57:58 +0100 Subject: [PATCH 17/18] Clarify page size on the resource holders endpoint --- src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index 9082ce553..add022438 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -1914,7 +1914,7 @@ paths: More specifically, it returns a page of global entities which hold the given resource, ordered descending by the total fungible balance / total count of non-fungibles stored in vaults in the state tree of that entity (excluding unclaimed royalty balances). This endpoint operates only at the **current state version**, it is not possible to browse historical data. Because of that, it is not possible to offer stable pagination as data constantly changes. Balances might change between pages being read, which might result in gaps or some entries being returned twice. - The default maximum page size is 1000. +Under default Gateway configuration, up to 100 entries are returned per response. This can be increased up to 1000 entries per page with the `limit_per_page` parameter. tags: - Extensions requestBody: From 445f20d75999333d25ce7074bbd918e500999f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Pawelec?= Date: Fri, 16 Aug 2024 15:15:35 +0200 Subject: [PATCH 18/18] add example to resource holders request. --- src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml index add022438..892e63169 100644 --- a/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml +++ b/src/RadixDlt.NetworkGateway.GatewayApi/gateway-api-schema.yaml @@ -4996,6 +4996,9 @@ components: properties: resource_address: $ref: "#/components/schemas/Address" + example: + limit_per_page: 100 + resource_address: "" ResourceHoldersResponse: allOf: