-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add /api/core/v3/outputs/{outputId}/full route
- Loading branch information
Showing
8 changed files
with
180 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2023 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
//! Find an output with its metadata, by its identifier by querying the `/api/core/v3/outputs/{outputId}/full` node | ||
//! endpoint. | ||
//! | ||
//! Make sure to provide a somewhat recent output id to make this example run successfully! | ||
//! | ||
//! Rename `.env.example` to `.env` first, then run the command: | ||
//! ```sh | ||
//! cargo run --release --example node_api_core_get_output_full <OUTPUT ID> [NODE URL] | ||
//! ``` | ||
|
||
use iota_sdk::{ | ||
client::{Client, Result}, | ||
types::block::output::OutputId, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
// If not provided we use the default node from the `.env` file. | ||
dotenvy::dotenv().ok(); | ||
|
||
// Take the node URL from command line argument or use one from env as default. | ||
let node_url = std::env::args() | ||
.nth(2) | ||
.unwrap_or_else(|| std::env::var("NODE_URL").expect("NODE_URL not set")); | ||
|
||
// Create a node client. | ||
let client = Client::builder().with_node(&node_url)?.finish().await?; | ||
|
||
// Take the output id from the command line, or panic. | ||
let output_id = std::env::args() | ||
.nth(1) | ||
.expect("missing example argument: OUTPUT ID") | ||
.parse::<OutputId>()?; | ||
|
||
// Get the output with its metadata. | ||
let output_with_metadata = client.get_output_with_metadata(&output_id).await?; | ||
|
||
println!("{output_with_metadata:?}"); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters