From bf42778b9a40c02e53e15f0c59cc6f2616777635 Mon Sep 17 00:00:00 2001 From: David Edey Date: Wed, 3 Jan 2024 12:56:45 +0000 Subject: [PATCH 01/10] Add Discord link to README --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e21101397..a7482f7f1 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ The Babylon Gateway code is released under the [Radix License](LICENSE). Binarie For documentation on the Gateway API, see the [Gateway API docs](https://docs-babylon.radixdlt.com/main/apis/api-specification.html). +## Community Involvement + +If you have questions, suggestions or bug reports, please come to the [Network Gateway channel](https://discord.com/channels/417762285172555786/1149370695206318151) on the [Radix DLT Discord server](http://discord.gg/radixdlt). + ## Structure The system is in three main parts: From 1f99ebda7cca1f4ebfb35d51805747537674e5aa Mon Sep 17 00:00:00 2001 From: rvelaz Date: Wed, 3 Jan 2024 16:25:45 +0100 Subject: [PATCH 02/10] add Radix License 1.0 header to README --- README.md | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 79 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a7482f7f1..7dc939a3c 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,6 @@ This system is designed to be the Radix-run publicly exposed gateway into the Babylon Radix network. It is the successor to the [Olympia Gateway](https://github.com/radixdlt/radixdlt-network-gateway). -## License - -The Babylon Gateway code is released under the [Radix License](LICENSE). Binaries/Executable components are licensed under the [Radix Software EULA](http://www.radixdlt.com/terms/genericEULA). - ## Using the Gateway API For documentation on the Gateway API, see the [Gateway API docs](https://docs-babylon.radixdlt.com/main/apis/api-specification.html). @@ -52,3 +48,82 @@ Mandatory dependencies: Optional dependencies: * Prometheus - for metrics collection. + +## License + +The executable components of the Babylon Gateway Code are licensed under the [Radix Software EULA](http://www.radixdlt.com/terms/genericEULA). + +The Babylon Gateway Code is released under the [Radix License 1.0 (modified Apache 2.0)](LICENSE): + +``` +Copyright 2023 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: +https://www.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 artifacts 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 Licence. +``` From fca7f1f59272fa941bd6ca02482f9a9e6cc64355 Mon Sep 17 00:00:00 2001 From: AbstractFruitFactory Date: Fri, 12 Jan 2024 11:03:51 +0000 Subject: [PATCH 03/10] fix: load all non fungible resources --- sdk/typescript/lib/subapis/state.ts | 156 +++++++++++++++++++++------- 1 file changed, 121 insertions(+), 35 deletions(-) diff --git a/sdk/typescript/lib/subapis/state.ts b/sdk/typescript/lib/subapis/state.ts index 24c996ea5..41c5b6141 100644 --- a/sdk/typescript/lib/subapis/state.ts +++ b/sdk/typescript/lib/subapis/state.ts @@ -17,6 +17,7 @@ import { StateEntityDetailsResponseItem, StateEntityFungiblesPageResponse, StateEntityMetadataPageResponse, + StateEntityNonFungiblesPageResponse, StateNonFungibleDetailsResponseItem, StateNonFungibleIdsResponse, StateNonFungibleLocationResponseItem, @@ -62,14 +63,14 @@ export class State { constructor( public innerClient: StateApi, public configuration: RuntimeConfiguration - ) {} + ) { } /** * Get detailed information about entities together with vault aggregated fungible and non-fungible resources. * Returns an array or single item depending on input value. If array is passed, it will be split into chunks of 20 addresses * which will be requested separately and returned only if all requests are successful. * - * Calling this function will exhaust list of all fungible resources for each entity. + * Calling this function will exhaust list of all resources for each entity. * If any of the requests fail, the whole operation will fail. * * When requesting details for `internal_vault` entity, `non_fungible_resources` and `fungible_resources` will be defaulted to objects with empty arrays @@ -135,21 +136,20 @@ export class State { return isArray ? Promise.all( - (items as StateEntityDetailsVaultResponseItem[]).map((item) => - this.queryAllFungibles( - item, - ledgerState || { - state_version: ledger_state.state_version, - } - ) + (items as StateEntityDetailsVaultResponseItem[]).map((item) => + this.queryAllResources( + item, + ledgerState || { + state_version: ledger_state.state_version, + } ) - ) - : this.queryAllFungibles( - items[0] as StateEntityDetailsVaultResponseItem, - ledgerState || { - state_version: ledger_state.state_version, - } - ) + )) + : this.queryAllResources( + items[0] as StateEntityDetailsVaultResponseItem, + ledgerState || { + state_version: ledger_state.state_version, + } + ) } /** @@ -383,6 +383,57 @@ export class State { > } + private async getEntityNonFungiblesPageVaultAggregated( + entity: string, + nextCursor?: string | undefined, + ledgerState?: LedgerStateSelector + ): Promise< + ReplaceProperty< + StateEntityNonFungiblesPageResponse, + 'items', + NonFungibleResourcesCollectionItemVaultAggregated[] + > + > { + return this.innerClient.entityNonFungiblesPage({ + stateEntityNonFungiblesPageRequest: { + address: entity, + cursor: nextCursor, + aggregation_level: 'Vault', + at_ledger_state: ledgerState, + }, + }) as Promise< + ReplaceProperty< + StateEntityNonFungiblesPageResponse, + 'items', + NonFungibleResourcesCollectionItemVaultAggregated[] + > + > + } + + private ensureResourcesProperties( + response: StateEntityDetailsResponse + ): ReplaceProperty< + StateEntityDetailsResponse, + 'items', + StateEntityDetailsVaultResponseItem[] + > { + return { + ...response, + items: response.items.map((item) => ({ + ...item, + fungible_resources: item.fungible_resources || { + total_count: 0, + items: [], + }, + non_fungible_resources: item.non_fungible_resources || { + total_count: 0, + items: [], + }, + })) as StateEntityDetailsVaultResponseItem[], + } + } + + private async queryAllFungibles( stateEntityDetails: StateEntityDetailsVaultResponseItem, ledgerState?: LedgerStateSelector @@ -412,26 +463,61 @@ export class State { }) } - private ensureResourcesProperties( - response: StateEntityDetailsResponse - ): ReplaceProperty< - StateEntityDetailsResponse, - 'items', - StateEntityDetailsVaultResponseItem[] - > { - return { - ...response, - items: response.items.map((item) => ({ - ...item, - fungible_resources: item.fungible_resources || { - total_count: 0, - items: [], + + private async queryAllNonFungibles( + stateEntityDetails: StateEntityDetailsVaultResponseItem, + ledgerState?: LedgerStateSelector + ): Promise { + const nextCursor = stateEntityDetails.non_fungible_resources.next_cursor + + if (!nextCursor) return Promise.resolve(stateEntityDetails) + + const allNonFungibles = await exhaustPaginationWithLedgerState( + (cursor) => + this.getEntityNonFungiblesPageVaultAggregated( + stateEntityDetails.address, + cursor, + ledgerState + ), + nextCursor + ) + + return Promise.resolve({ + ...stateEntityDetails, + non_fungible_resources: { + items: [ + ...stateEntityDetails.non_fungible_resources.items, + ...allNonFungibles.aggregatedEntities, + ], + }, + }) + } + + private async queryAllResources( + stateEntityDetails: StateEntityDetailsVaultResponseItem, + ledgerState?: LedgerStateSelector + ): Promise { + const itemsWithAllFungibles = this.queryAllFungibles(stateEntityDetails, ledgerState) + const itemsWithAllNonFungibles = this.queryAllNonFungibles(stateEntityDetails, ledgerState) + + return Promise.all([itemsWithAllFungibles, itemsWithAllNonFungibles]).then((results) => { + return { + ...stateEntityDetails, + fungible_resources: { + ...stateEntityDetails.fungible_resources, + items: [ + ...stateEntityDetails.fungible_resources.items, + ...results[0].fungible_resources.items, + ], }, - non_fungible_resources: item.non_fungible_resources || { - total_count: 0, - items: [], + non_fungible_resources: { + ...stateEntityDetails.non_fungible_resources, + items: [ + ...stateEntityDetails.non_fungible_resources.items, + ...results[1].non_fungible_resources.items, + ], }, - })) as StateEntityDetailsVaultResponseItem[], - } + } + }) } } From 33a9832b84de3b40fa1d1eb98c815c64897daae4 Mon Sep 17 00:00:00 2001 From: AbstractFruitFactory Date: Fri, 12 Jan 2024 12:26:39 +0000 Subject: [PATCH 04/10] fix: returned resources --- sdk/typescript/lib/subapis/state.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/sdk/typescript/lib/subapis/state.ts b/sdk/typescript/lib/subapis/state.ts index 41c5b6141..0d2824c08 100644 --- a/sdk/typescript/lib/subapis/state.ts +++ b/sdk/typescript/lib/subapis/state.ts @@ -506,14 +506,12 @@ export class State { fungible_resources: { ...stateEntityDetails.fungible_resources, items: [ - ...stateEntityDetails.fungible_resources.items, ...results[0].fungible_resources.items, ], }, non_fungible_resources: { ...stateEntityDetails.non_fungible_resources, items: [ - ...stateEntityDetails.non_fungible_resources.items, ...results[1].non_fungible_resources.items, ], }, From 728d591d5c093392e3891a9d3fa8a512eadc37d5 Mon Sep 17 00:00:00 2001 From: AbstractFruitFactory Date: Fri, 12 Jan 2024 12:34:37 +0000 Subject: [PATCH 05/10] fix: pagination with ledger state --- .../lib/helpers/exhaust-pagination.ts | 24 ------------------- sdk/typescript/lib/subapis/state.ts | 19 +++++++++++---- 2 files changed, 14 insertions(+), 29 deletions(-) diff --git a/sdk/typescript/lib/helpers/exhaust-pagination.ts b/sdk/typescript/lib/helpers/exhaust-pagination.ts index fe5478cc8..ec7fd1e65 100644 --- a/sdk/typescript/lib/helpers/exhaust-pagination.ts +++ b/sdk/typescript/lib/helpers/exhaust-pagination.ts @@ -1,29 +1,5 @@ import { LedgerState } from '../generated' -/** - * Exhausts a paginated API resource and returns all the results. - */ -export const exhaustPagination = async ( - queryFunction: ( - cursor?: string - ) => Promise<{ items: T[]; next_cursor?: string | null }>, - start?: string -): Promise => { - let next_cursor: string | null | undefined = start - const aggregatedEntities: T[] = [] - - do { - const queryFunctionResponse: { - next_cursor?: string | null - items: T[] - } = await queryFunction(next_cursor) - aggregatedEntities.push(...queryFunctionResponse.items) - next_cursor = queryFunctionResponse.next_cursor - } while (next_cursor) - - return aggregatedEntities -} - /** * Exhausts a paginated API resource and returns all the results. */ diff --git a/sdk/typescript/lib/subapis/state.ts b/sdk/typescript/lib/subapis/state.ts index 0d2824c08..47789d579 100644 --- a/sdk/typescript/lib/subapis/state.ts +++ b/sdk/typescript/lib/subapis/state.ts @@ -1,6 +1,5 @@ import { chunk } from '../helpers/chunk' import { - exhaustPagination, exhaustPaginationWithLedgerState, } from '../helpers/exhaust-pagination' import { @@ -208,10 +207,10 @@ export class State { address: string, startCursor?: string ): Promise { - return exhaustPagination( + return exhaustPaginationWithLedgerState( this.getEntityMetadata.bind(this, address), startCursor - ) + ).then((res) => res.aggregatedEntities) } /** @@ -232,11 +231,20 @@ export class State { * Get list of all validators. This will iterate over returned cursors and aggregate all responses. */ async getAllValidators(start?: string): Promise { - return exhaustPagination(this.getValidators.bind(this), start) + return exhaustPaginationWithLedgerState((cursor?: string) => { + const v = this.getValidatorsWithLedgerState(cursor) + return v.then((res) => ({ + items: res.validators.items, + ledger_state: res.ledger_state, + next_cursor: res.validators.next_cursor + })) + }, start).then( + (res) => res.aggregatedEntities + ) } /** - * Get paged list of validators + * Get paged list of validators with ledger state * @param cursor */ async getValidatorsWithLedgerState(cursor?: string) { @@ -256,6 +264,7 @@ export class State { this.getValidatorsWithLedgerState(cursor).then((res) => ({ items: res.validators.items, ledger_state: res.ledger_state, + next_cursor: res.validators.next_cursor })), start ) From 4903cee8730d5400ea08877ce2beb2ff37255df3 Mon Sep 17 00:00:00 2001 From: Dawid Sowa Date: Mon, 15 Jan 2024 10:55:17 +0100 Subject: [PATCH 06/10] fix: propagate explicitMetadata & nonFungibleIncludeNfids --- sdk/typescript/lib/subapis/state.ts | 137 +++++++++------ sdk/typescript/test/state.test.ts | 247 ++++++++++++++++++++++++++++ 2 files changed, 334 insertions(+), 50 deletions(-) diff --git a/sdk/typescript/lib/subapis/state.ts b/sdk/typescript/lib/subapis/state.ts index 47789d579..955b2c1e8 100644 --- a/sdk/typescript/lib/subapis/state.ts +++ b/sdk/typescript/lib/subapis/state.ts @@ -1,7 +1,5 @@ import { chunk } from '../helpers/chunk' -import { - exhaustPaginationWithLedgerState, -} from '../helpers/exhaust-pagination' +import { exhaustPaginationWithLedgerState } from '../helpers/exhaust-pagination' import { EntityMetadataItem, FungibleResourcesCollection, @@ -62,7 +60,7 @@ export class State { constructor( public innerClient: StateApi, public configuration: RuntimeConfiguration - ) { } + ) {} /** * Get detailed information about entities together with vault aggregated fungible and non-fungible resources. @@ -135,20 +133,30 @@ export class State { return isArray ? Promise.all( - (items as StateEntityDetailsVaultResponseItem[]).map((item) => - this.queryAllResources( - item, - ledgerState || { - state_version: ledger_state.state_version, - } + (items as StateEntityDetailsVaultResponseItem[]).map((item) => + this.queryAllResources( + item, + { + explicitMetadata: options?.explicitMetadata ?? [], + nonFungibleIncludeNfids: + options?.nonFungibleIncludeNfids ?? true, + }, + ledgerState || { + state_version: ledger_state.state_version, + } + ) ) - )) + ) : this.queryAllResources( - items[0] as StateEntityDetailsVaultResponseItem, - ledgerState || { - state_version: ledger_state.state_version, - } - ) + items[0] as StateEntityDetailsVaultResponseItem, + { + explicitMetadata: options?.explicitMetadata ?? [], + nonFungibleIncludeNfids: options?.nonFungibleIncludeNfids ?? true, + }, + ledgerState || { + state_version: ledger_state.state_version, + } + ) } /** @@ -236,11 +244,9 @@ export class State { return v.then((res) => ({ items: res.validators.items, ledger_state: res.ledger_state, - next_cursor: res.validators.next_cursor + next_cursor: res.validators.next_cursor, })) - }, start).then( - (res) => res.aggregatedEntities - ) + }, start).then((res) => res.aggregatedEntities) } /** @@ -264,7 +270,7 @@ export class State { this.getValidatorsWithLedgerState(cursor).then((res) => ({ items: res.validators.items, ledger_state: res.ledger_state, - next_cursor: res.validators.next_cursor + next_cursor: res.validators.next_cursor, })), start ) @@ -367,8 +373,11 @@ export class State { private async getEntityFungiblesPageVaultAggregated( entity: string, - nextCursor?: string | undefined, - ledgerState?: LedgerStateSelector + options?: { + nextCursor?: string | undefined + ledgerState?: LedgerStateSelector + explicitMetadata?: string[] + } ): Promise< ReplaceProperty< StateEntityFungiblesPageResponse, @@ -379,9 +388,12 @@ export class State { return this.innerClient.entityFungiblesPage({ stateEntityFungiblesPageRequest: { address: entity, - cursor: nextCursor, + cursor: options?.nextCursor, aggregation_level: 'Vault', - at_ledger_state: ledgerState, + at_ledger_state: options?.ledgerState, + opt_ins: { + explicit_metadata: options?.explicitMetadata, + }, }, }) as Promise< ReplaceProperty< @@ -394,8 +406,12 @@ export class State { private async getEntityNonFungiblesPageVaultAggregated( entity: string, - nextCursor?: string | undefined, - ledgerState?: LedgerStateSelector + options?: { + cursor: string | undefined + ledgerState?: LedgerStateSelector + explicitMetadata?: string[] + nonFungibleIncludeNfids?: boolean + } ): Promise< ReplaceProperty< StateEntityNonFungiblesPageResponse, @@ -406,9 +422,13 @@ export class State { return this.innerClient.entityNonFungiblesPage({ stateEntityNonFungiblesPageRequest: { address: entity, - cursor: nextCursor, + cursor: options?.cursor, aggregation_level: 'Vault', - at_ledger_state: ledgerState, + at_ledger_state: options?.ledgerState, + opt_ins: { + explicit_metadata: options?.explicitMetadata, + non_fungible_include_nfids: options?.nonFungibleIncludeNfids, + }, }, }) as Promise< ReplaceProperty< @@ -442,9 +462,11 @@ export class State { } } - private async queryAllFungibles( stateEntityDetails: StateEntityDetailsVaultResponseItem, + options?: { + explicitMetadata?: string[] + }, ledgerState?: LedgerStateSelector ): Promise { const nextCursor = stateEntityDetails?.fungible_resources?.next_cursor @@ -453,11 +475,11 @@ export class State { const allFungibles = await exhaustPaginationWithLedgerState( (cursor) => - this.getEntityFungiblesPageVaultAggregated( - stateEntityDetails.address, - cursor, - ledgerState - ), + this.getEntityFungiblesPageVaultAggregated(stateEntityDetails.address, { + nextCursor: cursor, + ledgerState, + explicitMetadata: options?.explicitMetadata, + }), nextCursor ) @@ -472,9 +494,12 @@ export class State { }) } - private async queryAllNonFungibles( stateEntityDetails: StateEntityDetailsVaultResponseItem, + options?: { + explicitMetadata?: string[] + nonFungibleIncludeNfids?: boolean + }, ledgerState?: LedgerStateSelector ): Promise { const nextCursor = stateEntityDetails.non_fungible_resources.next_cursor @@ -485,8 +510,12 @@ export class State { (cursor) => this.getEntityNonFungiblesPageVaultAggregated( stateEntityDetails.address, - cursor, - ledgerState + { + cursor, + ledgerState, + explicitMetadata: options?.explicitMetadata, + nonFungibleIncludeNfids: options?.nonFungibleIncludeNfids, + } ), nextCursor ) @@ -504,27 +533,35 @@ export class State { private async queryAllResources( stateEntityDetails: StateEntityDetailsVaultResponseItem, + options?: { + explicitMetadata?: string[] + nonFungibleIncludeNfids?: boolean + }, ledgerState?: LedgerStateSelector ): Promise { - const itemsWithAllFungibles = this.queryAllFungibles(stateEntityDetails, ledgerState) - const itemsWithAllNonFungibles = this.queryAllNonFungibles(stateEntityDetails, ledgerState) + const itemsWithAllFungibles = this.queryAllFungibles( + stateEntityDetails, + options, + ledgerState + ) + const itemsWithAllNonFungibles = this.queryAllNonFungibles( + stateEntityDetails, + options, + ledgerState + ) - return Promise.all([itemsWithAllFungibles, itemsWithAllNonFungibles]).then((results) => { - return { + return Promise.all([itemsWithAllFungibles, itemsWithAllNonFungibles]).then( + (results) => ({ ...stateEntityDetails, fungible_resources: { ...stateEntityDetails.fungible_resources, - items: [ - ...results[0].fungible_resources.items, - ], + items: [...results[0].fungible_resources.items], }, non_fungible_resources: { ...stateEntityDetails.non_fungible_resources, - items: [ - ...results[1].non_fungible_resources.items, - ], + items: [...results[1].non_fungible_resources.items], }, - } - }) + }) + ) } } diff --git a/sdk/typescript/test/state.test.ts b/sdk/typescript/test/state.test.ts index 5e0cea217..06d6fa687 100644 --- a/sdk/typescript/test/state.test.ts +++ b/sdk/typescript/test/state.test.ts @@ -152,6 +152,253 @@ describe('State Subapi', () => { }, ]) }) + + it('should propagate explicit_metadata to fungbile paging requests', async () => { + // Arrange + const spy = jest.fn().mockImplementation((a) => { + if (a.includes('/state/entity/details')) { + return fetchResponseFactory({ + items: [ + { + address: 'address', + fungible_resources: { + items: [{ aggregation_level: 'Vault' }], + next_cursor: 'eyJvIjoxMDB9', + total_count: 2, + }, + non_fungible_resources: { + items: [{ aggregation_level: 'Vault' }], + total_count: 1, + }, + }, + ], + ledger_state: { + state_version: 1, + }, + })() + } else { + return fetchResponseFactory({ + items: [], + ledger_state: { + state_version: 1, + }, + })() + } + }) + const gatewayApi = GatewayApiClient.initialize({ + fetchApi: spy, + basePath: 'https://just-for-test.com', + maxAddressesCount: 1, + }) + + // Act + const response = await gatewayApi.state.getEntityDetailsVaultAggregated( + ['address'], + { + explicitMetadata: ['name'], + } + ) + + // Assert + expect(spy).toHaveBeenCalledTimes(2) + expect(spy.mock.calls).toEqual([ + [ + 'https://just-for-test.com/state/entity/details', + { + body: '{"opt_ins":{"ancestor_identities":false,"component_royalty_vault_balance":false,"package_royalty_vault_balance":false,"non_fungible_include_nfids":true,"explicit_metadata":["name"]},"addresses":["address"],"aggregation_level":"Vault"}', + credentials: undefined, + headers: { + 'Content-Type': 'application/json', + 'RDX-App-Dapp-Definition': 'Unknown', + 'RDX-App-Name': 'Unknown', + 'RDX-App-Version': 'Unknown', + 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', + 'RDX-Client-Version': '0.0.0', + }, + method: 'POST', + }, + ], + [ + 'https://just-for-test.com/state/entity/page/fungibles/', + { + body: '{"at_ledger_state":{"state_version":1},"cursor":"eyJvIjoxMDB9","address":"address","aggregation_level":"Vault","opt_ins":{"explicit_metadata":["name"]}}', + credentials: undefined, + headers: { + 'Content-Type': 'application/json', + 'RDX-App-Dapp-Definition': 'Unknown', + 'RDX-App-Name': 'Unknown', + 'RDX-App-Version': 'Unknown', + 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', + 'RDX-Client-Version': '0.0.0', + }, + method: 'POST', + }, + ], + ]) + }) + + it('should propagate explicit_metadata & nonFungibleIncludeNfids to non-fungbile paging requests', async () => { + // Arrange + const spy = jest.fn().mockImplementation((a) => { + if (a.includes('/state/entity/details')) { + return fetchResponseFactory({ + items: [ + { + address: 'address', + fungible_resources: { + items: [{ aggregation_level: 'Vault' }], + total_count: 2, + }, + non_fungible_resources: { + items: [{ aggregation_level: 'Vault' }], + next_cursor: 'eyJvIjoxMDB9', + total_count: 2, + }, + }, + ], + ledger_state: { + state_version: 1, + }, + })() + } else { + return fetchResponseFactory({ + items: [], + ledger_state: { + state_version: 1, + }, + })() + } + }) + const gatewayApi = GatewayApiClient.initialize({ + fetchApi: spy, + basePath: 'https://just-for-test.com', + maxAddressesCount: 1, + }) + + // Act + await gatewayApi.state.getEntityDetailsVaultAggregated(['address'], { + explicitMetadata: ['name'], + }) + + // Assert + expect(spy).toHaveBeenCalledTimes(2) + expect(spy.mock.calls).toEqual([ + [ + 'https://just-for-test.com/state/entity/details', + { + body: '{"opt_ins":{"ancestor_identities":false,"component_royalty_vault_balance":false,"package_royalty_vault_balance":false,"non_fungible_include_nfids":true,"explicit_metadata":["name"]},"addresses":["address"],"aggregation_level":"Vault"}', + credentials: undefined, + headers: { + 'Content-Type': 'application/json', + 'RDX-App-Dapp-Definition': 'Unknown', + 'RDX-App-Name': 'Unknown', + 'RDX-App-Version': 'Unknown', + 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', + 'RDX-Client-Version': '0.0.0', + }, + method: 'POST', + }, + ], + [ + 'https://just-for-test.com/state/entity/page/non-fungibles/', + { + body: '{"at_ledger_state":{"state_version":1},"cursor":"eyJvIjoxMDB9","address":"address","aggregation_level":"Vault","opt_ins":{"non_fungible_include_nfids":true,"explicit_metadata":["name"]}}', + credentials: undefined, + headers: { + 'Content-Type': 'application/json', + 'RDX-App-Dapp-Definition': 'Unknown', + 'RDX-App-Name': 'Unknown', + 'RDX-App-Version': 'Unknown', + 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', + 'RDX-Client-Version': '0.0.0', + }, + method: 'POST', + }, + ], + ]) + }) + + it('should false nonFungibleIncludeNfids to non-fungbile paging requests', async () => { + // Arrange + const spy = jest.fn().mockImplementation((a) => { + if (a.includes('/state/entity/details')) { + return fetchResponseFactory({ + items: [ + { + address: 'address', + fungible_resources: { + items: [{ aggregation_level: 'Vault' }], + total_count: 2, + }, + non_fungible_resources: { + items: [{ aggregation_level: 'Vault' }], + next_cursor: 'eyJvIjoxMDB9', + total_count: 2, + }, + }, + ], + ledger_state: { + state_version: 1, + }, + })() + } else { + return fetchResponseFactory({ + items: [], + ledger_state: { + state_version: 1, + }, + })() + } + }) + const gatewayApi = GatewayApiClient.initialize({ + fetchApi: spy, + basePath: 'https://just-for-test.com', + maxAddressesCount: 1, + }) + + // Act + await gatewayApi.state.getEntityDetailsVaultAggregated(['address'], { + explicitMetadata: ['name'], + nonFungibleIncludeNfids: false, + }) + + // Assert + expect(spy).toHaveBeenCalledTimes(2) + expect(spy.mock.calls).toEqual([ + [ + 'https://just-for-test.com/state/entity/details', + { + body: '{"opt_ins":{"ancestor_identities":false,"component_royalty_vault_balance":false,"package_royalty_vault_balance":false,"non_fungible_include_nfids":false,"explicit_metadata":["name"]},"addresses":["address"],"aggregation_level":"Vault"}', + credentials: undefined, + headers: { + 'Content-Type': 'application/json', + 'RDX-App-Dapp-Definition': 'Unknown', + 'RDX-App-Name': 'Unknown', + 'RDX-App-Version': 'Unknown', + 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', + 'RDX-Client-Version': '0.0.0', + }, + method: 'POST', + }, + ], + [ + 'https://just-for-test.com/state/entity/page/non-fungibles/', + { + body: '{"at_ledger_state":{"state_version":1},"cursor":"eyJvIjoxMDB9","address":"address","aggregation_level":"Vault","opt_ins":{"non_fungible_include_nfids":false,"explicit_metadata":["name"]}}', + credentials: undefined, + headers: { + 'Content-Type': 'application/json', + 'RDX-App-Dapp-Definition': 'Unknown', + 'RDX-App-Name': 'Unknown', + 'RDX-App-Version': 'Unknown', + 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', + 'RDX-Client-Version': '0.0.0', + }, + method: 'POST', + }, + ], + ]) + }) }) describe('getNonFungibleData', () => { From b01e1fca43cbab9aa2dd911fd18d080a5936dddd Mon Sep 17 00:00:00 2001 From: Dawid Sowa Date: Mon, 15 Jan 2024 11:49:50 +0100 Subject: [PATCH 07/10] test: loosen unit test matchers --- sdk/typescript/test/state.test.ts | 56 ++++--------------------------- 1 file changed, 7 insertions(+), 49 deletions(-) diff --git a/sdk/typescript/test/state.test.ts b/sdk/typescript/test/state.test.ts index 06d6fa687..f48609cb0 100644 --- a/sdk/typescript/test/state.test.ts +++ b/sdk/typescript/test/state.test.ts @@ -207,14 +207,7 @@ describe('State Subapi', () => { { body: '{"opt_ins":{"ancestor_identities":false,"component_royalty_vault_balance":false,"package_royalty_vault_balance":false,"non_fungible_include_nfids":true,"explicit_metadata":["name"]},"addresses":["address"],"aggregation_level":"Vault"}', credentials: undefined, - headers: { - 'Content-Type': 'application/json', - 'RDX-App-Dapp-Definition': 'Unknown', - 'RDX-App-Name': 'Unknown', - 'RDX-App-Version': 'Unknown', - 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', - 'RDX-Client-Version': '0.0.0', - }, + headers: expect.anything(), method: 'POST', }, ], @@ -223,14 +216,7 @@ describe('State Subapi', () => { { body: '{"at_ledger_state":{"state_version":1},"cursor":"eyJvIjoxMDB9","address":"address","aggregation_level":"Vault","opt_ins":{"explicit_metadata":["name"]}}', credentials: undefined, - headers: { - 'Content-Type': 'application/json', - 'RDX-App-Dapp-Definition': 'Unknown', - 'RDX-App-Name': 'Unknown', - 'RDX-App-Version': 'Unknown', - 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', - 'RDX-Client-Version': '0.0.0', - }, + headers: expect.anything(), method: 'POST', }, ], @@ -288,14 +274,7 @@ describe('State Subapi', () => { { body: '{"opt_ins":{"ancestor_identities":false,"component_royalty_vault_balance":false,"package_royalty_vault_balance":false,"non_fungible_include_nfids":true,"explicit_metadata":["name"]},"addresses":["address"],"aggregation_level":"Vault"}', credentials: undefined, - headers: { - 'Content-Type': 'application/json', - 'RDX-App-Dapp-Definition': 'Unknown', - 'RDX-App-Name': 'Unknown', - 'RDX-App-Version': 'Unknown', - 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', - 'RDX-Client-Version': '0.0.0', - }, + headers: expect.anything(), method: 'POST', }, ], @@ -304,21 +283,14 @@ describe('State Subapi', () => { { body: '{"at_ledger_state":{"state_version":1},"cursor":"eyJvIjoxMDB9","address":"address","aggregation_level":"Vault","opt_ins":{"non_fungible_include_nfids":true,"explicit_metadata":["name"]}}', credentials: undefined, - headers: { - 'Content-Type': 'application/json', - 'RDX-App-Dapp-Definition': 'Unknown', - 'RDX-App-Name': 'Unknown', - 'RDX-App-Version': 'Unknown', - 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', - 'RDX-Client-Version': '0.0.0', - }, + headers: expect.anything(), method: 'POST', }, ], ]) }) - it('should false nonFungibleIncludeNfids to non-fungbile paging requests', async () => { + it('should propagate nonFungibleIncludeNfids=false to non-fungbile paging requests', async () => { // Arrange const spy = jest.fn().mockImplementation((a) => { if (a.includes('/state/entity/details')) { @@ -370,14 +342,7 @@ describe('State Subapi', () => { { body: '{"opt_ins":{"ancestor_identities":false,"component_royalty_vault_balance":false,"package_royalty_vault_balance":false,"non_fungible_include_nfids":false,"explicit_metadata":["name"]},"addresses":["address"],"aggregation_level":"Vault"}', credentials: undefined, - headers: { - 'Content-Type': 'application/json', - 'RDX-App-Dapp-Definition': 'Unknown', - 'RDX-App-Name': 'Unknown', - 'RDX-App-Version': 'Unknown', - 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', - 'RDX-Client-Version': '0.0.0', - }, + headers: expect.anything(), method: 'POST', }, ], @@ -386,14 +351,7 @@ describe('State Subapi', () => { { body: '{"at_ledger_state":{"state_version":1},"cursor":"eyJvIjoxMDB9","address":"address","aggregation_level":"Vault","opt_ins":{"non_fungible_include_nfids":false,"explicit_metadata":["name"]}}', credentials: undefined, - headers: { - 'Content-Type': 'application/json', - 'RDX-App-Dapp-Definition': 'Unknown', - 'RDX-App-Name': 'Unknown', - 'RDX-App-Version': 'Unknown', - 'RDX-Client-Name': '@radixdlt/babylon-gateway-api-sdk', - 'RDX-Client-Version': '0.0.0', - }, + headers: expect.anything(), method: 'POST', }, ], From 84b1b7920e87bd969e3e05a08bac428460ad7a94 Mon Sep 17 00:00:00 2001 From: Dawid Sowa Date: Tue, 23 Jan 2024 13:24:54 +0100 Subject: [PATCH 08/10] update networks config --- sdk/typescript/lib/helpers/networks.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sdk/typescript/lib/helpers/networks.ts b/sdk/typescript/lib/helpers/networks.ts index 2d04a3079..47a3a5b87 100644 --- a/sdk/typescript/lib/helpers/networks.ts +++ b/sdk/typescript/lib/helpers/networks.ts @@ -50,6 +50,12 @@ export const RadixNetworkConfig: Record = { gatewayUrl: 'https://rcnet.radixdlt.com', dashboardUrl: 'https://rcnet-dashboard.radixdlt.com', }, + Mardunet: { + networkName: 'Mardunet', + networkId: RadixNetwork.Mardunet, + gatewayUrl: 'https://mardunet-gateway.radixdlt.com', + dashboardUrl: 'https://mardunet-dashboard.rdx-works-main.extratools.works', + }, Zabanet: { networkName: 'Zabanet', networkId: RadixNetwork.Zabanet, @@ -66,7 +72,7 @@ export const RadixNetworkConfig: Record = { networkName: 'Gilganet', networkId: RadixNetwork.Gilganet, gatewayUrl: 'https://gilganet-gateway.radixdlt.com', - dashboardUrl: '', + dashboardUrl: 'https://gilganet-dashboard.rdx-works-main.extratools.works', }, Enkinet: { networkName: 'Enkinet', From 3087245ae59b5b49df3741679a5dede830390891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20=C5=81abu=C5=9B?= Date: Fri, 26 Jan 2024 14:29:25 +0100 Subject: [PATCH 09/10] Fixed broken (incompatible) Core API SDK --- .../CommittedTransactionBalanceChanges.cs | 104 -------- .../core-api-spec-copy.yaml | 50 +--- .../generated/Model/CommittedTransaction.cs | 20 +- .../CommittedTransactionBalanceChanges.cs | 245 ------------------ .../generated/Model/CostingParameters.cs | 6 +- .../Model/LtsCommittedTransactionOutcome.cs | 2 +- .../Model/TransactionFormatOptions.cs | 17 +- .../generated/Model/TransactionHeader.cs | 6 +- .../Model/TransactionPreviewRequest.cs | 6 +- .../ApiReaders/TransactionStreamReader.cs | 1 - .../GatewayModelExtensions.cs | 21 -- .../PostgresLedgerExtenderService.cs | 10 +- .../TransactionBalanceChangesService.cs | 15 -- 13 files changed, 20 insertions(+), 483 deletions(-) delete mode 100644 src/RadixDlt.CoreApiSdk/Model/CommittedTransactionBalanceChanges.cs delete mode 100644 src/RadixDlt.CoreApiSdk/generated/Model/CommittedTransactionBalanceChanges.cs diff --git a/src/RadixDlt.CoreApiSdk/Model/CommittedTransactionBalanceChanges.cs b/src/RadixDlt.CoreApiSdk/Model/CommittedTransactionBalanceChanges.cs deleted file mode 100644 index 3c50f3132..000000000 --- a/src/RadixDlt.CoreApiSdk/Model/CommittedTransactionBalanceChanges.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright 2021 Radix Publishing Ltd incorporated in Jersey (Channel Islands). - * - * Licensed under the Radix License, Version 1.0 (the "License"); you may not use this - * file except in compliance with the License. You may obtain a copy of the License at: - * - * radixfoundation.org/licenses/LICENSE-v1 - * - * The Licensor hereby grants permission for the Canonical version of the Work to be - * published, distributed and used under or by reference to the Licensor’s trademark - * Radix ® and use of any unregistered trade names, logos or get-up. - * - * The Licensor provides the Work (and each Contributor provides its Contributions) on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, - * including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, - * MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. - * - * Whilst the Work is capable of being deployed, used and adopted (instantiated) to create - * a distributed ledger it is your responsibility to test and validate the code, together - * with all logic and performance of that code under all foreseeable scenarios. - * - * The Licensor does not make or purport to make and hereby excludes liability for all - * and any representation, warranty or undertaking in any form whatsoever, whether express - * or implied, to any entity or person, including any representation, warranty or - * undertaking, as to the functionality security use, value or other characteristics of - * any distributed ledger nor in respect the functioning or value of any tokens which may - * be created stored or transferred using the Work. The Licensor does not warrant that the - * Work or any use of the Work complies with any law or regulation in any territory where - * it may be implemented or used or that it will be appropriate for any specific purpose. - * - * Neither the licensor nor any current or former employees, officers, directors, partners, - * trustees, representatives, agents, advisors, contractors, or volunteers of the Licensor - * shall be liable for any direct or indirect, special, incidental, consequential or other - * losses of any kind, in tort, contract or otherwise (including but not limited to loss - * of revenue, income or profits, or loss of use or data, or loss of reputation, or loss - * of any economic or other opportunity of whatsoever nature or howsoever arising), arising - * out of or in connection with (without limitation of any use, misuse, of any ledger system - * or use made or its functionality or any performance or operation of any code or protocol - * caused by bugs or programming or logic errors or otherwise); - * - * A. any offer, purchase, holding, use, sale, exchange or transmission of any - * cryptographic keys, tokens or assets created, exchanged, stored or arising from any - * interaction with the Work; - * - * B. any failure in a transmission or loss of any token or assets keys or other digital - * artefacts due to errors in transmission; - * - * C. bugs, hacks, logic errors or faults in the Work or any communication; - * - * D. system software or apparatus including but not limited to losses caused by errors - * in holding or transmitting tokens by any third-party; - * - * E. breaches or failure of security including hacker attacks, loss or disclosure of - * password, loss of private key, unauthorised use or misuse of such passwords or keys; - * - * F. any losses including loss of anticipated savings or other benefits resulting from - * use of the Work or any changes to the Work (however implemented). - * - * You are solely responsible for; testing, validating and evaluation of all operation - * logic, functionality, security and appropriateness of using the Work for any commercial - * or non-commercial purpose and for any reproduction or redistribution by You of the - * Work. You assume all risks associated with Your use of the Work and the exercise of - * permissions under this License. - */ - -using System.Collections.Generic; - -namespace RadixDlt.CoreApiSdk.Model; - -public partial class CommittedTransactionBalanceChanges : IEntityAddressPointer -{ - public IEnumerable GetEntityAddresses() - { - foreach (var fungibleBalanceChange in FungibleEntityBalanceChanges) - { - yield return fungibleBalanceChange.EntityAddress; - - foreach (var feeBalanceChange in fungibleBalanceChange.FeeBalanceChanges) - { - yield return feeBalanceChange.ResourceAddress; - } - - foreach (var nonFeeBalanceChange in fungibleBalanceChange.NonFeeBalanceChanges) - { - yield return nonFeeBalanceChange.ResourceAddress; - } - } - - foreach (var nonFungibleBalanceChange in NonFungibleEntityBalanceChanges) - { - yield return nonFungibleBalanceChange.EntityAddress; - yield return nonFungibleBalanceChange.ResourceAddress; - } - - foreach (var resultantAccountFungibleBalance in ResultantAccountFungibleBalances) - { - yield return resultantAccountFungibleBalance.AccountAddress; - - foreach (var resultantBalance in resultantAccountFungibleBalance.ResultantBalances) - { - yield return resultantBalance.ResourceAddress; - } - } - } -} diff --git a/src/RadixDlt.CoreApiSdk/core-api-spec-copy.yaml b/src/RadixDlt.CoreApiSdk/core-api-spec-copy.yaml index f632251d6..a00ecb991 100644 --- a/src/RadixDlt.CoreApiSdk/core-api-spec-copy.yaml +++ b/src/RadixDlt.CoreApiSdk/core-api-spec-copy.yaml @@ -1156,9 +1156,6 @@ components: message: description: Whether to return the transaction message (default true) type: boolean - balance_changes: - description: Whether to return the transaction balance changes (default false) - type: boolean raw_system_transaction: description: Whether to return the raw hex-encoded system transaction bytes (default false) type: boolean @@ -1472,8 +1469,8 @@ components: type: integer format: int32 minimum: 0 - maximum: 65535 - description: An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + maximum: 255 + description: An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. NetworkIdentifierByte: description: The logical id of the network type: integer @@ -1774,8 +1771,8 @@ components: type: integer format: int32 minimum: 0 - maximum: 65535 - description: An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + maximum: 255 + description: An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. FeeSource: type: object required: @@ -5752,6 +5749,7 @@ components: description: | For the given transaction, contains the status, total fee summary and individual entity resource balance changes. The balance changes accounts for the fee payments as well. + Current implementation does not take into account recalls, but this will change in a future update. For failed transactions, current implementation does not return any balance changes (not even the fee payments). This will also change in a future update. type: object @@ -6965,8 +6963,8 @@ components: type: integer format: int32 minimum: 0 - maximum: 65535 - description: An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + maximum: 255 + description: An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. nonce: type: integer format: int64 @@ -7148,46 +7146,12 @@ components: $ref: "#/components/schemas/LedgerTransaction" receipt: $ref: "#/components/schemas/TransactionReceipt" - balance_changes: - $ref: "#/components/schemas/CommittedTransactionBalanceChanges" proposer_timestamp_ms: type: integer format: int64 minimum: 0 maximum: 100000000000000 description: An integer between `0` and `10^14`, marking the proposer timestamp in ms. - CommittedTransactionBalanceChanges: - description: | - For the given transaction, contains individual entity resource balance changes. - The balance changes accounts for the fee payments as well. - For failed transactions, current implementation does not return any balance changes (not even the fee payments). - This will also change in a future update. - type: object - required: - - fungible_entity_balance_changes - - non_fungible_entity_balance_changes - - resultant_account_fungible_balances - properties: - fungible_entity_balance_changes: - description: | - A list of all fungible balance updates which occurred in this transaction, aggregated by the global entity (such as account) - which owns the vaults which were updated. - type: array - items: - $ref: "#/components/schemas/LtsEntityFungibleBalanceChanges" - non_fungible_entity_balance_changes: - description: | - Non fungible changes per entity and resource - type: array - items: - $ref: "#/components/schemas/LtsEntityNonFungibleBalanceChanges" - resultant_account_fungible_balances: - description: | - A list of the resultant fungible account balances for any balances which changed in this transaction. - Only balances for accounts are returned, not any other kind of entity. - type: array - items: - $ref: "#/components/schemas/LtsResultantAccountFungibleBalances" LedgerProof: type: object required: diff --git a/src/RadixDlt.CoreApiSdk/generated/Model/CommittedTransaction.cs b/src/RadixDlt.CoreApiSdk/generated/Model/CommittedTransaction.cs index 114e7bc87..8dccfaae0 100644 --- a/src/RadixDlt.CoreApiSdk/generated/Model/CommittedTransaction.cs +++ b/src/RadixDlt.CoreApiSdk/generated/Model/CommittedTransaction.cs @@ -106,9 +106,8 @@ protected CommittedTransaction() { } /// resultantStateIdentifiers (required). /// ledgerTransaction (required). /// receipt (required). - /// balanceChanges. /// An integer between `0` and `10^14`, marking the proposer timestamp in ms. (required). - public CommittedTransaction(CommittedStateIdentifier resultantStateIdentifiers = default(CommittedStateIdentifier), LedgerTransaction ledgerTransaction = default(LedgerTransaction), TransactionReceipt receipt = default(TransactionReceipt), CommittedTransactionBalanceChanges balanceChanges = default(CommittedTransactionBalanceChanges), long proposerTimestampMs = default(long)) + public CommittedTransaction(CommittedStateIdentifier resultantStateIdentifiers = default(CommittedStateIdentifier), LedgerTransaction ledgerTransaction = default(LedgerTransaction), TransactionReceipt receipt = default(TransactionReceipt), long proposerTimestampMs = default(long)) { // to ensure "resultantStateIdentifiers" is required (not null) if (resultantStateIdentifiers == null) @@ -129,7 +128,6 @@ protected CommittedTransaction() { } } this.Receipt = receipt; this.ProposerTimestampMs = proposerTimestampMs; - this.BalanceChanges = balanceChanges; } /// @@ -150,12 +148,6 @@ protected CommittedTransaction() { } [DataMember(Name = "receipt", IsRequired = true, EmitDefaultValue = true)] public TransactionReceipt Receipt { get; set; } - /// - /// Gets or Sets BalanceChanges - /// - [DataMember(Name = "balance_changes", EmitDefaultValue = true)] - public CommittedTransactionBalanceChanges BalanceChanges { get; set; } - /// /// An integer between `0` and `10^14`, marking the proposer timestamp in ms. /// @@ -174,7 +166,6 @@ public override string ToString() sb.Append(" ResultantStateIdentifiers: ").Append(ResultantStateIdentifiers).Append("\n"); sb.Append(" LedgerTransaction: ").Append(LedgerTransaction).Append("\n"); sb.Append(" Receipt: ").Append(Receipt).Append("\n"); - sb.Append(" BalanceChanges: ").Append(BalanceChanges).Append("\n"); sb.Append(" ProposerTimestampMs: ").Append(ProposerTimestampMs).Append("\n"); sb.Append("}\n"); return sb.ToString(); @@ -226,11 +217,6 @@ public bool Equals(CommittedTransaction input) (this.Receipt != null && this.Receipt.Equals(input.Receipt)) ) && - ( - this.BalanceChanges == input.BalanceChanges || - (this.BalanceChanges != null && - this.BalanceChanges.Equals(input.BalanceChanges)) - ) && ( this.ProposerTimestampMs == input.ProposerTimestampMs || this.ProposerTimestampMs.Equals(input.ProposerTimestampMs) @@ -258,10 +244,6 @@ public override int GetHashCode() { hashCode = (hashCode * 59) + this.Receipt.GetHashCode(); } - if (this.BalanceChanges != null) - { - hashCode = (hashCode * 59) + this.BalanceChanges.GetHashCode(); - } hashCode = (hashCode * 59) + this.ProposerTimestampMs.GetHashCode(); return hashCode; } diff --git a/src/RadixDlt.CoreApiSdk/generated/Model/CommittedTransactionBalanceChanges.cs b/src/RadixDlt.CoreApiSdk/generated/Model/CommittedTransactionBalanceChanges.cs deleted file mode 100644 index fda0e1e37..000000000 --- a/src/RadixDlt.CoreApiSdk/generated/Model/CommittedTransactionBalanceChanges.cs +++ /dev/null @@ -1,245 +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 Core API - Babylon - * - * This API is exposed by the Babylon Radix node to give clients access to the Radix Engine, Mempool and State in the node. The default configuration is intended for use by node-runners on a private network, and is not intended to be exposed publicly. Very heavy load may impact the node's function. The node exposes a configuration flag which allows disabling certain endpoints which may be problematic, but monitoring is advised. This configuration parameter is `api.core.flags.enable_unbounded_endpoints` / `RADIXDLT_CORE_API_FLAGS_ENABLE_UNBOUNDED_ENDPOINTS`. This API exposes queries against the node's current state (see `/lts/state/` or `/state/`), and streams of transaction history (under `/lts/stream/` or `/stream`). If you require queries against snapshots of historical ledger state, you may also wish to consider using the [Gateway API](https://docs-babylon.radixdlt.com/). ## Integration and forward compatibility guarantees Integrators (such as exchanges) are recommended to use the `/lts/` endpoints - they have been designed to be clear and simple for integrators wishing to create and monitor transactions involving fungible transfers to/from accounts. All endpoints under `/lts/` have high guarantees of forward compatibility in future node versions. We may add new fields, but existing fields will not be changed. Assuming the integrating code uses a permissive JSON parser which ignores unknown fields, any additions will not affect existing code. Other endpoints may be changed with new node versions carrying protocol-updates, although any breaking changes will be flagged clearly in the corresponding release notes. All responses may have additional fields added, so clients are advised to use JSON parsers which ignore unknown fields on JSON objects. - * - * The version of the OpenAPI document: v1.0.4 - * 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.CoreApiSdk.Client.FileParameter; -using OpenAPIDateConverter = RadixDlt.CoreApiSdk.Client.OpenAPIDateConverter; - -namespace RadixDlt.CoreApiSdk.Model -{ - /// - /// For the given transaction, contains individual entity resource balance changes. The balance changes accounts for the fee payments as well. For failed transactions, current implementation does not return any balance changes (not even the fee payments). This will also change in a future update. - /// - [DataContract(Name = "CommittedTransactionBalanceChanges")] - public partial class CommittedTransactionBalanceChanges : IEquatable - { - /// - /// Initializes a new instance of the class. - /// - [JsonConstructorAttribute] - protected CommittedTransactionBalanceChanges() { } - /// - /// Initializes a new instance of the class. - /// - /// A list of all fungible balance updates which occurred in this transaction, aggregated by the global entity (such as account) which owns the vaults which were updated. (required). - /// Non fungible changes per entity and resource (required). - /// A list of the resultant fungible account balances for any balances which changed in this transaction. Only balances for accounts are returned, not any other kind of entity. (required). - public CommittedTransactionBalanceChanges(List fungibleEntityBalanceChanges = default(List), List nonFungibleEntityBalanceChanges = default(List), List resultantAccountFungibleBalances = default(List)) - { - // to ensure "fungibleEntityBalanceChanges" is required (not null) - if (fungibleEntityBalanceChanges == null) - { - throw new ArgumentNullException("fungibleEntityBalanceChanges is a required property for CommittedTransactionBalanceChanges and cannot be null"); - } - this.FungibleEntityBalanceChanges = fungibleEntityBalanceChanges; - // to ensure "nonFungibleEntityBalanceChanges" is required (not null) - if (nonFungibleEntityBalanceChanges == null) - { - throw new ArgumentNullException("nonFungibleEntityBalanceChanges is a required property for CommittedTransactionBalanceChanges and cannot be null"); - } - this.NonFungibleEntityBalanceChanges = nonFungibleEntityBalanceChanges; - // to ensure "resultantAccountFungibleBalances" is required (not null) - if (resultantAccountFungibleBalances == null) - { - throw new ArgumentNullException("resultantAccountFungibleBalances is a required property for CommittedTransactionBalanceChanges and cannot be null"); - } - this.ResultantAccountFungibleBalances = resultantAccountFungibleBalances; - } - - /// - /// A list of all fungible balance updates which occurred in this transaction, aggregated by the global entity (such as account) which owns the vaults which were updated. - /// - /// A list of all fungible balance updates which occurred in this transaction, aggregated by the global entity (such as account) which owns the vaults which were updated. - [DataMember(Name = "fungible_entity_balance_changes", IsRequired = true, EmitDefaultValue = true)] - public List FungibleEntityBalanceChanges { get; set; } - - /// - /// Non fungible changes per entity and resource - /// - /// Non fungible changes per entity and resource - [DataMember(Name = "non_fungible_entity_balance_changes", IsRequired = true, EmitDefaultValue = true)] - public List NonFungibleEntityBalanceChanges { get; set; } - - /// - /// A list of the resultant fungible account balances for any balances which changed in this transaction. Only balances for accounts are returned, not any other kind of entity. - /// - /// A list of the resultant fungible account balances for any balances which changed in this transaction. Only balances for accounts are returned, not any other kind of entity. - [DataMember(Name = "resultant_account_fungible_balances", IsRequired = true, EmitDefaultValue = true)] - public List ResultantAccountFungibleBalances { 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 CommittedTransactionBalanceChanges {\n"); - sb.Append(" FungibleEntityBalanceChanges: ").Append(FungibleEntityBalanceChanges).Append("\n"); - sb.Append(" NonFungibleEntityBalanceChanges: ").Append(NonFungibleEntityBalanceChanges).Append("\n"); - sb.Append(" ResultantAccountFungibleBalances: ").Append(ResultantAccountFungibleBalances).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 CommittedTransactionBalanceChanges); - } - - /// - /// Returns true if CommittedTransactionBalanceChanges instances are equal - /// - /// Instance of CommittedTransactionBalanceChanges to be compared - /// Boolean - public bool Equals(CommittedTransactionBalanceChanges input) - { - if (input == null) - { - return false; - } - return - ( - this.FungibleEntityBalanceChanges == input.FungibleEntityBalanceChanges || - this.FungibleEntityBalanceChanges != null && - input.FungibleEntityBalanceChanges != null && - this.FungibleEntityBalanceChanges.SequenceEqual(input.FungibleEntityBalanceChanges) - ) && - ( - this.NonFungibleEntityBalanceChanges == input.NonFungibleEntityBalanceChanges || - this.NonFungibleEntityBalanceChanges != null && - input.NonFungibleEntityBalanceChanges != null && - this.NonFungibleEntityBalanceChanges.SequenceEqual(input.NonFungibleEntityBalanceChanges) - ) && - ( - this.ResultantAccountFungibleBalances == input.ResultantAccountFungibleBalances || - this.ResultantAccountFungibleBalances != null && - input.ResultantAccountFungibleBalances != null && - this.ResultantAccountFungibleBalances.SequenceEqual(input.ResultantAccountFungibleBalances) - ); - } - - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.FungibleEntityBalanceChanges != null) - { - hashCode = (hashCode * 59) + this.FungibleEntityBalanceChanges.GetHashCode(); - } - if (this.NonFungibleEntityBalanceChanges != null) - { - hashCode = (hashCode * 59) + this.NonFungibleEntityBalanceChanges.GetHashCode(); - } - if (this.ResultantAccountFungibleBalances != null) - { - hashCode = (hashCode * 59) + this.ResultantAccountFungibleBalances.GetHashCode(); - } - return hashCode; - } - } - - } - -} diff --git a/src/RadixDlt.CoreApiSdk/generated/Model/CostingParameters.cs b/src/RadixDlt.CoreApiSdk/generated/Model/CostingParameters.cs index 7f84e8cf9..d8d01e633 100644 --- a/src/RadixDlt.CoreApiSdk/generated/Model/CostingParameters.cs +++ b/src/RadixDlt.CoreApiSdk/generated/Model/CostingParameters.cs @@ -110,7 +110,7 @@ protected CostingParameters() { } /// An integer between `0` and `2^32 - 1`, representing the maximum amount of cost units available for the transaction finalization. (required). /// The string-encoded decimal representing the price of 1 USD, expressed in XRD. A decimal is formed of some signed integer `m` of attos (`10^(-18)`) units, where `-2^(192 - 1) <= m < 2^(192 - 1)`. (required). /// The string-encoded decimal representing the price of 1 byte of storage, expressed in XRD. A decimal is formed of some signed integer `m` of attos (`10^(-18)`) units, where `-2^(192 - 1) <= m < 2^(192 - 1)`. (required). - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. (required). + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. (required). public CostingParameters(string executionCostUnitPrice = default(string), long executionCostUnitLimit = default(long), long executionCostUnitLoan = default(long), string finalizationCostUnitPrice = default(string), long finalizationCostUnitLimit = default(long), string xrdUsdPrice = default(string), string xrdStoragePrice = default(string), int tipPercentage = default(int)) { // to ensure "executionCostUnitPrice" is required (not null) @@ -193,9 +193,9 @@ protected CostingParameters() { } public string XrdStoragePrice { get; set; } /// - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. /// - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. [DataMember(Name = "tip_percentage", IsRequired = true, EmitDefaultValue = true)] public int TipPercentage { get; set; } diff --git a/src/RadixDlt.CoreApiSdk/generated/Model/LtsCommittedTransactionOutcome.cs b/src/RadixDlt.CoreApiSdk/generated/Model/LtsCommittedTransactionOutcome.cs index 7b90ead5d..3e750ac4a 100644 --- a/src/RadixDlt.CoreApiSdk/generated/Model/LtsCommittedTransactionOutcome.cs +++ b/src/RadixDlt.CoreApiSdk/generated/Model/LtsCommittedTransactionOutcome.cs @@ -90,7 +90,7 @@ namespace RadixDlt.CoreApiSdk.Model { /// - /// For the given transaction, contains the status, total fee summary and individual entity resource balance changes. The balance changes accounts for the fee payments as well. For failed transactions, current implementation does not return any balance changes (not even the fee payments). This will also change in a future update. + /// For the given transaction, contains the status, total fee summary and individual entity resource balance changes. The balance changes accounts for the fee payments as well. Current implementation does not take into account recalls, but this will change in a future update. For failed transactions, current implementation does not return any balance changes (not even the fee payments). This will also change in a future update. /// [DataContract(Name = "LtsCommittedTransactionOutcome")] public partial class LtsCommittedTransactionOutcome : IEquatable diff --git a/src/RadixDlt.CoreApiSdk/generated/Model/TransactionFormatOptions.cs b/src/RadixDlt.CoreApiSdk/generated/Model/TransactionFormatOptions.cs index c580edaa2..4560c278c 100644 --- a/src/RadixDlt.CoreApiSdk/generated/Model/TransactionFormatOptions.cs +++ b/src/RadixDlt.CoreApiSdk/generated/Model/TransactionFormatOptions.cs @@ -101,16 +101,14 @@ public partial class TransactionFormatOptions : IEquatableWhether to return the raw manifest (default true). /// Whether to return the hex-encoded blobs (default false). /// Whether to return the transaction message (default true). - /// Whether to return the transaction balance changes (default false). /// Whether to return the raw hex-encoded system transaction bytes (default false). /// Whether to return the raw hex-encoded notarized transaction bytes (default true). /// Whether to return the raw hex-encoded ledger transaction bytes (default false). - public TransactionFormatOptions(bool manifest = default(bool), bool blobs = default(bool), bool message = default(bool), bool balanceChanges = default(bool), bool rawSystemTransaction = default(bool), bool rawNotarizedTransaction = default(bool), bool rawLedgerTransaction = default(bool)) + public TransactionFormatOptions(bool manifest = default(bool), bool blobs = default(bool), bool message = default(bool), bool rawSystemTransaction = default(bool), bool rawNotarizedTransaction = default(bool), bool rawLedgerTransaction = default(bool)) { this.Manifest = manifest; this.Blobs = blobs; this.Message = message; - this.BalanceChanges = balanceChanges; this.RawSystemTransaction = rawSystemTransaction; this.RawNotarizedTransaction = rawNotarizedTransaction; this.RawLedgerTransaction = rawLedgerTransaction; @@ -137,13 +135,6 @@ public partial class TransactionFormatOptions : IEquatable - /// Whether to return the transaction balance changes (default false) - /// - /// Whether to return the transaction balance changes (default false) - [DataMember(Name = "balance_changes", EmitDefaultValue = true)] - public bool BalanceChanges { get; set; } - /// /// Whether to return the raw hex-encoded system transaction bytes (default false) /// @@ -176,7 +167,6 @@ public override string ToString() sb.Append(" Manifest: ").Append(Manifest).Append("\n"); sb.Append(" Blobs: ").Append(Blobs).Append("\n"); sb.Append(" Message: ").Append(Message).Append("\n"); - sb.Append(" BalanceChanges: ").Append(BalanceChanges).Append("\n"); sb.Append(" RawSystemTransaction: ").Append(RawSystemTransaction).Append("\n"); sb.Append(" RawNotarizedTransaction: ").Append(RawNotarizedTransaction).Append("\n"); sb.Append(" RawLedgerTransaction: ").Append(RawLedgerTransaction).Append("\n"); @@ -227,10 +217,6 @@ public bool Equals(TransactionFormatOptions input) this.Message == input.Message || this.Message.Equals(input.Message) ) && - ( - this.BalanceChanges == input.BalanceChanges || - this.BalanceChanges.Equals(input.BalanceChanges) - ) && ( this.RawSystemTransaction == input.RawSystemTransaction || this.RawSystemTransaction.Equals(input.RawSystemTransaction) @@ -257,7 +243,6 @@ public override int GetHashCode() hashCode = (hashCode * 59) + this.Manifest.GetHashCode(); hashCode = (hashCode * 59) + this.Blobs.GetHashCode(); hashCode = (hashCode * 59) + this.Message.GetHashCode(); - hashCode = (hashCode * 59) + this.BalanceChanges.GetHashCode(); hashCode = (hashCode * 59) + this.RawSystemTransaction.GetHashCode(); hashCode = (hashCode * 59) + this.RawNotarizedTransaction.GetHashCode(); hashCode = (hashCode * 59) + this.RawLedgerTransaction.GetHashCode(); diff --git a/src/RadixDlt.CoreApiSdk/generated/Model/TransactionHeader.cs b/src/RadixDlt.CoreApiSdk/generated/Model/TransactionHeader.cs index b321bcdfd..09e1c4fc1 100644 --- a/src/RadixDlt.CoreApiSdk/generated/Model/TransactionHeader.cs +++ b/src/RadixDlt.CoreApiSdk/generated/Model/TransactionHeader.cs @@ -109,7 +109,7 @@ protected TransactionHeader() { } /// An integer between `0` and `2^32 - 1`, chosen to allow a unique intent to be created (to enable submitting an otherwise identical/duplicate intent). (required). /// notaryPublicKey (required). /// Specifies whether the notary public key should be included in the transaction signers list (required). - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. (required). + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. (required). public TransactionHeader(int networkId = default(int), long startEpochInclusive = default(long), long endEpochExclusive = default(long), long nonce = default(long), PublicKey notaryPublicKey = default(PublicKey), bool notaryIsSignatory = default(bool), int tipPercentage = default(int)) { this.NetworkId = networkId; @@ -168,9 +168,9 @@ protected TransactionHeader() { } public bool NotaryIsSignatory { get; set; } /// - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. /// - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. [DataMember(Name = "tip_percentage", IsRequired = true, EmitDefaultValue = true)] public int TipPercentage { get; set; } diff --git a/src/RadixDlt.CoreApiSdk/generated/Model/TransactionPreviewRequest.cs b/src/RadixDlt.CoreApiSdk/generated/Model/TransactionPreviewRequest.cs index ea147c5c1..95bcfbd6c 100644 --- a/src/RadixDlt.CoreApiSdk/generated/Model/TransactionPreviewRequest.cs +++ b/src/RadixDlt.CoreApiSdk/generated/Model/TransactionPreviewRequest.cs @@ -110,7 +110,7 @@ protected TransactionPreviewRequest() { } /// An integer between `0` and `10^10`, marking the epoch at which the transaction is no longer valid (required). /// notaryPublicKey. /// Whether the notary should count as a signatory (optional, default false). - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. (required). + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. (required). /// An integer between `0` and `2^32 - 1`, chosen to allow a unique intent to be created (to enable submitting an otherwise identical/duplicate intent). (required). /// A list of public keys to be used as transaction signers (required). /// message. @@ -200,9 +200,9 @@ protected TransactionPreviewRequest() { } public bool NotaryIsSignatory { get; set; } /// - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. /// - /// An integer between `0` and `65535`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. + /// An integer between `0` and `255`, giving the validator tip as a percentage amount. A value of `1` corresponds to 1% of the fee. [DataMember(Name = "tip_percentage", IsRequired = true, EmitDefaultValue = true)] public int TipPercentage { get; set; } diff --git a/src/RadixDlt.NetworkGateway.DataAggregator/NodeServices/ApiReaders/TransactionStreamReader.cs b/src/RadixDlt.NetworkGateway.DataAggregator/NodeServices/ApiReaders/TransactionStreamReader.cs index d3513d192..acb4e5f3f 100644 --- a/src/RadixDlt.NetworkGateway.DataAggregator/NodeServices/ApiReaders/TransactionStreamReader.cs +++ b/src/RadixDlt.NetworkGateway.DataAggregator/NodeServices/ApiReaders/TransactionStreamReader.cs @@ -107,7 +107,6 @@ public TransactionStreamReader( Blobs = true, Manifest = true, Message = true, - BalanceChanges = true, RawLedgerTransaction = false, RawNotarizedTransaction = true, RawSystemTransaction = false, diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/GatewayModelExtensions.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/GatewayModelExtensions.cs index c74c26d15..65b300ea7 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/GatewayModelExtensions.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/GatewayModelExtensions.cs @@ -233,27 +233,6 @@ public static GatewayModel.TransactionBalanceChanges ToGatewayModel(this CoreMod return new GatewayModel.TransactionBalanceChanges(fungibleFeeBalanceChanges, fungibleBalanceChanges, nonFungibleBalanceChanges); } - public static GatewayModel.TransactionBalanceChanges ToGatewayModel(this CoreModel.CommittedTransactionBalanceChanges input) - { - var fungibleFeeBalanceChanges = new List(); - var fungibleBalanceChanges = new List(); - - foreach (var f in input.FungibleEntityBalanceChanges) - { - fungibleFeeBalanceChanges.AddRange(f.FeeBalanceChanges - .Select(x => new GatewayModel.TransactionFungibleFeeBalanceChanges(x.Type.ToGatewayModel(), f.EntityAddress, x.ResourceAddress, x.BalanceChange))); - fungibleBalanceChanges.AddRange(f.NonFeeBalanceChanges - .Select(x => new GatewayModel.TransactionFungibleBalanceChanges(f.EntityAddress, x.ResourceAddress, x.BalanceChange))); - } - - var nonFungibleBalanceChanges = input - .NonFungibleEntityBalanceChanges - .Select(x => new GatewayModel.TransactionNonFungibleBalanceChanges(x.EntityAddress, x.ResourceAddress, x.Added, x.Removed)) - .ToList(); - - return new GatewayModel.TransactionBalanceChanges(fungibleFeeBalanceChanges, fungibleBalanceChanges, nonFungibleBalanceChanges); - } - private static GatewayModel.TransactionFungibleFeeBalanceChangeType ToGatewayModel(this CoreModel.LtsFeeFungibleResourceBalanceChangeType input) { return input switch diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs index 4cc6d6b09..ecf4b9909 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/LedgerExtension/PostgresLedgerExtenderService.cs @@ -466,14 +466,6 @@ private async Task ProcessTransactions(ReadWriteDbContext db } } - if (committedTransaction.BalanceChanges != null) - { - foreach (var entityAddress in committedTransaction.BalanceChanges.GetEntityAddresses()) - { - referencedEntities.MarkSeenAddress((EntityAddress)entityAddress); - } - } - /* NB: The Epoch Transition Transaction sort of fits between epochs, but it seems to fit slightly more naturally as the _first_ transaction of a new epoch, as creates the next EpochData, and the RoundData to 0. @@ -538,7 +530,7 @@ private async Task ProcessTransactions(ReadWriteDbContext db ledgerTransaction.ReceiptNextEpoch = committedTransaction.Receipt.NextEpoch?.ToJson(); ledgerTransaction.ReceiptCostingParameters = committedTransaction.Receipt.CostingParameters.ToJson(); ledgerTransaction.ReceiptFeeDestination = committedTransaction.Receipt.FeeDestination?.ToJson(); - ledgerTransaction.BalanceChanges = committedTransaction.BalanceChanges?.ToJson(); + ledgerTransaction.BalanceChanges = null; ledgerTransactionsToAdd.Add(ledgerTransaction); if (committedTransaction.Receipt.NextEpoch != null) diff --git a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/TransactionBalanceChangesService.cs b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/TransactionBalanceChangesService.cs index f9e1a7137..c4cd17d9e 100644 --- a/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/TransactionBalanceChangesService.cs +++ b/src/RadixDlt.NetworkGateway.PostgresIntegration/Services/TransactionBalanceChangesService.cs @@ -64,7 +64,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; -using Newtonsoft.Json; using RadixDlt.NetworkGateway.Abstractions.Extensions; using RadixDlt.NetworkGateway.GatewayApi.Configuration; using RadixDlt.NetworkGateway.GatewayApi.CoreCommunications; @@ -118,20 +117,6 @@ await Parallel.ForEachAsync(transactions, options, async (transaction, cancellat { try { - if (transaction.BalanceChanges != null) - { - var storedBalanceChanges = JsonConvert.DeserializeObject(transaction.BalanceChanges); - - if (storedBalanceChanges == null) - { - throw new InvalidOperationException("Unable to deserialize stored balance changes into CoreModel.CommittedTransactionBalanceChanges"); - } - - result.TryAdd(transaction.StateVersion, storedBalanceChanges.ToGatewayModel()); - - return; - } - var selectedNode = _coreApiHandler.GetCoreNodeConnectedTo(); await _observers.ForEachAsync(x => x.PreHandleOutcomeRequest(transaction.StateVersion, selectedNode.Name)); From cec0a811b7f943478bf82da60a4002b4b616f987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20=C5=81abu=C5=9B?= Date: Fri, 26 Jan 2024 14:57:49 +0100 Subject: [PATCH 10/10] Updated changelog --- CHANGELOG.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cce16b44..e47a8f794 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ +## 1.2.5 +Release Date: 26.01.2024 + +- Fixed broken (incompatible) Core API SDK + ## 1.2.4 -Release Date: _unreleased_ +Release Date: 04.01.2024 - Extended validator's data returned from `/state/validators/list`: added `effective_fee_factor` field which returns `current` fee_factor and optionally `pending` change. - Enable retries on transient database connectivity issues in gateway api.