From 9225373d0ebbdecd6c8b5ed16bdf17a0b6886306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Fri, 17 Nov 2023 15:06:54 +0100 Subject: [PATCH 1/3] Update OutputIdsResponse --- .../lib/types/models/api/output-metadata-response.ts | 2 +- .../types/models/api/plugins/indexer/output-response.ts | 6 +++--- bindings/python/iota_sdk/client/_node_indexer_api.py | 8 ++++++-- .../node_api_indexer/07_get_random_basic_outputs.rs | 2 +- sdk/src/client/node_api/indexer/mod.rs | 6 ++++-- sdk/src/types/api/plugins/indexer.rs | 7 +++++-- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/bindings/nodejs/lib/types/models/api/output-metadata-response.ts b/bindings/nodejs/lib/types/models/api/output-metadata-response.ts index 4c6e6b780c..25234016dd 100644 --- a/bindings/nodejs/lib/types/models/api/output-metadata-response.ts +++ b/bindings/nodejs/lib/types/models/api/output-metadata-response.ts @@ -45,5 +45,5 @@ export interface IOutputMetadataResponse { /** * The ledger index at which these output was available at. */ - ledgerIndex: number; + committedSlot: number; } diff --git a/bindings/nodejs/lib/types/models/api/plugins/indexer/output-response.ts b/bindings/nodejs/lib/types/models/api/plugins/indexer/output-response.ts index f953ecd53f..b2ad84191d 100644 --- a/bindings/nodejs/lib/types/models/api/plugins/indexer/output-response.ts +++ b/bindings/nodejs/lib/types/models/api/plugins/indexer/output-response.ts @@ -9,11 +9,11 @@ import type { HexEncodedString } from '../../../../utils/hex-encoding'; */ export interface IOutputsResponse { /** - * The ledger index at which these outputs where available at. + * The committed slot at which these outputs where available at. */ - ledgerIndex: number; + committedSlot: number; /** - * The maximum count of results that are returned by the node. + * The maximum amount of items returned in one call. If there are more items, a cursor to the next page is returned too. */ pageSize: NumericString; /** diff --git a/bindings/python/iota_sdk/client/_node_indexer_api.py b/bindings/python/iota_sdk/client/_node_indexer_api.py index 28f402348b..b6fda4a0e2 100644 --- a/bindings/python/iota_sdk/client/_node_indexer_api.py +++ b/bindings/python/iota_sdk/client/_node_indexer_api.py @@ -9,17 +9,21 @@ from iota_sdk.types.output_id import OutputId +@json +@dataclass class OutputIdsResponse: """Response type for output IDs. Attributes: - ledger_index: The ledger index for which the response is valid. + committed_slot: The committed slot at which these outputs where available at. + page_size: The maximum amount of items returned in one call. If there are more items, a cursor to the next page is returned too. cursor: The cursor to the next page of results. items: The query results. """ def __init__(self, output_dict: Dict): - self.ledgerIndex = output_dict["ledgerIndex"] + self.committed_slot = output_dict["committedSlot"] + self.page_size = output_dict["pageSize"] self.cursor = output_dict["cursor"] self.items = [OutputId.from_string( output_id) for output_id in output_dict["items"]] diff --git a/sdk/examples/client/node_api_indexer/07_get_random_basic_outputs.rs b/sdk/examples/client/node_api_indexer/07_get_random_basic_outputs.rs index 72cc7d2c09..b53aa1802b 100644 --- a/sdk/examples/client/node_api_indexer/07_get_random_basic_outputs.rs +++ b/sdk/examples/client/node_api_indexer/07_get_random_basic_outputs.rs @@ -20,7 +20,7 @@ async fn main() -> Result<()> { // Take the node URL from command line argument or use one from env as default. let node_url = std::env::args() - .nth(2) + .nth(1) .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); // Create a node client. diff --git a/sdk/src/client/node_api/indexer/mod.rs b/sdk/src/client/node_api/indexer/mod.rs index 1357068173..511b408936 100644 --- a/sdk/src/client/node_api/indexer/mod.rs +++ b/sdk/src/client/node_api/indexer/mod.rs @@ -23,7 +23,8 @@ impl ClientInner { prefer_permanode: bool, ) -> Result { let mut merged_output_ids_response = OutputIdsResponse { - ledger_index: 0, + committed_slot: 0, + page_size: 1000, cursor: None, items: Vec::new(), }; @@ -48,7 +49,8 @@ impl ClientInner { return Ok(output_ids_response); } - merged_output_ids_response.ledger_index = output_ids_response.ledger_index; + merged_output_ids_response.committed_slot = output_ids_response.committed_slot; + merged_output_ids_response.page_size = output_ids_response.page_size; merged_output_ids_response.cursor = output_ids_response.cursor; merged_output_ids_response.items.extend(output_ids_response.items); diff --git a/sdk/src/types/api/plugins/indexer.rs b/sdk/src/types/api/plugins/indexer.rs index 2c609dfddc..611157646e 100644 --- a/sdk/src/types/api/plugins/indexer.rs +++ b/sdk/src/types/api/plugins/indexer.rs @@ -17,8 +17,11 @@ use crate::types::block::output::OutputId; serde(rename_all = "camelCase") )] pub struct OutputIdsResponse { - /// The ledger index at which the outputs were collected - pub ledger_index: u32, + /// The committed slot at which these outputs where available at. + pub committed_slot: u32, + /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is + /// returned too. + pub page_size: u32, /// Cursor confirmationMS+outputId.pageSize pub cursor: Option, /// The output ids From e50fb7de84c976bde21d02bb5a61c4264454313f Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:10:21 +0100 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Thibault Martinez --- .../lib/types/models/api/plugins/indexer/output-response.ts | 2 +- bindings/python/iota_sdk/client/_node_indexer_api.py | 2 +- sdk/src/types/api/plugins/indexer.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bindings/nodejs/lib/types/models/api/plugins/indexer/output-response.ts b/bindings/nodejs/lib/types/models/api/plugins/indexer/output-response.ts index b2ad84191d..2bf8b46c3c 100644 --- a/bindings/nodejs/lib/types/models/api/plugins/indexer/output-response.ts +++ b/bindings/nodejs/lib/types/models/api/plugins/indexer/output-response.ts @@ -9,7 +9,7 @@ import type { HexEncodedString } from '../../../../utils/hex-encoding'; */ export interface IOutputsResponse { /** - * The committed slot at which these outputs where available at. + * The committed slot at which these outputs were available at. */ committedSlot: number; /** diff --git a/bindings/python/iota_sdk/client/_node_indexer_api.py b/bindings/python/iota_sdk/client/_node_indexer_api.py index b6fda4a0e2..cdc24277a5 100644 --- a/bindings/python/iota_sdk/client/_node_indexer_api.py +++ b/bindings/python/iota_sdk/client/_node_indexer_api.py @@ -15,7 +15,7 @@ class OutputIdsResponse: """Response type for output IDs. Attributes: - committed_slot: The committed slot at which these outputs where available at. + committed_slot: The committed slot at which these outputs were available at. page_size: The maximum amount of items returned in one call. If there are more items, a cursor to the next page is returned too. cursor: The cursor to the next page of results. items: The query results. diff --git a/sdk/src/types/api/plugins/indexer.rs b/sdk/src/types/api/plugins/indexer.rs index 611157646e..c977a74ed1 100644 --- a/sdk/src/types/api/plugins/indexer.rs +++ b/sdk/src/types/api/plugins/indexer.rs @@ -17,7 +17,7 @@ use crate::types::block::output::OutputId; serde(rename_all = "camelCase") )] pub struct OutputIdsResponse { - /// The committed slot at which these outputs where available at. + /// The committed slot at which these outputs were available at. pub committed_slot: u32, /// The maximum amount of items returned in one call. If there are more items, a cursor to the next page is /// returned too. From cfcfdb4088c6e337b3b82fa00f8bae777e722cbe Mon Sep 17 00:00:00 2001 From: Thoralf-M <46689931+Thoralf-M@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:15:53 +0100 Subject: [PATCH 3/3] Undo metadata change --- .../nodejs/lib/types/models/api/output-metadata-response.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bindings/nodejs/lib/types/models/api/output-metadata-response.ts b/bindings/nodejs/lib/types/models/api/output-metadata-response.ts index 25234016dd..4c6e6b780c 100644 --- a/bindings/nodejs/lib/types/models/api/output-metadata-response.ts +++ b/bindings/nodejs/lib/types/models/api/output-metadata-response.ts @@ -45,5 +45,5 @@ export interface IOutputMetadataResponse { /** * The ledger index at which these output was available at. */ - committedSlot: number; + ledgerIndex: number; }