diff --git a/crates/iota-graphql-client/Cargo.toml b/crates/iota-graphql-client/Cargo.toml
index efc7c97ac..511c5b57f 100644
--- a/crates/iota-graphql-client/Cargo.toml
+++ b/crates/iota-graphql-client/Cargo.toml
@@ -9,12 +9,12 @@ repository = "https://github.com/iotaledger/iota-rust-sdk/"
description = "GraphQL RPC Client for the IOTA Blockchain"
[dependencies]
-anyhow = "1.0.71"
base64ct = { version = "1.6.0", features = ["alloc", "std"] }
bcs = "0.1.4"
chrono = "0.4.26"
cynic = "3.7.3"
derive_more = { version = "2.0", features = ["from"] }
+eyre = "0.6"
futures = "0.3.29"
iota-types = { package = "iota-sdk-types", path = "../iota-sdk-types", features = ["serde"] }
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls", "json"] }
diff --git a/crates/iota-graphql-client/README.md b/crates/iota-graphql-client/README.md
index 56552d387..26936340c 100644
--- a/crates/iota-graphql-client/README.md
+++ b/crates/iota-graphql-client/README.md
@@ -23,7 +23,7 @@ Instantiate a client with [`Client::new(server: &str)`] or use one of the predef
```rust, no_run
use iota_graphql_client::Client;
-use anyhow::Result;
+use eyre::Result;
#[tokio::main]
async fn main() -> Result<()> {
@@ -47,7 +47,7 @@ The client provides an API to request gas from the faucet. The `request_and_wait
use iota_graphql_client::faucet::FaucetClient;
use iota_types::Address;
-use anyhow::Result;
+use eyre::Result;
use std::str::FromStr;
#[tokio::main]
@@ -77,7 +77,7 @@ Note that this `FaucetClient` is explicitly designed to work with two endpoints:
use iota_graphql_client::faucet::FaucetClient;
use iota_types::Address;
-use anyhow::Result;
+use eyre::Result;
use std::str::FromStr;
#[tokio::main]
@@ -157,7 +157,7 @@ pub struct BigInt(pub String);
The complete example is shown below:
```rust, ignore
-use anyhow::Result;
+use eyre::Result;
use cynic::QueryBuilder;
use iota_graphql_client::{
diff --git a/crates/iota-graphql-client/examples/custom_query.rs b/crates/iota-graphql-client/examples/custom_query.rs
index a9a786a43..a9fab31ea 100644
--- a/crates/iota-graphql-client/examples/custom_query.rs
+++ b/crates/iota-graphql-client/examples/custom_query.rs
@@ -2,8 +2,8 @@
// Modifications Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-use anyhow::Result;
use cynic::QueryBuilder;
+use eyre::Result;
use iota_graphql_client::{
Client,
query_types::{BigInt, schema},
diff --git a/crates/iota-graphql-client/examples/dynamic_fields.rs b/crates/iota-graphql-client/examples/dynamic_fields.rs
index 62fe6094f..afc7f70fa 100644
--- a/crates/iota-graphql-client/examples/dynamic_fields.rs
+++ b/crates/iota-graphql-client/examples/dynamic_fields.rs
@@ -1,7 +1,7 @@
// Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-use anyhow::Result;
+use eyre::Result;
use iota_graphql_client::Client;
#[tokio::main]
diff --git a/crates/iota-graphql-client/examples/generic_move_function.rs b/crates/iota-graphql-client/examples/generic_move_function.rs
index cac68b12f..8cfd6ebd1 100644
--- a/crates/iota-graphql-client/examples/generic_move_function.rs
+++ b/crates/iota-graphql-client/examples/generic_move_function.rs
@@ -3,7 +3,7 @@
use core::str::FromStr;
-use anyhow::{Context, Result};
+use eyre::{OptionExt, Result};
use iota_graphql_client::Client;
use iota_transaction_builder::{Function, TransactionBuilder, unresolved::Input};
use iota_types::{Address, Identifier, TypeTag};
@@ -20,7 +20,7 @@ async fn main() -> Result<()> {
None,
)
.await?
- .context("missing gas coin")?;
+ .ok_or_eyre("missing gas coin")?;
let mut builder = TransactionBuilder::new();
@@ -55,7 +55,7 @@ async fn main() -> Result<()> {
client
.reference_gas_price(None)
.await?
- .context("missing gas price")?,
+ .ok_or_eyre("missing gas price")?,
);
builder.add_gas_objects([Input::from(&gas_coin).with_owned_kind()]);
@@ -63,7 +63,7 @@ async fn main() -> Result<()> {
let res = client.dry_run_tx(&txn, false).await?;
if let Some(err) = res.error {
- anyhow::bail!("Failed to call generic Move function: {err}");
+ eyre::bail!("Failed to call generic Move function: {err}");
}
println!("Successfully called generic Move function!");
diff --git a/crates/iota-graphql-client/examples/get_object.rs b/crates/iota-graphql-client/examples/get_object.rs
index 79062e06c..cdbc7c861 100644
--- a/crates/iota-graphql-client/examples/get_object.rs
+++ b/crates/iota-graphql-client/examples/get_object.rs
@@ -3,7 +3,7 @@
use std::str::FromStr;
-use anyhow::{Context, Result};
+use eyre::{OptionExt, Result};
use iota_graphql_client::Client;
use iota_types::ObjectId;
@@ -17,7 +17,7 @@ async fn main() -> Result<()> {
let obj = client
.object(object_id, None)
.await?
- .context("missing object")?;
+ .ok_or_eyre("missing object")?;
println!("Object ID: {}", obj.object_id());
println!("Version: {}", obj.version());
diff --git a/crates/iota-graphql-client/examples/move_functions.rs b/crates/iota-graphql-client/examples/move_functions.rs
index 0b46e6ff8..cec4525af 100644
--- a/crates/iota-graphql-client/examples/move_functions.rs
+++ b/crates/iota-graphql-client/examples/move_functions.rs
@@ -3,7 +3,7 @@
use std::str::FromStr;
-use anyhow::Result;
+use eyre::Result;
use iota_graphql_client::Client;
use iota_types::Address;
@@ -14,7 +14,7 @@ async fn main() -> Result<()> {
let package_address =
Address::from_str("0x3ec4826f1d6e0d9f00680b2e9a7a41f03788ee610b3d11c24f41ab0ae71da39f")?;
let Some(package) = client.package(package_address, None).await? else {
- anyhow::bail!("no package found")
+ eyre::bail!("no package found")
};
for (module_id, _) in package.modules {
@@ -30,7 +30,7 @@ async fn main() -> Result<()> {
)
.await?
else {
- anyhow::bail!("module `{module_id}` not found")
+ eyre::bail!("module `{module_id}` not found")
};
if let Some(funs) = module.functions {
println!("Module: {module_id}");
diff --git a/crates/iota-graphql-client/examples/owned_objects.rs b/crates/iota-graphql-client/examples/owned_objects.rs
index 8e7725202..1c865cba8 100644
--- a/crates/iota-graphql-client/examples/owned_objects.rs
+++ b/crates/iota-graphql-client/examples/owned_objects.rs
@@ -1,7 +1,7 @@
// Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-use anyhow::Result;
+use eyre::Result;
use iota_graphql_client::{Client, pagination::PaginationFilter, query_types::ObjectFilter};
use iota_types::Address;
diff --git a/crates/iota-graphql-client/examples/pagination.rs b/crates/iota-graphql-client/examples/pagination.rs
index be544532c..ac5037b56 100644
--- a/crates/iota-graphql-client/examples/pagination.rs
+++ b/crates/iota-graphql-client/examples/pagination.rs
@@ -1,7 +1,7 @@
// Copyright (c) 2025 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
-use anyhow::Result;
+use eyre::Result;
use iota_graphql_client::{Client, pagination::PaginationFilter, query_types::ObjectFilter};
use iota_types::Address;
diff --git a/crates/iota-graphql-client/examples/prepare_send_iota.rs b/crates/iota-graphql-client/examples/prepare_send_iota.rs
index 17410bf43..431a403cd 100644
--- a/crates/iota-graphql-client/examples/prepare_send_iota.rs
+++ b/crates/iota-graphql-client/examples/prepare_send_iota.rs
@@ -3,8 +3,8 @@
use std::str::FromStr;
-use anyhow::Result;
use base64ct::Encoding;
+use eyre::Result;
use iota_graphql_client::Client;
use iota_transaction_builder::{TransactionBuilder, unresolved::Input};
use iota_types::{Address, ObjectId};
@@ -63,7 +63,7 @@ async fn main() -> Result<()> {
let res = client.dry_run_tx(&txn, false).await?;
if let Some(err) = res.error {
- anyhow::bail!("Failed to send IOTA: {err}");
+ eyre::bail!("Failed to send IOTA: {err}");
}
println!("Send IOTA dry run was successful!");
diff --git a/crates/iota-graphql-client/examples/prepare_send_iota_multi.rs b/crates/iota-graphql-client/examples/prepare_send_iota_multi.rs
index 11f0a32bb..a3f40474c 100644
--- a/crates/iota-graphql-client/examples/prepare_send_iota_multi.rs
+++ b/crates/iota-graphql-client/examples/prepare_send_iota_multi.rs
@@ -3,8 +3,8 @@
use std::str::FromStr;
-use anyhow::{Context, Result};
use base64ct::Encoding;
+use eyre::{OptionExt, Result};
use iota_graphql_client::Client;
use iota_transaction_builder::{TransactionBuilder, unresolved::Input};
use iota_types::{Address, Argument, ObjectId};
@@ -24,7 +24,7 @@ async fn main() -> Result<()> {
None,
)
.await?
- .context("missing gas coin")?;
+ .ok_or_eyre("missing gas coin")?;
// Recipients and amounts
let recipients = [
@@ -61,7 +61,7 @@ async fn main() -> Result<()> {
// Transfer each split coin to its corresponding recipient
for (i, recipient_input) in recipient_inputs.into_iter().enumerate() {
let coin_arg = Argument::get_nested_result(&split_coins_result, i as u16)
- .ok_or_else(|| anyhow::anyhow!("Failed to get split coin result at index {i}"))?;
+ .ok_or_else(|| eyre::eyre!("Failed to get split coin result at index {i}"))?;
builder.transfer_objects(vec![coin_arg], recipient_input);
}
@@ -71,7 +71,7 @@ async fn main() -> Result<()> {
client
.reference_gas_price(None)
.await?
- .context("missing ref gas price")?,
+ .ok_or_eyre("missing ref gas price")?,
);
builder.add_gas_objects([Input::from(&gas_coin).with_owned_kind()]);
let txn = builder.finish()?;
@@ -85,7 +85,7 @@ async fn main() -> Result<()> {
let res = client.dry_run_tx(&txn, false).await?;
if let Some(err) = res.error {
- anyhow::bail!("Failed to send IOTA: {err}");
+ eyre::bail!("Failed to send IOTA: {err}");
}
println!("Send IOTA dry run was successful!");
diff --git a/crates/iota-graphql-client/examples/stake.rs b/crates/iota-graphql-client/examples/stake.rs
index f2ef0a484..1115e7fa4 100644
--- a/crates/iota-graphql-client/examples/stake.rs
+++ b/crates/iota-graphql-client/examples/stake.rs
@@ -3,7 +3,7 @@
use std::str::FromStr;
-use anyhow::{Context, Result};
+use eyre::{OptionExt, Result};
use iota_graphql_client::Client;
use iota_transaction_builder::{Function, TransactionBuilder, unresolved::Input};
use iota_types::{Address, Identifier, ObjectId};
@@ -21,7 +21,7 @@ async fn main() -> Result<()> {
.data
.into_iter()
.next()
- .context("no validators found")?;
+ .ok_or_eyre("no validators found")?;
println!(
"Staking to validator {}",
@@ -36,7 +36,7 @@ async fn main() -> Result<()> {
None,
)
.await?
- .context("missing object")?;
+ .ok_or_eyre("missing object")?;
let gas_coin = client
.object(
ObjectId::from_str(
@@ -45,7 +45,7 @@ async fn main() -> Result<()> {
None,
)
.await?
- .context("missing gas coin")?;
+ .ok_or_eyre("missing gas coin")?;
let mut builder = TransactionBuilder::new();
let inputs = vec![
@@ -68,14 +68,14 @@ async fn main() -> Result<()> {
client
.reference_gas_price(None)
.await?
- .context("missing ref gas price")?,
+ .ok_or_eyre("missing ref gas price")?,
);
builder.add_gas_objects([Input::from(&gas_coin).with_owned_kind()]);
let txn = builder.finish()?;
let res = client.dry_run_tx(&txn, false).await?;
if let Some(err) = res.error {
- anyhow::bail!("Failed to stake: {err}");
+ eyre::bail!("Failed to stake: {err}");
}
println!("Stake dry run was successful!");
diff --git a/crates/iota-graphql-client/examples/unstake.rs b/crates/iota-graphql-client/examples/unstake.rs
index 6e2480b6c..17fd91210 100644
--- a/crates/iota-graphql-client/examples/unstake.rs
+++ b/crates/iota-graphql-client/examples/unstake.rs
@@ -3,7 +3,7 @@
use std::str::FromStr;
-use anyhow::{Context, Result};
+use eyre::{OptionExt, Result};
use iota_graphql_client::{Client, query_types::ObjectFilter};
use iota_transaction_builder::{Function, TransactionBuilder, unresolved::Input};
use iota_types::{Address, Identifier, ObjectId, StructTag};
@@ -24,7 +24,7 @@ async fn main() -> Result<()> {
.data
.into_iter()
.next()
- .context("no staked iota found")?;
+ .ok_or_eyre("no staked iota found")?;
// Get a valid gas coin
let gas_coin = client
@@ -40,7 +40,7 @@ async fn main() -> Result<()> {
.data
.into_iter()
.next()
- .context("no gas coin found")?;
+ .ok_or_eyre("no gas coin found")?;
let mut builder = TransactionBuilder::new();
let inputs = vec![
@@ -69,7 +69,7 @@ async fn main() -> Result<()> {
let res = client.dry_run_tx(&txn, false).await?;
if let Some(err) = res.error {
- anyhow::bail!("Failed to unstake: {err}");
+ eyre::bail!("Failed to unstake: {err}");
}
println!("Unstake dry run was successful!");
diff --git a/crates/iota-graphql-client/src/faucet.rs b/crates/iota-graphql-client/src/faucet.rs
index d4fed9c46..167d7ce57 100644
--- a/crates/iota-graphql-client/src/faucet.rs
+++ b/crates/iota-graphql-client/src/faucet.rs
@@ -4,7 +4,7 @@
use std::time::Duration;
-use anyhow::{anyhow, bail};
+use eyre::{bail, eyre};
use iota_types::{Address, Digest, ObjectId};
use reqwest::{StatusCode, Url};
use serde::{Deserialize, Serialize};
@@ -95,13 +95,13 @@ impl FaucetClient {
/// Request gas from the faucet. Note that this will return the UUID of the
/// request and not wait until the token is received. Use
/// `request_and_wait` to wait for the token.
- pub async fn request(&self, address: Address) -> anyhow::Result