Skip to content

Commit

Permalink
fix examples from readme
Browse files Browse the repository at this point in the history
  • Loading branch information
wulfraem committed Nov 28, 2024
1 parent 3414ac9 commit f2db8ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
17 changes: 5 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Test this example using https://github.com/anko/txm: `txm README.md`
!test program
cd ../..
mkdir tmp
cat | sed -e 's#identity_iota = { git = "[^"]*"#identity_iota = { path = "../identity_iota"#' > tmp/Cargo.toml
cat | sed -e 's#identity_iota = { git = "[^"]*", tag = "[^"]*"#identity_iota = { path = "../identity_iota"#' > tmp/Cargo.toml
echo '[workspace]' >>tmp/Cargo.toml
-->
<!-- !test check Cargo Example -->
Expand All @@ -93,7 +93,7 @@ edition = "2021"

[dependencies]
identity_iota = { git = "https://github.com/iotaledger/identity.rs.git", tag = "v1.6.0-alpha", features = ["memstore"] }
iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v0.7.0-alpha" }
iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", rev = "39c83ddcf07894cdee2abd146381d8704205e6e9" }
tokio = { version = "1", features = ["full"] }
anyhow = "1.0.62"
rand = "0.8.5"
Expand All @@ -113,7 +113,6 @@ timeout 360 cargo build || (echo "Process timed out after 360 seconds" && exit 1
-->
<!-- !test check Rust Example -->


```rust,no_run
use anyhow::Context;
use identity_iota::iota::IotaDocument;
Expand All @@ -134,18 +133,12 @@ use identity_iota::verification::MethodScope;
use iota_sdk::IotaClientBuilder;
use tokio::io::AsyncReadExt;
// The endpoint of the IOTA node to use.
static API_ENDPOINT: &str = "http://localhost";
// Test budget for transactions.
const TEST_GAS_BUDGET: u64 = 50_000_000;
/// Demonstrates how to create a DID Document and publish it in a new identity.
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a new client to interact with the IOTA ledger.
let iota_client = IotaClientBuilder::default()
.build(API_ENDPOINT)
.build_localnet()
.await
.map_err(|err| anyhow::anyhow!(format!("failed to connect to network; {}", err)))?;
Expand All @@ -170,12 +163,12 @@ async fn main() -> anyhow::Result<()> {
let identity_client = IdentityClient::new(read_only_client, signer).await?;
println!("Your wallet address is: {}", sender_address);
println!("Please request funds from http://localhost/faucet/, wait for a couple of seconds and then press Enter.");
println!("Please request funds from http://127.0.0.1:9123/gas, wait for a couple of seconds and then press Enter.");
tokio::io::stdin().read_u8().await?;
// Create a new DID document with a placeholder DID.
let mut unpublished: IotaDocument = IotaDocument::new(identity_client.network());
let verification_method_fragment = unpublished
unpublished
.generate_method(
&storage,
JwkMemStore::ED25519_KEY_TYPE,
Expand Down
17 changes: 5 additions & 12 deletions identity_iota/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Test this example using https://github.com/anko/txm: `txm README.md`
!test program
cd ../..
mkdir tmp
cat | sed -e 's#identity_iota = { git = "[^"]*"#identity_iota = { path = "../identity_iota"#' > tmp/Cargo.toml
cat | sed -e 's#identity_iota = { git = "[^"]*", tag = "[^"]*"#identity_iota = { path = "../identity_iota"#' > tmp/Cargo.toml
echo '[workspace]' >>tmp/Cargo.toml
-->
<!-- !test check Cargo Example -->
Expand All @@ -93,7 +93,7 @@ edition = "2021"

[dependencies]
identity_iota = { git = "https://github.com/iotaledger/identity.rs.git", tag = "v1.6.0-alpha", features = ["memstore"] }
iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v0.7.0-alpha" }
iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", rev = "39c83ddcf07894cdee2abd146381d8704205e6e9" }
tokio = { version = "1", features = ["full"] }
anyhow = "1.0.62"
rand = "0.8.5"
Expand All @@ -113,7 +113,6 @@ timeout 360 cargo build || (echo "Process timed out after 360 seconds" && exit 1
-->
<!-- !test check Rust Example -->


```rust,no_run
use anyhow::Context;
use identity_iota::iota::IotaDocument;
Expand All @@ -134,18 +133,12 @@ use identity_iota::verification::MethodScope;
use iota_sdk::IotaClientBuilder;
use tokio::io::AsyncReadExt;
// The endpoint of the IOTA node to use.
static API_ENDPOINT: &str = "http://localhost";
// Test budget for transactions.
const TEST_GAS_BUDGET: u64 = 50_000_000;
/// Demonstrates how to create a DID Document and publish it in a new identity.
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Create a new client to interact with the IOTA ledger.
let iota_client = IotaClientBuilder::default()
.build(API_ENDPOINT)
.build_localnet()
.await
.map_err(|err| anyhow::anyhow!(format!("failed to connect to network; {}", err)))?;
Expand All @@ -170,12 +163,12 @@ async fn main() -> anyhow::Result<()> {
let identity_client = IdentityClient::new(read_only_client, signer).await?;
println!("Your wallet address is: {}", sender_address);
println!("Please request funds from http://localhost/faucet/, wait for a couple of seconds and then press Enter.");
println!("Please request funds from http://127.0.0.1:9123/gas, wait for a couple of seconds and then press Enter.");
tokio::io::stdin().read_u8().await?;
// Create a new DID document with a placeholder DID.
let mut unpublished: IotaDocument = IotaDocument::new(identity_client.network());
let verification_method_fragment = unpublished
unpublished
.generate_method(
&storage,
JwkMemStore::ED25519_KEY_TYPE,
Expand Down

0 comments on commit f2db8ad

Please sign in to comment.