From 3d1b716da3f6088069ec2692d187552a71037e44 Mon Sep 17 00:00:00 2001 From: PhilippGackstatter Date: Thu, 21 Oct 2021 17:40:37 +0200 Subject: [PATCH] Use `IdentityBuilder` in examples --- examples/account/config.rs | 5 +---- examples/account/create_did.rs | 4 ++-- examples/account/lazy.rs | 5 ++--- examples/account/manipulate_did.rs | 4 ++-- examples/account/signing.rs | 4 ++-- identity-account/src/tests/account.rs | 7 +++---- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/examples/account/config.rs b/examples/account/config.rs index f0fffb1dc7..1b5815daf2 100644 --- a/examples/account/config.rs +++ b/examples/account/config.rs @@ -7,7 +7,6 @@ use identity::account::Account; use identity::account::AccountBuilder; use identity::account::AccountStorage; use identity::account::AutoSave; -use identity::account::IdentityCreate; use identity::account::Result; use identity::iota::IotaDID; use identity::iota::Network; @@ -55,10 +54,8 @@ async fn main() -> Result<()> { // Create an identity specifically on the devnet by passing `network_name` // The same applies if we wanted to create an identity on a private tangle - let id_create = IdentityCreate::new().network(network_name)?; - // Create a new Identity with the network name set. - let identity: Account = match builder.create_identity(id_create).await { + let identity: Account = match builder.create_identity().network(network_name)?.build().await { Ok(identity) => identity, Err(err) => { eprintln!("[Example] Error: {:?} {}", err, err.to_string()); diff --git a/examples/account/create_did.rs b/examples/account/create_did.rs index 1742a19611..da3d064433 100644 --- a/examples/account/create_did.rs +++ b/examples/account/create_did.rs @@ -7,7 +7,6 @@ use std::path::PathBuf; use identity::account::Account; use identity::account::AccountStorage; -use identity::account::IdentityCreate; use identity::account::Result; use identity::iota::IotaDID; @@ -28,7 +27,8 @@ async fn main() -> Result<()> { // and publishes it to the IOTA mainnet. let account: Account = Account::builder() .storage(AccountStorage::Stronghold(stronghold_path, Some(password))) - .create_identity(IdentityCreate::default()) + .create_identity() + .build() .await?; // Retrieve the did of the newly created identity. diff --git a/examples/account/lazy.rs b/examples/account/lazy.rs index 1a8b9010a2..c538235880 100644 --- a/examples/account/lazy.rs +++ b/examples/account/lazy.rs @@ -6,7 +6,6 @@ use std::path::PathBuf; use identity::account::Account; use identity::account::AccountStorage; -use identity::account::IdentityCreate; use identity::account::Result; use identity::core::Url; use identity::iota::IotaDID; @@ -24,8 +23,8 @@ async fn main() -> Result<()> { // Rather, when we publish, multiple updates are batched together. let mut account: Account = Account::builder() .storage(AccountStorage::Stronghold(stronghold_path, Some(password))) - .autopublish(false) - .create_identity(IdentityCreate::default()) + .create_identity() + .build() .await?; // Add a new service to the local DID document. diff --git a/examples/account/manipulate_did.rs b/examples/account/manipulate_did.rs index fcaf69f67e..59e2a79119 100644 --- a/examples/account/manipulate_did.rs +++ b/examples/account/manipulate_did.rs @@ -7,7 +7,6 @@ use std::path::PathBuf; use identity::account::Account; use identity::account::AccountStorage; -use identity::account::IdentityCreate; use identity::account::Result; use identity::core::Url; use identity::did::MethodScope; @@ -28,7 +27,8 @@ async fn main() -> Result<()> { // Create a new Account with the default configuration let mut account: Account = Account::builder() .storage(AccountStorage::Stronghold(stronghold_path, Some(password))) - .create_identity(IdentityCreate::default()) + .create_identity() + .build() .await?; // =========================================================================== diff --git a/examples/account/signing.rs b/examples/account/signing.rs index 5ef1b00024..85b841c847 100644 --- a/examples/account/signing.rs +++ b/examples/account/signing.rs @@ -7,7 +7,6 @@ use std::path::PathBuf; use identity::account::Account; use identity::account::AccountStorage; -use identity::account::IdentityCreate; use identity::account::Result; use identity::core::json; use identity::core::FromJson; @@ -33,7 +32,8 @@ async fn main() -> Result<()> { // Create a new Account with stronghold storage. let mut account: Account = Account::builder() .storage(AccountStorage::Stronghold(stronghold_path, Some(password))) - .create_identity(IdentityCreate::default()) + .create_identity() + .build() .await?; // =========================================================================== diff --git a/identity-account/src/tests/account.rs b/identity-account/src/tests/account.rs index 82777be74d..06e50699fa 100644 --- a/identity-account/src/tests/account.rs +++ b/identity-account/src/tests/account.rs @@ -6,17 +6,16 @@ use identity_iota::did::IotaDID; use crate::account::Account; use crate::account::AccountBuilder; use crate::error::Result; -use crate::identity::IdentityCreate; #[tokio::test] async fn test_account_high_level() -> Result<()> { let mut builder: AccountBuilder = AccountBuilder::default().testmode(true); - let account1: Account = builder.create_identity(IdentityCreate::default()).await?; + let account1: Account = builder.create_identity().build().await?; builder = builder.autopublish(false); - let account2: Account = builder.create_identity(IdentityCreate::default()).await?; + let account2: Account = builder.create_identity().build().await?; assert!(account1.autopublish()); assert!(!account2.autopublish()); @@ -40,7 +39,7 @@ async fn test_account_did_lease() -> Result<()> { let mut builder: AccountBuilder = AccountBuilder::default().testmode(true); let did: IotaDID = { - let account: Account = builder.create_identity(IdentityCreate::default()).await?; + let account: Account = builder.create_identity().build().await?; account.did().to_owned() }; // <-- Lease released here.