Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix README.md example code and instructions #1481

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ To try out the [examples](https://github.com/iotaledger/identity.rs/blob/HEAD/ex
3. Start a local network for testing with `iota start --force-regenesis --with-faucet`.
4. Request funds with `iota client faucet`.
5. Publish a test identity package to your local network: `./identity_iota_core/scripts/publish_identity_package.sh`.
6. Get the `packageId` value from the output (the entry with `"type": "published"`) and pass this as `IDENTITY_IOTA_PKG_ID` env value.
7. Run the example to create a DID using `IDENTITY_IOTA_PKG_ID=(the value from previous step) run --release --example 0_create_did`
6. Get the `packageId` value from the output (the entry with `"type": "published"`) and pass this as `IOTA_IDENTITY_PKG_ID` env value.
7. Run the example to create a DID using `IOTA_IDENTITY_PKG_ID=(the value from previous step) run --release --example 0_create_did`

## Example: Creating an Identity

Expand Down Expand Up @@ -151,14 +151,14 @@ async fn main() -> anyhow::Result<()> {
let public_key_jwk = generate.jwk.to_public().expect("public components should be derivable");
let public_key_bytes = get_sender_public_key(&public_key_jwk)?;
let sender_address = convert_to_address(&public_key_bytes)?;
let package_id = std::env::var("IDENTITY_IOTA_PKG_ID")
let package_id = std::env::var("IOTA_IDENTITY_PKG_ID")
.map_err(|e| {
anyhow::anyhow!("env variable IDENTITY_IOTA_PKG_ID must be set in order to run the examples").context(e)
anyhow::anyhow!("env variable IOTA_IDENTITY_PKG_ID must be set in order to run the examples").context(e)
})
.and_then(|pkg_str| pkg_str.parse().context("invalid package id"))?;

// Create identity client with signing capabilities.
let read_only_client = IdentityClientReadOnly::new(iota_client, package_id).await?;
let read_only_client = IdentityClientReadOnly::new_with_pkg_id(iota_client, package_id).await?;
let signer = StorageSigner::new(&storage, generate.key_id, public_key_jwk);
let identity_client = IdentityClient::new(read_only_client, signer).await?;

Expand Down Expand Up @@ -215,8 +215,6 @@ _Example output_
"meta": {
"created": "2023-08-29T14:47:26Z",
"updated": "2023-08-29T14:47:26Z",
"governorAddress": "tst1qqd7kyu8xadzx9vutznu72336npqpj92jtp27uyu2tj2sa5hx6n3k0vrzwv",
"stateControllerAddress": "tst1qqd7kyu8xadzx9vutznu72336npqpj92jtp27uyu2tj2sa5hx6n3k0vrzwv"
}
}
```
Expand Down
12 changes: 5 additions & 7 deletions identity_iota/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ To try out the [examples](https://github.com/iotaledger/identity.rs/blob/HEAD/ex
3. Start a local network for testing with `iota start --force-regenesis --with-faucet`.
4. Request funds with `iota client faucet`.
5. Publish a test identity package to your local network: `./identity_iota_core/scripts/publish_identity_package.sh`.
6. Get the `packageId` value from the output (the entry with `"type": "published"`) and pass this as `IDENTITY_IOTA_PKG_ID` env value.
7. Run the example to create a DID using `IDENTITY_IOTA_PKG_ID=(the value from previous step) run --release --example 0_create_did`
6. Get the `packageId` value from the output (the entry with `"type": "published"`) and pass this as `IOTA_IDENTITY_PKG_ID` env value.
7. Run the example to create a DID using `IOTA_IDENTITY_PKG_ID=(the value from previous step) run --release --example 0_create_did`

## Example: Creating an Identity

Expand Down Expand Up @@ -151,14 +151,14 @@ async fn main() -> anyhow::Result<()> {
let public_key_jwk = generate.jwk.to_public().expect("public components should be derivable");
let public_key_bytes = get_sender_public_key(&public_key_jwk)?;
let sender_address = convert_to_address(&public_key_bytes)?;
let package_id = std::env::var("IDENTITY_IOTA_PKG_ID")
let package_id = std::env::var("IOTA_IDENTITY_PKG_ID")
.map_err(|e| {
anyhow::anyhow!("env variable IDENTITY_IOTA_PKG_ID must be set in order to run the examples").context(e)
anyhow::anyhow!("env variable IOTA_IDENTITY_PKG_ID must be set in order to run the examples").context(e)
})
.and_then(|pkg_str| pkg_str.parse().context("invalid package id"))?;

// Create identity client with signing capabilities.
let read_only_client = IdentityClientReadOnly::new(iota_client, package_id).await?;
let read_only_client = IdentityClientReadOnly::new_with_pkg_id(iota_client, package_id).await?;
let signer = StorageSigner::new(&storage, generate.key_id, public_key_jwk);
let identity_client = IdentityClient::new(read_only_client, signer).await?;

Expand Down Expand Up @@ -215,8 +215,6 @@ _Example output_
"meta": {
"created": "2023-08-29T14:47:26Z",
"updated": "2023-08-29T14:47:26Z",
"governorAddress": "tst1qqd7kyu8xadzx9vutznu72336npqpj92jtp27uyu2tj2sa5hx6n3k0vrzwv",
"stateControllerAddress": "tst1qqd7kyu8xadzx9vutznu72336npqpj92jtp27uyu2tj2sa5hx6n3k0vrzwv"
}
}
```
Expand Down
Loading