diff --git a/.github/workflows/bindings-wasm-publish.yml b/.github/workflows/bindings-wasm-publish.yml index c2552a6630..8640c86540 100644 --- a/.github/workflows/bindings-wasm-publish.yml +++ b/.github/workflows/bindings-wasm-publish.yml @@ -25,7 +25,7 @@ jobs: - name: Install wasm-bindgen-cli uses: jetli/wasm-bindgen-action@v0.2.0 with: - version: "0.2.87" + version: "0.2.89" - name: Set up Node.js uses: actions/setup-node@v3 diff --git a/.github/workflows/bindings-wasm.yml b/.github/workflows/bindings-wasm.yml index 21eaa69f36..29df4e78c4 100644 --- a/.github/workflows/bindings-wasm.yml +++ b/.github/workflows/bindings-wasm.yml @@ -65,7 +65,7 @@ jobs: - name: Install wasm-bindgen-cli uses: jetli/wasm-bindgen-action@v0.2.0 with: - version: "0.2.88" + version: "0.2.89" - name: Set Up Node.js ${{ matrix.node }} and Yarn Cache uses: actions/setup-node@v3 diff --git a/Cargo.lock b/Cargo.lock index bb6bc95aea..c1f2a11221 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2220,7 +2220,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "858971e010057f7bcae183e545085b83d41280ca8abe0333613a7135fbb54430" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 1.3.1", "proc-macro-error", "proc-macro2", "quote", @@ -2229,9 +2229,9 @@ dependencies = [ [[package]] name = "parity-scale-codec" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dec8a8073036902368c2cdc0387e85ff9a37054d7e7c98e592145e0c92cd4fb" +checksum = "881331e34fa842a2fb61cc2db9643a8fedc615e47cfcc52597d1af0db9a7e8fe" dependencies = [ "arrayvec", "bitvec", @@ -2243,11 +2243,11 @@ dependencies = [ [[package]] name = "parity-scale-codec-derive" -version = "3.6.5" +version = "3.6.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "312270ee71e1cd70289dacf597cab7b207aa107d2f28191c2ae45b2ece18a260" +checksum = "be30eaf4b0a9fba5336683b38de57bb86d179a35862ba6bfcf57625d006bde5b" dependencies = [ - "proc-macro-crate", + "proc-macro-crate 2.0.0", "proc-macro2", "quote", "syn 1.0.109", @@ -2419,7 +2419,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.15", +] + +[[package]] +name = "proc-macro-crate" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e8366a6159044a37876a2b9817124296703c586a5c92e2c53751fa06d8d43e8" +dependencies = [ + "toml_edit 0.20.7", ] [[package]] @@ -3362,6 +3371,17 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70f427fce4d84c72b5b732388bf4a9f4531b53f74e2887e3ecb2481f68f66d81" +dependencies = [ + "indexmap", + "toml_datetime", + "winnow", +] + [[package]] name = "tower-service" version = "0.3.2" @@ -4016,18 +4036,18 @@ checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec" [[package]] name = "zerocopy" -version = "0.7.26" +version = "0.7.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e97e415490559a91254a2979b4829267a57d2fcd741a98eee8b722fb57289aa0" +checksum = "f43de342578a3a14a9314a2dab1942cbfcbe5686e1f91acdc513058063eafe18" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.7.26" +version = "0.7.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd7e48ccf166952882ca8bd778a43502c64f33bf94c12ebe2a7f08e5a0f6689f" +checksum = "e1012d89e3acb79fad7a799ce96866cfb8098b74638465ea1b1533d35900ca90" dependencies = [ "proc-macro2", "quote", diff --git a/bindings/core/Cargo.toml b/bindings/core/Cargo.toml index e9db452142..ebee17c2d2 100644 --- a/bindings/core/Cargo.toml +++ b/bindings/core/Cargo.toml @@ -26,12 +26,12 @@ log = { version = "0.4.20", default-features = false } packable = { version = "0.10.0", default-features = false } prefix-hex = { version = "0.7.1", default-features = false } primitive-types = { version = "0.12.2", default-features = false } -serde = { version = "1.0.190", default-features = false } -serde_json = { version = "1.0.107", default-features = false } +serde = { version = "1.0.193", default-features = false } +serde_json = { version = "1.0.108", default-features = false } thiserror = { version = "1.0.50", default-features = false } -tokio = { version = "1.33.0", default-features = false } +tokio = { version = "1.34.0", default-features = false } url = { version = "2.4.1", default-features = false, features = ["serde"] } -zeroize = { version = "1.6.0", default-features = false } +zeroize = { version = "1.7.0", default-features = false } [dev-dependencies] pretty_assertions = { version = "1.4.0", default-features = false, features = [ diff --git a/bindings/nodejs/Cargo.toml b/bindings/nodejs/Cargo.toml index cf4f515cb1..5b1a72bdf8 100644 --- a/bindings/nodejs/Cargo.toml +++ b/bindings/nodejs/Cargo.toml @@ -33,9 +33,9 @@ log = { version = "0.4.20", default-features = false } napi = { version = "2.13.3", default-features = false, features = ["async"] } napi-derive = { version = "2.13.0", default-features = false } once_cell = { version = "1.18.0", default-features = false } -serde_json = { version = "1.0.107", default-features = false } +serde_json = { version = "1.0.108", default-features = false } thiserror = { version = "1.0.49", default-features = false } -tokio = { version = "1.33.0", default-features = false } +tokio = { version = "1.34.0", default-features = false } [build-dependencies] napi-build = { version = "2.0.1", default-features = false } diff --git a/bindings/python/Cargo.toml b/bindings/python/Cargo.toml index eae8434b01..457fad6ca7 100644 --- a/bindings/python/Cargo.toml +++ b/bindings/python/Cargo.toml @@ -33,5 +33,5 @@ pyo3 = { version = "0.20.0", default-features = false, features = [ "macros", "extension-module", ] } -serde_json = { version = "1.0.107", default-features = false } -tokio = { version = "1.33.0", default-features = false } +serde_json = { version = "1.0.108", default-features = false } +tokio = { version = "1.34.0", default-features = false } diff --git a/bindings/wasm/Cargo.toml b/bindings/wasm/Cargo.toml index d3d7bffccf..70d292358f 100644 --- a/bindings/wasm/Cargo.toml +++ b/bindings/wasm/Cargo.toml @@ -24,20 +24,20 @@ iota-sdk-bindings-core = { path = "../core", default-features = false, features ] } console_error_panic_hook = { version = "0.1.7", default-features = false } -js-sys = { version = "0.3.64", default-features = false, features = [] } +js-sys = { version = "0.3.66", default-features = false, features = [] } log = { version = "0.4.20", default-features = false } -serde_json = { version = "1.0.107", default-features = false } -tokio = { version = "1.33.0", default-features = false, features = ["sync"] } -wasm-bindgen = { version = "0.2.88", default-features = false, features = [ +serde_json = { version = "1.0.108", default-features = false } +tokio = { version = "1.34.0", default-features = false, features = ["sync"] } +wasm-bindgen = { version = "0.2.89", default-features = false, features = [ "spans", "std", "serde-serialize", ] } -wasm-bindgen-futures = { version = "0.4.37", default-features = false } +wasm-bindgen-futures = { version = "0.4.39", default-features = false } wasm-logger = { version = "0.2.0", default-features = false } [target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dependencies] -getrandom = { version = "0.2.10", default-features = false, features = ["js"] } +getrandom = { version = "0.2.11", default-features = false, features = ["js"] } instant = { version = "0.1.12", default-features = false, features = [ "wasm-bindgen", ] } diff --git a/cli/Cargo.toml b/cli/Cargo.toml index bc45142d0e..2d24c2e70e 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -25,7 +25,7 @@ iota-sdk = { path = "../sdk", default-features = false, features = [ ] } chrono = { version = "0.4.31", default-features = false, features = ["std"] } -clap = { version = "4.4.7", default-features = false, features = [ +clap = { version = "4.4.10", default-features = false, features = [ "std", "color", "help", @@ -44,10 +44,10 @@ fern-logger = { version = "0.5.0", default-features = false } log = { version = "0.4.20", default-features = false } prefix-hex = { version = "0.7.1", default-features = false, features = ["std"] } rustyline = { version = "12.0.0", features = ["derive"] } -serde_json = { version = "1.0.107", default-features = false } +serde_json = { version = "1.0.108", default-features = false } thiserror = { version = "1.0.50", default-features = false } -tokio = { version = "1.33.0", default-features = false, features = ["fs"] } -zeroize = { version = "1.6.0", default-features = false } +tokio = { version = "1.34.0", default-features = false, features = ["fs"] } +zeroize = { version = "1.7.0", default-features = false } [target.'cfg(target_os = "windows")'.dependencies] winapi = { version = "0.3.9", default-features = false } diff --git a/sdk/CHANGELOG.md b/sdk/CHANGELOG.md index 4b1fbe3df7..49e228b612 100644 --- a/sdk/CHANGELOG.md +++ b/sdk/CHANGELOG.md @@ -29,6 +29,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Display of `WalletError::InsufficientFunds`; +### Fixed + +- `needs_blind_signing()` for non Ed25519 addresses; + ## 1.1.2 - 2023-10-26 ### Added diff --git a/sdk/Cargo.toml b/sdk/Cargo.toml index 66a0d10918..e9bb13942f 100644 --- a/sdk/Cargo.toml +++ b/sdk/Cargo.toml @@ -34,7 +34,7 @@ derive_more = { version = "0.99.17", default-features = false, features = [ ] } derive_setters = { version = "0.1.6", default-features = false } getset = { version = "0.1.2", default-features = false } -hashbrown = { version = "0.14.2", default-features = false, features = [ +hashbrown = { version = "0.14.3", default-features = false, features = [ "ahash", "inline-more", ] } @@ -53,8 +53,8 @@ prefix-hex = { version = "0.7.1", default-features = false, features = [ "primitive-types", ] } primitive-types = { version = "0.12.2", default-features = false } -serde = { version = "1.0.190", default-features = false, features = ["derive"] } -serde_json = { version = "1.0.107", default-features = false, features = [ +serde = { version = "1.0.193", default-features = false, features = ["derive"] } +serde_json = { version = "1.0.108", default-features = false, features = [ "alloc", ] } @@ -86,21 +86,21 @@ rocksdb = { version = "0.21.0", default-features = false, features = [ rumqttc = { version = "0.23.0", default-features = false, features = [ "websocket", ], optional = true } -serde_repr = { version = "0.1.16", default-features = false, optional = true } +serde_repr = { version = "0.1.17", default-features = false, optional = true } thiserror = { version = "1.0.50", default-features = false, optional = true } time = { version = "0.3.30", default-features = false, features = [ "serde", "macros", ], optional = true } -url = { version = "2.4.1", default-features = false, features = [ +url = { version = "2.5.0", default-features = false, features = [ "serde", ], optional = true } -zeroize = { version = "1.6.0", default-features = false, features = [ +zeroize = { version = "1.7.0", default-features = false, features = [ "zeroize_derive", ], optional = true } [target.'cfg(not(target_family = "wasm"))'.dependencies] -tokio = { version = "1.33.0", default-features = false, features = [ +tokio = { version = "1.34.0", default-features = false, features = [ "macros", "rt-multi-thread", "time", @@ -116,13 +116,13 @@ instant = { version = "0.1.12", default-features = false, features = [ "wasm-bindgen", ], optional = true } lazy_static = { version = "1.4.0", default-features = false } -tokio = { version = "1.33.0", default-features = false, features = [ +tokio = { version = "1.34.0", default-features = false, features = [ "macros", "rt", "time", "sync", ], optional = true } -wasm-bindgen-futures = { version = "0.4.37", default-features = false, optional = true } +wasm-bindgen-futures = { version = "0.4.39", default-features = false, optional = true } [dev-dependencies] iota-sdk = { path = ".", default-features = false, features = ["rand"] } @@ -134,7 +134,7 @@ dotenvy = { version = "0.15.7", default-features = false } fern-logger = { version = "0.5.0", default-features = false } num_cpus = { version = "1.16.0", default-features = false } once_cell = { version = "1.18.0", default-features = false } -tokio = { version = "1.33.0", default-features = false, features = [ +tokio = { version = "1.34.0", default-features = false, features = [ "macros", "rt", "rt-multi-thread", diff --git a/sdk/examples/client/01_generate_addresses.rs b/sdk/examples/client/01_generate_addresses.rs index 2b70abd286..f4295576a6 100644 --- a/sdk/examples/client/01_generate_addresses.rs +++ b/sdk/examples/client/01_generate_addresses.rs @@ -19,6 +19,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create a node client. let client = Client::builder() .with_node(&std::env::var("NODE_URL").unwrap())? diff --git a/sdk/examples/client/02_address_balance.rs b/sdk/examples/client/02_address_balance.rs index edea187d1a..04019f6735 100644 --- a/sdk/examples/client/02_address_balance.rs +++ b/sdk/examples/client/02_address_balance.rs @@ -22,6 +22,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create a node client. let client = Client::builder() .with_node(&std::env::var("NODE_URL").unwrap())? diff --git a/sdk/examples/client/block/00_block_no_payload.rs b/sdk/examples/client/block/00_block_no_payload.rs index 0f4b1dbc19..4958adf17b 100644 --- a/sdk/examples/client/block/00_block_no_payload.rs +++ b/sdk/examples/client/block/00_block_no_payload.rs @@ -23,6 +23,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); let issuer_id = std::env::var("ISSUER_ID").unwrap().parse::().unwrap(); diff --git a/sdk/examples/client/block/01_block_confirmation_time.rs b/sdk/examples/client/block/01_block_confirmation_time.rs index 6267f7ed18..ca3c644c35 100644 --- a/sdk/examples/client/block/01_block_confirmation_time.rs +++ b/sdk/examples/client/block/01_block_confirmation_time.rs @@ -23,6 +23,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); let issuer_id = std::env::var("ISSUER_ID").unwrap().parse::().unwrap(); diff --git a/sdk/examples/client/block/02_block_custom_parents.rs b/sdk/examples/client/block/02_block_custom_parents.rs index 9a12661d38..4eca20cc59 100644 --- a/sdk/examples/client/block/02_block_custom_parents.rs +++ b/sdk/examples/client/block/02_block_custom_parents.rs @@ -23,6 +23,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); let issuer_id = std::env::var("ISSUER_ID").unwrap().parse::().unwrap(); diff --git a/sdk/examples/client/block/03_block_custom_payload.rs b/sdk/examples/client/block/03_block_custom_payload.rs index baa4883666..a57f83e564 100644 --- a/sdk/examples/client/block/03_block_custom_payload.rs +++ b/sdk/examples/client/block/03_block_custom_payload.rs @@ -26,6 +26,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); let issuer_id = std::env::var("ISSUER_ID").unwrap().parse::().unwrap(); diff --git a/sdk/examples/client/block/04_block_tagged_data.rs b/sdk/examples/client/block/04_block_tagged_data.rs index 12ade65585..0ff222b84e 100644 --- a/sdk/examples/client/block/04_block_tagged_data.rs +++ b/sdk/examples/client/block/04_block_tagged_data.rs @@ -26,6 +26,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); let issuer_id = std::env::var("ISSUER_ID").unwrap().parse::().unwrap(); diff --git a/sdk/examples/client/get_block.rs b/sdk/examples/client/get_block.rs index 6805bc42a0..a75cfd7764 100644 --- a/sdk/examples/client/get_block.rs +++ b/sdk/examples/client/get_block.rs @@ -15,6 +15,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create a node client. let client = Client::builder() .with_node(&std::env::var("NODE_URL").unwrap())? diff --git a/sdk/examples/client/high_level/consolidation.rs b/sdk/examples/client/high_level/consolidation.rs index 6fb4002c59..ef4de78fe5 100644 --- a/sdk/examples/client/high_level/consolidation.rs +++ b/sdk/examples/client/high_level/consolidation.rs @@ -15,6 +15,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "EXPLORER_URL", "MNEMONIC"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let address_range_start = std::env::args().nth(1).map(|s| s.parse::().unwrap()).unwrap_or(0); let address_range_len = std::env::args().nth(2).map(|s| s.parse::().unwrap()).unwrap_or(10); diff --git a/sdk/examples/client/high_level/inputs_from_transaction_id.rs b/sdk/examples/client/high_level/inputs_from_transaction_id.rs index 1b8f1072c2..a48e7a1e7a 100644 --- a/sdk/examples/client/high_level/inputs_from_transaction_id.rs +++ b/sdk/examples/client/high_level/inputs_from_transaction_id.rs @@ -20,6 +20,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); // Create a node client. diff --git a/sdk/examples/client/high_level/search_address.rs b/sdk/examples/client/high_level/search_address.rs index a20ad6c4b4..f0809142d4 100644 --- a/sdk/examples/client/high_level/search_address.rs +++ b/sdk/examples/client/high_level/search_address.rs @@ -20,6 +20,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); // Create a node client. diff --git a/sdk/examples/client/ledger_nano_transaction.rs b/sdk/examples/client/ledger_nano_transaction.rs index 150e3171af..63032331fc 100644 --- a/sdk/examples/client/ledger_nano_transaction.rs +++ b/sdk/examples/client/ledger_nano_transaction.rs @@ -30,6 +30,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create a client instance let client = Client::builder() .with_node(&std::env::var("NODE_URL").unwrap())? diff --git a/sdk/examples/client/logger.rs b/sdk/examples/client/logger.rs index e261e335aa..fc860e6f4b 100644 --- a/sdk/examples/client/logger.rs +++ b/sdk/examples/client/logger.rs @@ -15,6 +15,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Generates a client.log file with logs for debugging. // We exclude logs from h2, hyper and rustls to reduce the noise. let logger_output_config = fern_logger::LoggerOutputConfigBuilder::new() diff --git a/sdk/examples/client/node_api_core/01_get_routes.rs b/sdk/examples/client/node_api_core/01_get_routes.rs index 74c8b672d1..f8e8dfb614 100644 --- a/sdk/examples/client/node_api_core/01_get_routes.rs +++ b/sdk/examples/client/node_api_core/01_get_routes.rs @@ -14,11 +14,10 @@ use iota_sdk::client::{Client, Result}; 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(1) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .unwrap_or_else(|| std::env::var("NODE_URL").expect("NODE_URL not set")); // Create a node client. let client = Client::builder() diff --git a/sdk/examples/client/node_api_core/03_get_issuance.rs b/sdk/examples/client/node_api_core/03_get_issuance.rs index c6f5ebf361..7519bb7f9f 100644 --- a/sdk/examples/client/node_api_core/03_get_issuance.rs +++ b/sdk/examples/client/node_api_core/03_get_issuance.rs @@ -19,7 +19,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(1) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_core/04_post_block.rs b/sdk/examples/client/node_api_core/04_post_block.rs index 7481535227..9bec68322e 100644 --- a/sdk/examples/client/node_api_core/04_post_block.rs +++ b/sdk/examples/client/node_api_core/04_post_block.rs @@ -23,6 +23,11 @@ async fn main() -> Result<()> { // If not provided we use the default node from the `.env` file. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL", "MNEMONIC", "ISSUER_ID", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Take the node URL from command line argument or use one from env as default. let node_url = std::env::args() .nth(1) diff --git a/sdk/examples/client/node_api_core/05_post_block_raw.rs b/sdk/examples/client/node_api_core/05_post_block_raw.rs index 608ff4fcaf..3e3e5fc365 100644 --- a/sdk/examples/client/node_api_core/05_post_block_raw.rs +++ b/sdk/examples/client/node_api_core/05_post_block_raw.rs @@ -23,6 +23,11 @@ async fn main() -> Result<()> { // If not provided we use the default node from the `.env` file. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL", "MNEMONIC", "ISSUER_ID", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Take the node URL from command line argument or use one from env as default. let node_url = std::env::args() .nth(1) diff --git a/sdk/examples/client/node_api_core/06_get_block.rs b/sdk/examples/client/node_api_core/06_get_block.rs index e5462cdfe1..99898c6fa8 100644 --- a/sdk/examples/client/node_api_core/06_get_block.rs +++ b/sdk/examples/client/node_api_core/06_get_block.rs @@ -18,7 +18,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_core/07_get_block_raw.rs b/sdk/examples/client/node_api_core/07_get_block_raw.rs index 06cdb557dd..3ac1d8f3d7 100644 --- a/sdk/examples/client/node_api_core/07_get_block_raw.rs +++ b/sdk/examples/client/node_api_core/07_get_block_raw.rs @@ -18,7 +18,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_core/08_get_block_metadata.rs b/sdk/examples/client/node_api_core/08_get_block_metadata.rs index a337fdb7f3..23085c13de 100644 --- a/sdk/examples/client/node_api_core/08_get_block_metadata.rs +++ b/sdk/examples/client/node_api_core/08_get_block_metadata.rs @@ -18,7 +18,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_core/09_get_output.rs b/sdk/examples/client/node_api_core/09_get_output.rs index 09f280d32c..08a8bf2b41 100644 --- a/sdk/examples/client/node_api_core/09_get_output.rs +++ b/sdk/examples/client/node_api_core/09_get_output.rs @@ -23,7 +23,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_core/10_get_output_raw.rs b/sdk/examples/client/node_api_core/10_get_output_raw.rs index 4a58aa126c..56787884bf 100644 --- a/sdk/examples/client/node_api_core/10_get_output_raw.rs +++ b/sdk/examples/client/node_api_core/10_get_output_raw.rs @@ -23,7 +23,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_core/11_get_output_metadata.rs b/sdk/examples/client/node_api_core/11_get_output_metadata.rs index 6ca679e753..9f3660ea71 100644 --- a/sdk/examples/client/node_api_core/11_get_output_metadata.rs +++ b/sdk/examples/client/node_api_core/11_get_output_metadata.rs @@ -23,7 +23,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_indexer/01_get_account_output.rs b/sdk/examples/client/node_api_indexer/01_get_account_output.rs index 79bcd484da..2932a6e018 100644 --- a/sdk/examples/client/node_api_indexer/01_get_account_output.rs +++ b/sdk/examples/client/node_api_indexer/01_get_account_output.rs @@ -24,7 +24,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_indexer/02_get_account_outputs.rs b/sdk/examples/client/node_api_indexer/02_get_account_outputs.rs index a66e1beb2c..86cae612d3 100644 --- a/sdk/examples/client/node_api_indexer/02_get_account_outputs.rs +++ b/sdk/examples/client/node_api_indexer/02_get_account_outputs.rs @@ -24,7 +24,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .unwrap_or_else(|| std::env::var("NODE_URL").expect("NODE_URL not set")); // Create a node client. let client = Client::builder() diff --git a/sdk/examples/client/node_api_indexer/03_get_foundry_output.rs b/sdk/examples/client/node_api_indexer/03_get_foundry_output.rs index e89f490d16..5e8a040fab 100644 --- a/sdk/examples/client/node_api_indexer/03_get_foundry_output.rs +++ b/sdk/examples/client/node_api_indexer/03_get_foundry_output.rs @@ -24,7 +24,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_indexer/04_get_foundry_outputs.rs b/sdk/examples/client/node_api_indexer/04_get_foundry_outputs.rs index 1e81619103..b1a993d522 100644 --- a/sdk/examples/client/node_api_indexer/04_get_foundry_outputs.rs +++ b/sdk/examples/client/node_api_indexer/04_get_foundry_outputs.rs @@ -24,7 +24,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .unwrap_or_else(|| std::env::var("NODE_URL").expect("NODE_URL not set")); // Create a node client. let client = Client::builder() diff --git a/sdk/examples/client/node_api_indexer/05_get_nft_output.rs b/sdk/examples/client/node_api_indexer/05_get_nft_output.rs index 41ddbb6247..1214780597 100644 --- a/sdk/examples/client/node_api_indexer/05_get_nft_output.rs +++ b/sdk/examples/client/node_api_indexer/05_get_nft_output.rs @@ -24,7 +24,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/node_api_indexer/06_get_nft_outputs.rs b/sdk/examples/client/node_api_indexer/06_get_nft_outputs.rs index d0210a27b1..bf491f0544 100644 --- a/sdk/examples/client/node_api_indexer/06_get_nft_outputs.rs +++ b/sdk/examples/client/node_api_indexer/06_get_nft_outputs.rs @@ -24,7 +24,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .unwrap_or_else(|| std::env::var("NODE_URL").expect("NODE_URL not set")); // Create a node client. let client = Client::builder() 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 b53aa1802b..4cf7f8fbb5 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 @@ -21,7 +21,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(1) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/client/output/build_account_output.rs b/sdk/examples/client/output/build_account_output.rs index 97fec52486..c575d37960 100644 --- a/sdk/examples/client/output/build_account_output.rs +++ b/sdk/examples/client/output/build_account_output.rs @@ -25,6 +25,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let metadata = std::env::args().nth(1).unwrap_or_else(|| "hello".to_string()); let metadata = metadata.as_bytes(); diff --git a/sdk/examples/client/output/build_nft_output.rs b/sdk/examples/client/output/build_nft_output.rs index 936f85397b..3fedaf5532 100644 --- a/sdk/examples/client/output/build_nft_output.rs +++ b/sdk/examples/client/output/build_nft_output.rs @@ -28,6 +28,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create a node client. let client = Client::builder() .with_node(&std::env::var("NODE_URL").unwrap())? diff --git a/sdk/examples/client/quorum.rs b/sdk/examples/client/quorum.rs index 232de6e647..06b5233ef7 100644 --- a/sdk/examples/client/quorum.rs +++ b/sdk/examples/client/quorum.rs @@ -23,6 +23,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["MNEMONIC"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_1 = std::env::args().nth(1).expect("missing example argument: NODE 1"); let node_2 = std::env::args().nth(2).expect("missing example argument: NODE 2"); let node_3 = std::env::args().nth(3).expect("missing example argument: NODE 3"); diff --git a/sdk/examples/client/send_all.rs b/sdk/examples/client/send_all.rs index a17dbb5dc5..b88cd94874 100644 --- a/sdk/examples/client/send_all.rs +++ b/sdk/examples/client/send_all.rs @@ -24,6 +24,10 @@ async fn main() -> Result<()> { // `NON_SECURE_USE_DEVELOPMENT_MNEMONIC_1` must contain non-zero balance. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC", "MNEMONIC_2", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create a node client. let client = Client::builder() .with_node(&std::env::var("NODE_URL").unwrap())? diff --git a/sdk/examples/client/split_funds.rs b/sdk/examples/client/split_funds.rs index ca7eb31b5b..d5a5d5d12a 100644 --- a/sdk/examples/client/split_funds.rs +++ b/sdk/examples/client/split_funds.rs @@ -17,6 +17,10 @@ async fn main() -> Result<()> { // `MNEMONIC` must contain non-zero balance. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC", "FAUCET_URL", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create a node client. let client = Client::builder() .with_node(&std::env::var("NODE_URL").unwrap())? diff --git a/sdk/examples/client/stronghold.rs b/sdk/examples/client/stronghold.rs index 50ed797069..6bdd1a2776 100644 --- a/sdk/examples/client/stronghold.rs +++ b/sdk/examples/client/stronghold.rs @@ -20,13 +20,18 @@ use iota_sdk::{ #[tokio::main] async fn main() -> Result<()> { + // This example uses secrets in environment variables for simplicity which should not be done in production. + dotenvy::dotenv().ok(); + + #[allow(clippy::single_element_loop)] + for var in ["MNEMONIC"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let stronghold_secret_manager = StrongholdSecretManager::builder() .password("some_hopefully_secure_password".to_owned()) .build("test.stronghold")?; - // This example uses secrets in environment variables for simplicity which should not be done in production. - dotenvy::dotenv().ok(); - let mnemonic = Mnemonic::from(std::env::var("MNEMONIC").unwrap()); // The mnemonic only needs to be stored the first time diff --git a/sdk/examples/how_tos/account/create.rs b/sdk/examples/how_tos/account/create.rs index 78ad399c7f..a9d44a25ca 100644 --- a/sdk/examples/how_tos/account/create.rs +++ b/sdk/examples/how_tos/account/create.rs @@ -19,6 +19,10 @@ async fn main() -> Result<()> { //  This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/account_wallet/request_funds.rs b/sdk/examples/how_tos/account_wallet/request_funds.rs index 1975a09391..2604143aea 100644 --- a/sdk/examples/how_tos/account_wallet/request_funds.rs +++ b/sdk/examples/how_tos/account_wallet/request_funds.rs @@ -18,6 +18,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["FAUCET_URL", "WALLET_DB_PATH"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let faucet_url = std::env::var("FAUCET_URL").unwrap(); // Create the wallet diff --git a/sdk/examples/how_tos/account_wallet/transaction.rs b/sdk/examples/how_tos/account_wallet/transaction.rs index 5087b82e19..a6183ef651 100644 --- a/sdk/examples/how_tos/account_wallet/transaction.rs +++ b/sdk/examples/how_tos/account_wallet/transaction.rs @@ -18,6 +18,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let sync_options = SyncOptions { account: AccountSyncOptions { basic_outputs: true, @@ -70,8 +74,10 @@ async fn main() -> Result<()> { wallet .reissue_transaction_until_included(&transaction.transaction_id, None, None) .await?; + println!( - "Transaction with custom input: https://explorer.shimmer.network/testnet/transaction/{}", + "Transaction with custom input: {}/transaction/{}", + std::env::var("EXPLORER_URL").unwrap(), transaction.transaction_id ); diff --git a/sdk/examples/how_tos/accounts_and_addresses/check_balance.rs b/sdk/examples/how_tos/accounts_and_addresses/check_balance.rs index ab200fa677..6cfda4f7a1 100644 --- a/sdk/examples/how_tos/accounts_and_addresses/check_balance.rs +++ b/sdk/examples/how_tos/accounts_and_addresses/check_balance.rs @@ -18,6 +18,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/accounts_and_addresses/consolidate_outputs.rs b/sdk/examples/how_tos/accounts_and_addresses/consolidate_outputs.rs index 9726ba09bd..9f4b013824 100644 --- a/sdk/examples/how_tos/accounts_and_addresses/consolidate_outputs.rs +++ b/sdk/examples/how_tos/accounts_and_addresses/consolidate_outputs.rs @@ -23,6 +23,12 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "EXPLORER_URL", "STRONGHOLD_PASSWORD"] { + if std::env::var(var).is_err() { + panic!(".env variable '{}' is undefined, see .env.example", var); + } + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/accounts_and_addresses/create_wallet.rs b/sdk/examples/how_tos/accounts_and_addresses/create_wallet.rs index be4d113b1d..7d5385ecd9 100644 --- a/sdk/examples/how_tos/accounts_and_addresses/create_wallet.rs +++ b/sdk/examples/how_tos/accounts_and_addresses/create_wallet.rs @@ -24,6 +24,16 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in [ + "STRONGHOLD_PASSWORD", + "STRONGHOLD_SNAPSHOT_PATH", + "MNEMONIC", + "NODE_URL", + "WALLET_DB_PATH", + ] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Setup Stronghold secret_manager let secret_manager = StrongholdSecretManager::builder() .password(std::env::var("STRONGHOLD_PASSWORD").unwrap()) diff --git a/sdk/examples/how_tos/accounts_and_addresses/list_outputs.rs b/sdk/examples/how_tos/accounts_and_addresses/list_outputs.rs index 9c732c4831..76eb7ca140 100644 --- a/sdk/examples/how_tos/accounts_and_addresses/list_outputs.rs +++ b/sdk/examples/how_tos/accounts_and_addresses/list_outputs.rs @@ -15,6 +15,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["WALLET_DB_PATH"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/accounts_and_addresses/list_transactions.rs b/sdk/examples/how_tos/accounts_and_addresses/list_transactions.rs index 6d07e6cb7c..b1b46d88ec 100644 --- a/sdk/examples/how_tos/accounts_and_addresses/list_transactions.rs +++ b/sdk/examples/how_tos/accounts_and_addresses/list_transactions.rs @@ -18,6 +18,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["WALLET_DB_PATH"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs b/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs index 7c9ba9c99a..6b07de8487 100644 --- a/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs +++ b/sdk/examples/how_tos/advanced_transactions/advanced_transaction.rs @@ -25,6 +25,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "EXPLORER_URL", "STRONGHOLD_PASSWORD"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Get the wallet we generated with `create_wallet`. let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) diff --git a/sdk/examples/how_tos/advanced_transactions/claim_transaction.rs b/sdk/examples/how_tos/advanced_transactions/claim_transaction.rs index 68319df0a9..6e8a8a60f3 100644 --- a/sdk/examples/how_tos/advanced_transactions/claim_transaction.rs +++ b/sdk/examples/how_tos/advanced_transactions/claim_transaction.rs @@ -16,6 +16,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "EXPLORER_URL", "STRONGHOLD_PASSWORD"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Get the wallet we generated with `create_wallet`. let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) diff --git a/sdk/examples/how_tos/advanced_transactions/send_micro_transaction.rs b/sdk/examples/how_tos/advanced_transactions/send_micro_transaction.rs index a4ddb1db9e..80b50eae56 100644 --- a/sdk/examples/how_tos/advanced_transactions/send_micro_transaction.rs +++ b/sdk/examples/how_tos/advanced_transactions/send_micro_transaction.rs @@ -26,6 +26,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Get the wallet we generated with `create_wallet`. let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) diff --git a/sdk/examples/how_tos/client/get_health.rs b/sdk/examples/how_tos/client/get_health.rs index ab0a68262d..7a42ef8978 100644 --- a/sdk/examples/how_tos/client/get_health.rs +++ b/sdk/examples/how_tos/client/get_health.rs @@ -18,7 +18,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(1) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .unwrap_or_else(|| std::env::var("NODE_URL").expect("NODE_URL not set")); // Create a node client. let client = Client::builder() diff --git a/sdk/examples/how_tos/client/get_info.rs b/sdk/examples/how_tos/client/get_info.rs index 6751dfebf4..a5d6251471 100644 --- a/sdk/examples/how_tos/client/get_info.rs +++ b/sdk/examples/how_tos/client/get_info.rs @@ -18,7 +18,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(1) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .unwrap_or_else(|| std::env::var("NODE_URL").expect("NODE_URL not set")); // Create a node client. let client = Client::builder() diff --git a/sdk/examples/how_tos/client/get_outputs.rs b/sdk/examples/how_tos/client/get_outputs.rs index 567dd80cf5..ec0819c4e1 100644 --- a/sdk/examples/how_tos/client/get_outputs.rs +++ b/sdk/examples/how_tos/client/get_outputs.rs @@ -25,7 +25,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) - .unwrap_or_else(|| std::env::var("NODE_URL").unwrap()); + .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?; diff --git a/sdk/examples/how_tos/native_tokens/burn.rs b/sdk/examples/how_tos/native_tokens/burn.rs index 15d0985236..42e2a3773e 100644 --- a/sdk/examples/how_tos/native_tokens/burn.rs +++ b/sdk/examples/how_tos/native_tokens/burn.rs @@ -32,6 +32,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/native_tokens/create.rs b/sdk/examples/how_tos/native_tokens/create.rs index c47b7f8275..467162c741 100644 --- a/sdk/examples/how_tos/native_tokens/create.rs +++ b/sdk/examples/how_tos/native_tokens/create.rs @@ -27,6 +27,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/native_tokens/destroy_foundry.rs b/sdk/examples/how_tos/native_tokens/destroy_foundry.rs index a324f366db..3304548b9d 100644 --- a/sdk/examples/how_tos/native_tokens/destroy_foundry.rs +++ b/sdk/examples/how_tos/native_tokens/destroy_foundry.rs @@ -19,6 +19,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/native_tokens/melt.rs b/sdk/examples/how_tos/native_tokens/melt.rs index 90bdcc34d0..779beda4fe 100644 --- a/sdk/examples/how_tos/native_tokens/melt.rs +++ b/sdk/examples/how_tos/native_tokens/melt.rs @@ -26,6 +26,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/native_tokens/mint.rs b/sdk/examples/how_tos/native_tokens/mint.rs index 46a6ddfce9..44ed6db3ab 100644 --- a/sdk/examples/how_tos/native_tokens/mint.rs +++ b/sdk/examples/how_tos/native_tokens/mint.rs @@ -26,6 +26,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/native_tokens/send.rs b/sdk/examples/how_tos/native_tokens/send.rs index 01b0b5ec2b..5e765bd153 100644 --- a/sdk/examples/how_tos/native_tokens/send.rs +++ b/sdk/examples/how_tos/native_tokens/send.rs @@ -28,6 +28,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/nft_collection/00_mint_issuer_nft.rs b/sdk/examples/how_tos/nft_collection/00_mint_issuer_nft.rs index 4023bfc015..2a0e5bca56 100644 --- a/sdk/examples/how_tos/nft_collection/00_mint_issuer_nft.rs +++ b/sdk/examples/how_tos/nft_collection/00_mint_issuer_nft.rs @@ -28,6 +28,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/nft_collection/01_mint_collection_nft.rs b/sdk/examples/how_tos/nft_collection/01_mint_collection_nft.rs index b71ff05350..914897800e 100644 --- a/sdk/examples/how_tos/nft_collection/01_mint_collection_nft.rs +++ b/sdk/examples/how_tos/nft_collection/01_mint_collection_nft.rs @@ -34,6 +34,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let issuer_nft_id = std::env::args() .nth(1) .expect("missing example argument: ISSUER_NFT_ID") diff --git a/sdk/examples/how_tos/nfts/burn_nft.rs b/sdk/examples/how_tos/nfts/burn_nft.rs index 84a4ab2df5..227a777063 100644 --- a/sdk/examples/how_tos/nfts/burn_nft.rs +++ b/sdk/examples/how_tos/nfts/burn_nft.rs @@ -18,6 +18,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create the wallet let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) diff --git a/sdk/examples/how_tos/nfts/mint_nft.rs b/sdk/examples/how_tos/nfts/mint_nft.rs index b1af051b4c..10264f07c9 100644 --- a/sdk/examples/how_tos/nfts/mint_nft.rs +++ b/sdk/examples/how_tos/nfts/mint_nft.rs @@ -35,6 +35,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Get the wallet we generated with `create_wallet`. let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) diff --git a/sdk/examples/how_tos/nfts/send_nft.rs b/sdk/examples/how_tos/nfts/send_nft.rs index 4c24e104ff..ba4b29d288 100644 --- a/sdk/examples/how_tos/nfts/send_nft.rs +++ b/sdk/examples/how_tos/nfts/send_nft.rs @@ -24,6 +24,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create the wallet let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) diff --git a/sdk/examples/how_tos/outputs/features.rs b/sdk/examples/how_tos/outputs/features.rs index ca51095bb4..78d991872f 100644 --- a/sdk/examples/how_tos/outputs/features.rs +++ b/sdk/examples/how_tos/outputs/features.rs @@ -25,6 +25,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); // Create a client instance. diff --git a/sdk/examples/how_tos/outputs/unlock_conditions.rs b/sdk/examples/how_tos/outputs/unlock_conditions.rs index 0683de7f86..f41162d555 100644 --- a/sdk/examples/how_tos/outputs/unlock_conditions.rs +++ b/sdk/examples/how_tos/outputs/unlock_conditions.rs @@ -27,6 +27,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let node_url = std::env::var("NODE_URL").unwrap(); // Create a client instance. diff --git a/sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs b/sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs index fde71e50a2..9304b224ab 100644 --- a/sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs +++ b/sdk/examples/how_tos/sign_and_verify_ed25519/sign_ed25519.rs @@ -29,6 +29,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["STRONGHOLD_PASSWORD", "MNEMONIC"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Setup Stronghold secret_manager let stronghold = StrongholdSecretManager::builder() .password(std::env::var("STRONGHOLD_PASSWORD").unwrap()) diff --git a/sdk/examples/how_tos/simple_transaction/request_funds.rs b/sdk/examples/how_tos/simple_transaction/request_funds.rs index 2b19ae1d8f..13a0de5254 100644 --- a/sdk/examples/how_tos/simple_transaction/request_funds.rs +++ b/sdk/examples/how_tos/simple_transaction/request_funds.rs @@ -18,6 +18,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "FAUCET_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/how_tos/simple_transaction/simple_transaction.rs b/sdk/examples/how_tos/simple_transaction/simple_transaction.rs index 16915f60b0..9990e6843e 100644 --- a/sdk/examples/how_tos/simple_transaction/simple_transaction.rs +++ b/sdk/examples/how_tos/simple_transaction/simple_transaction.rs @@ -23,6 +23,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/wallet/17_check_unlock_conditions.rs b/sdk/examples/wallet/17_check_unlock_conditions.rs index f961427fb5..dda853bc04 100644 --- a/sdk/examples/wallet/17_check_unlock_conditions.rs +++ b/sdk/examples/wallet/17_check_unlock_conditions.rs @@ -24,6 +24,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["WALLET_DB_PATH"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/wallet/background_syncing.rs b/sdk/examples/wallet/background_syncing.rs index 9cb953ebca..c2e2ee3407 100644 --- a/sdk/examples/wallet/background_syncing.rs +++ b/sdk/examples/wallet/background_syncing.rs @@ -23,6 +23,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC", "WALLET_DB_PATH", "FAUCET_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create a wallet let client_options = ClientOptions::new().with_node(&std::env::var("NODE_URL").unwrap())?; let secret_manager = MnemonicSecretManager::try_from_mnemonic(std::env::var("MNEMONIC").unwrap())?; diff --git a/sdk/examples/wallet/events.rs b/sdk/examples/wallet/events.rs index c2e2d99ec5..0c714a85ba 100644 --- a/sdk/examples/wallet/events.rs +++ b/sdk/examples/wallet/events.rs @@ -32,6 +32,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC", "WALLET_DB_PATH", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let client_options = ClientOptions::new().with_node(&std::env::var("NODE_URL").unwrap())?; let secret_manager = MnemonicSecretManager::try_from_mnemonic(std::env::var("MNEMONIC").unwrap())?; diff --git a/sdk/examples/wallet/getting_started.rs b/sdk/examples/wallet/getting_started.rs index 35b1431d23..ca224dd04c 100644 --- a/sdk/examples/wallet/getting_started.rs +++ b/sdk/examples/wallet/getting_started.rs @@ -19,13 +19,21 @@ use iota_sdk::{ #[tokio::main] async fn main() -> Result<()> { + // This example uses secrets in environment variables for simplicity which should not be done in production. + dotenvy::dotenv().ok(); + + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Setup Stronghold secret manager. // WARNING: Never hardcode passwords in production code. let secret_manager = StrongholdSecretManager::builder() .password("password".to_owned()) // A password to encrypt the stored data. .build("vault.stronghold")?; // The path to store the wallet snapshot. - let client_options = ClientOptions::new().with_node("https://api.testnet.shimmer.network")?; + let client_options = ClientOptions::new().with_node(&std::env::var("NODE_URL").unwrap())?; // Set up and store the wallet. let wallet = Wallet::builder() diff --git a/sdk/examples/wallet/ledger_nano.rs b/sdk/examples/wallet/ledger_nano.rs index e428af78cb..d00faf9ff7 100644 --- a/sdk/examples/wallet/ledger_nano.rs +++ b/sdk/examples/wallet/ledger_nano.rs @@ -33,6 +33,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "WALLET_DB_PATH", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let client_options = ClientOptions::new().with_node(&std::env::var("NODE_URL").unwrap())?; let secret_manager = LedgerSecretManager::new(true); let wallet = Wallet::builder() diff --git a/sdk/examples/wallet/logger.rs b/sdk/examples/wallet/logger.rs index 43033a3bef..aea7bf146c 100644 --- a/sdk/examples/wallet/logger.rs +++ b/sdk/examples/wallet/logger.rs @@ -22,6 +22,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC", "WALLET_DB_PATH"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Initialize a logger that writes to the specified file let logger_output_config = fern_logger::LoggerOutputConfigBuilder::new() .name("example.log") diff --git a/sdk/examples/wallet/offline_signing/0_generate_address.rs b/sdk/examples/wallet/offline_signing/0_generate_address.rs index fa14f84112..f54a1b8c95 100644 --- a/sdk/examples/wallet/offline_signing/0_generate_address.rs +++ b/sdk/examples/wallet/offline_signing/0_generate_address.rs @@ -26,6 +26,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["STRONGHOLD_PASSWORD", "MNEMONIC"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let offline_client = ClientOptions::new(); // Setup Stronghold secret_manager diff --git a/sdk/examples/wallet/offline_signing/1_prepare_transaction.rs b/sdk/examples/wallet/offline_signing/1_prepare_transaction.rs index d9eee607cc..d5cfbfca99 100644 --- a/sdk/examples/wallet/offline_signing/1_prepare_transaction.rs +++ b/sdk/examples/wallet/offline_signing/1_prepare_transaction.rs @@ -31,6 +31,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["NODE_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let params = [SendParams::new(SEND_AMOUNT, RECV_ADDRESS)?]; // Recovers addresses from example `0_address_generation`. diff --git a/sdk/examples/wallet/offline_signing/2_sign_transaction.rs b/sdk/examples/wallet/offline_signing/2_sign_transaction.rs index a32f72c9ff..14b9e0f4b3 100644 --- a/sdk/examples/wallet/offline_signing/2_sign_transaction.rs +++ b/sdk/examples/wallet/offline_signing/2_sign_transaction.rs @@ -29,6 +29,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["STRONGHOLD_PASSWORD"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Setup Stronghold secret_manager let secret_manager = StrongholdSecretManager::builder() .password(std::env::var("STRONGHOLD_PASSWORD").unwrap()) diff --git a/sdk/examples/wallet/offline_signing/3_send_transaction.rs b/sdk/examples/wallet/offline_signing/3_send_transaction.rs index 43f68883f7..5a108b9fbc 100644 --- a/sdk/examples/wallet/offline_signing/3_send_transaction.rs +++ b/sdk/examples/wallet/offline_signing/3_send_transaction.rs @@ -27,6 +27,11 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + #[allow(clippy::single_element_loop)] + for var in ["EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + // Create the wallet with the secret_manager and client options let wallet = Wallet::builder() .with_storage_path(ONLINE_WALLET_DB_PATH) diff --git a/sdk/examples/wallet/participation.rs b/sdk/examples/wallet/participation.rs index d55f4059ea..190ff79462 100644 --- a/sdk/examples/wallet/participation.rs +++ b/sdk/examples/wallet/participation.rs @@ -42,6 +42,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["WALLET_DB_PATH", "STRONGHOLD_PASSWORD", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = Wallet::builder() .with_storage_path(&std::env::var("WALLET_DB_PATH").unwrap()) .finish() diff --git a/sdk/examples/wallet/spammer.rs b/sdk/examples/wallet/spammer.rs index 9387836fd1..370c1b01d8 100644 --- a/sdk/examples/wallet/spammer.rs +++ b/sdk/examples/wallet/spammer.rs @@ -35,6 +35,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC", "EXPLORER_URL", "FAUCET_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let num_simultaneous_txs = NUM_SIMULTANEOUS_TXS.min(num_cpus::get()); println!("Spammer set up to issue {num_simultaneous_txs} transactions simultaneously."); diff --git a/sdk/examples/wallet/storage.rs b/sdk/examples/wallet/storage.rs index fa1b3b571d..d04ec6f656 100644 --- a/sdk/examples/wallet/storage.rs +++ b/sdk/examples/wallet/storage.rs @@ -22,6 +22,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC", "WALLET_DB_PATH"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let secret_manager = MnemonicSecretManager::try_from_mnemonic(std::env::var("MNEMONIC").unwrap())?; let client_options = ClientOptions::new().with_node(&std::env::var("NODE_URL").unwrap())?; diff --git a/sdk/examples/wallet/wallet.rs b/sdk/examples/wallet/wallet.rs index 12f8b2ec33..de5b8cf48c 100644 --- a/sdk/examples/wallet/wallet.rs +++ b/sdk/examples/wallet/wallet.rs @@ -34,6 +34,10 @@ async fn main() -> Result<()> { // This example uses secrets in environment variables for simplicity which should not be done in production. dotenvy::dotenv().ok(); + for var in ["NODE_URL", "MNEMONIC", "WALLET_DB_PATH", "EXPLORER_URL"] { + std::env::var(var).unwrap_or_else(|_| panic!(".env variable '{var}' is undefined, see .env.example")); + } + let wallet = create_wallet().await?; // Change to `true` to print the full balance report diff --git a/sdk/src/client/secret/ledger_nano.rs b/sdk/src/client/secret/ledger_nano.rs index d499e5dc76..0519b5447f 100644 --- a/sdk/src/client/secret/ledger_nano.rs +++ b/sdk/src/client/secret/ledger_nano.rs @@ -431,12 +431,9 @@ impl SecretManagerConfig for LedgerSecretManager { /// If criteria are not met, blind signing is needed. /// This method finds out if we have to switch to blind signing mode. pub fn needs_blind_signing(prepared_transaction: &PreparedTransactionData, buffer_size: usize) -> bool { - if !prepared_transaction - .transaction - .outputs() - .iter() - .all(|output| matches!(output, Output::Basic(o) if o.simple_deposit_address().is_some())) - { + if !prepared_transaction.transaction.outputs().iter().all( + |output| matches!(output, Output::Basic(o) if o.simple_deposit_address().is_some()&& o.address().is_ed25519()), + ) { return true; }