Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update OutputIdsResponse #1638

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 were 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;
/**
Expand Down
8 changes: 6 additions & 2 deletions bindings/python/iota_sdk/client/_node_indexer_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
"""

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"]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions sdk/src/client/node_api/indexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl ClientInner {
prefer_permanode: bool,
) -> Result<OutputIdsResponse> {
let mut merged_output_ids_response = OutputIdsResponse {
ledger_index: 0,
committed_slot: 0,
page_size: 1000,
cursor: None,
items: Vec::new(),
};
Expand All @@ -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);

Expand Down
7 changes: 5 additions & 2 deletions sdk/src/types/api/plugins/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 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.
pub page_size: u32,
/// Cursor confirmationMS+outputId.pageSize
pub cursor: Option<String>,
/// The output ids
Expand Down
Loading