From 34c200ce99ce50cf87f7949016294635f6cedfc0 Mon Sep 17 00:00:00 2001 From: Enrico Marconi <31142849+UMR1352@users.noreply.github.com> Date: Fri, 29 Nov 2024 14:38:28 +0100 Subject: [PATCH] Fix CI issues (#1458) * debug output * test * publish package before running the test harness * remove 'with' clause in workflow * publish package without script * fix typo * request funds and add dbg statement * remove faucet call * debug error * add output that could not be parsed to error message * comment out debug log in publishing script * make sure package id env is set * update publish package script handling in tests and grpc to follow update * fix clippy issues * fix dependencies for doc test * fix clippy issues * fix clippy issues * fix clippy issues * fix clippy issues * fix examples from readme * add action auth token to release check and check response status * update action token to execution step scoped variant * add check for parsed download url * set IOTA binary version to fixed urls - avoid CI breaking on releases, where binariese have not yet been published * bump iota dependencies to `v0.7.3-rc` --------- Co-authored-by: Sebastian Wolfram --- .../iota-rebase-sandbox/setup/action.yml | 20 +++++++++++++---- .github/workflows/build-and-test.yml | 9 ++++++++ README.md | 21 ++++++------------ bindings/grpc/Cargo.toml | 2 +- bindings/grpc/tests/api/helpers.rs | 18 +++++---------- examples/Cargo.toml | 4 ++-- examples/utils/utils.rs | 4 ++-- .../src/credential/jwt_serialization.rs | 2 +- .../domain_linkage_validator.rs | 1 - .../src/presentation/jwt_serialization.rs | 2 +- .../src/revocation/status_list_2021/entry.rs | 2 +- .../revocation_timeframe_status.rs | 2 +- .../src/document/core_document.rs | 4 ++-- identity_document/src/utils/did_url_query.rs | 4 ++-- identity_iota/Cargo.toml | 8 +++++++ identity_iota/README.md | 21 ++++++------------ identity_iota_core/Cargo.toml | 8 +++---- .../packages/iota_identity/Move.toml | 8 ++++--- .../scripts/publish_identity_package.sh | 7 +++--- .../src/document/iota_document.rs | 4 ++-- .../src/rebased/assets/asset.rs | 4 ++-- .../src/rebased/migration/alias.rs | 1 - .../src/rebased/migration/identity.rs | 2 +- .../src/rebased/proposals/borrow.rs | 4 ++-- .../src/rebased/proposals/config_change.rs | 2 +- .../src/rebased/proposals/controller.rs | 2 +- .../src/rebased/proposals/mod.rs | 10 ++++----- .../src/rebased/proposals/send.rs | 2 +- identity_iota_core/tests/e2e/common.rs | 22 ++++++++----------- identity_jose/src/jws/decoder.rs | 2 +- identity_jose/src/jws/encoding/utils.rs | 4 ++-- identity_jose/src/jws/recipient.rs | 2 +- .../src/storage/storage_signer.rs | 4 ++-- 33 files changed, 109 insertions(+), 103 deletions(-) diff --git a/.github/actions/iota-rebase-sandbox/setup/action.yml b/.github/actions/iota-rebase-sandbox/setup/action.yml index 0f0554aa89..169fd4eca8 100644 --- a/.github/actions/iota-rebase-sandbox/setup/action.yml +++ b/.github/actions/iota-rebase-sandbox/setup/action.yml @@ -21,9 +21,17 @@ runs: PLATFORM="${{ inputs.platform }}" echo "Looking for platform: $PLATFORM" - # Get download URL - DOWNLOAD_URL=$(curl "https://api.github.com/repos/iotaledger/iota/releases/latest" | \ - jq -r --arg p "$PLATFORM" '.assets[] | select(.name | contains($p)) | .browser_download_url') + # pinned releases from: + # url = https://api.github.com/repos/iotaledger/iota/releases/latest + # releases might be visible before all binaries are available, so refer to fixed binaries here + if [ "$PLATFORM" = "linux" ]; then + DOWNLOAD_URL="https://github.com/iotaledger/iota/releases/download/v0.7.3-rc/iota-v0.7.3-rc-linux-x86_64.tgz" + elif [ "$PLATFORM" = "macos" ]; then + DOWNLOAD_URL="https://github.com/iotaledger/iota/releases/download/v0.7.3-rc/iota-v0.7.3-rc-macos-arm64.tgz" + else + echo "not binaries for platform: $PLATFORM" + exit 1 + fi # Download and extract echo "Downloading from: $DOWNLOAD_URL" @@ -38,4 +46,8 @@ runs: - name: Start the Network shell: bash working-directory: iota - run: iota start --with-faucet --force-regenesis & + run: | + # Clear previous configuration + rm -rf ~/.iota || true + # Start the network + iota start --with-faucet & diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index feef4c3b8a..4368cafa3e 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -135,6 +135,15 @@ jobs: with: platform: ${{ matrix.os == 'ubuntu-24.04' && 'linux' || 'macos' }} + - name: publish IotaIdentity package + if: matrix.os != 'windows-latest' + # publish the package and set the IOTA_IDENTITY_PKG_ID env variable + run: | + json_output=$(iota client publish --skip-dependency-verification --with-unpublished-dependencies --json --gas-budget 500000000 .) + package_id=$(echo $json_output | jq --raw-output '.objectChanges[] | select(.type | contains("published")) | .packageId') + echo "IOTA_IDENTITY_PKG_ID=$package_id" >> "$GITHUB_ENV" + working-directory: ./identity_iota_core/packages/iota_identity + - name: Run tests excluding `custom_time` feature if: matrix.os != 'windows-latest' run: cargo test --workspace --release diff --git a/README.md b/README.md index 5d1b736182..183c04bd95 100644 --- a/README.md +++ b/README.md @@ -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 --> @@ -92,11 +92,11 @@ version = "1.0.0" 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" } -tokio = { version = "1", features = ["full"] } anyhow = "1.0.62" +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.3-rc" } rand = "0.8.5" +tokio = { version = "1", features = ["full"] } ``` _main.__rs_ @@ -113,7 +113,6 @@ timeout 360 cargo build || (echo "Process timed out after 360 seconds" && exit 1 --> - ```rust,no_run use anyhow::Context; use identity_iota::iota::IotaDocument; @@ -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)))?; @@ -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, diff --git a/bindings/grpc/Cargo.toml b/bindings/grpc/Cargo.toml index 85c26daa78..f2830d183d 100644 --- a/bindings/grpc/Cargo.toml +++ b/bindings/grpc/Cargo.toml @@ -24,7 +24,7 @@ identity_iota = { path = "../../identity_iota", features = ["resolver", "sd-jwt" identity_jose = { path = "../../identity_jose" } identity_storage = { path = "../../identity_storage", features = ["memstore"] } identity_stronghold = { path = "../../identity_stronghold", features = ["send-sync-storage"] } -iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", rev = "39c83ddcf07894cdee2abd146381d8704205e6e9" } +iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v0.7.3-rc" } iota-sdk-legacy = { package = "iota-sdk", version = "1.1.2", features = ["stronghold"] } prost = "0.13" rand = "0.8.5" diff --git a/bindings/grpc/tests/api/helpers.rs b/bindings/grpc/tests/api/helpers.rs index 97c50b2b07..a2b58fedf4 100644 --- a/bindings/grpc/tests/api/helpers.rs +++ b/bindings/grpc/tests/api/helpers.rs @@ -38,6 +38,7 @@ use serde_json::Value; use std::io::Write; use std::net::SocketAddr; use std::path::PathBuf; +use std::str::FromStr; use tokio::net::TcpListener; use tokio::process::Command; @@ -375,20 +376,13 @@ async fn publish_package(active_address: IotaAddress) -> anyhow::Result(output_str[start_of_json..].trim())? + let package_id: ObjectID = { + let output_str = std::str::from_utf8(&output.stdout).unwrap().trim(); + ObjectID::from_str(output_str).context(format!( + "failed to find IDENTITY_IOTA_PKG_ID in response from: {output_str}" + ))? }; - let package_id = publish_result - .path("$.objectChanges[?(@.type == 'published')].packageId") - .map_err(|e| anyhow!("Failed to parse JSONPath: {e}")) - .and_then(|value| Ok(serde_json::from_value::>(value)?))? - .first() - .copied() - .ok_or_else(|| anyhow!("Failed to parse package ID after publishing"))?; - // Persist package ID in order to avoid publishing the package for every test. let package_id_str = package_id.to_string(); std::env::set_var("IDENTITY_IOTA_PKG_ID", package_id_str.as_str()); diff --git a/examples/Cargo.toml b/examples/Cargo.toml index c0af97083e..a280ec5d09 100644 --- a/examples/Cargo.toml +++ b/examples/Cargo.toml @@ -10,14 +10,14 @@ anyhow = "1.0.62" identity_eddsa_verifier = { path = "../identity_eddsa_verifier", default-features = false, features = ["ed25519"] } identity_storage = { path = "../identity_storage" } identity_stronghold = { path = "../identity_stronghold", default-features = false, features = ["send-sync-storage"] } -iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", rev = "39c83ddcf07894cdee2abd146381d8704205e6e9" } +iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v0.7.3-rc" } iota-sdk-legacy = { package = "iota-sdk", version = "1.0", default-features = false, features = ["tls", "client", "stronghold"] } json-proof-token.workspace = true rand = "0.8.5" sd-jwt-payload = { version = "0.2.1", default-features = false, features = ["sha"] } secret-storage = { git = "https://github.com/iotaledger/secret-storage.git", tag = "v0.1.0" } serde_json = { version = "1.0", default-features = false } -tokio = { version = "1.29", default-features = false, features = ["rt"] } +tokio = { version = "1.29", default-features = false, features = ["rt", "macros"] } [dependencies.identity_iota] path = "../identity_iota" diff --git a/examples/utils/utils.rs b/examples/utils/utils.rs index 47b350f132..ca9fd74da9 100644 --- a/examples/utils/utils.rs +++ b/examples/utils/utils.rs @@ -98,9 +98,9 @@ where let public_key_bytes = get_sender_public_key(&public_key_jwk)?; let sender_address = convert_to_address(&public_key_bytes)?; request_funds(&sender_address).await?; - 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"))?; diff --git a/identity_credential/src/credential/jwt_serialization.rs b/identity_credential/src/credential/jwt_serialization.rs index 82bb1ae24c..f2727741ca 100644 --- a/identity_credential/src/credential/jwt_serialization.rs +++ b/identity_credential/src/credential/jwt_serialization.rs @@ -131,7 +131,7 @@ where } #[cfg(feature = "validator")] -impl<'credential, T> CredentialJwtClaims<'credential, T> +impl CredentialJwtClaims<'_, T> where T: ToOwned + Serialize + DeserializeOwned, { diff --git a/identity_credential/src/domain_linkage/domain_linkage_validator.rs b/identity_credential/src/domain_linkage/domain_linkage_validator.rs index be67c96832..746a9b2f5a 100644 --- a/identity_credential/src/domain_linkage/domain_linkage_validator.rs +++ b/identity_credential/src/domain_linkage/domain_linkage_validator.rs @@ -21,7 +21,6 @@ use super::DomainLinkageValidationResult; use crate::utils::url_only_includes_origin; /// A validator for a Domain Linkage Configuration and Credentials. - pub struct JwtDomainLinkageValidator { validator: JwtCredentialValidator, } diff --git a/identity_credential/src/presentation/jwt_serialization.rs b/identity_credential/src/presentation/jwt_serialization.rs index d8bb18c238..50aab3d428 100644 --- a/identity_credential/src/presentation/jwt_serialization.rs +++ b/identity_credential/src/presentation/jwt_serialization.rs @@ -136,7 +136,7 @@ where } #[cfg(feature = "validator")] -impl<'presentation, CRED, T> PresentationJwtClaims<'presentation, CRED, T> +impl PresentationJwtClaims<'_, CRED, T> where CRED: ToOwned + Serialize + DeserializeOwned + Clone, T: ToOwned + Serialize + DeserializeOwned, diff --git a/identity_credential/src/revocation/status_list_2021/entry.rs b/identity_credential/src/revocation/status_list_2021/entry.rs index 92415d06b7..1108b5e7c1 100644 --- a/identity_credential/src/revocation/status_list_2021/entry.rs +++ b/identity_credential/src/revocation/status_list_2021/entry.rs @@ -18,7 +18,7 @@ where D: serde::Deserializer<'de>, { struct ExactStrVisitor(&'static str); - impl<'a> Visitor<'a> for ExactStrVisitor { + impl Visitor<'_> for ExactStrVisitor { type Value = &'static str; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "the exact string \"{}\"", self.0) diff --git a/identity_credential/src/revocation/validity_timeframe_2024/revocation_timeframe_status.rs b/identity_credential/src/revocation/validity_timeframe_2024/revocation_timeframe_status.rs index 0a70589112..6ae6ea74f8 100644 --- a/identity_credential/src/revocation/validity_timeframe_2024/revocation_timeframe_status.rs +++ b/identity_credential/src/revocation/validity_timeframe_2024/revocation_timeframe_status.rs @@ -18,7 +18,7 @@ where D: serde::Deserializer<'de>, { struct ExactStrVisitor(&'static str); - impl<'a> Visitor<'a> for ExactStrVisitor { + impl Visitor<'_> for ExactStrVisitor { type Value = &'static str; fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(formatter, "the exact string \"{}\"", self.0) diff --git a/identity_document/src/document/core_document.rs b/identity_document/src/document/core_document.rs index 2747f7fae6..1e1a340bb4 100644 --- a/identity_document/src/document/core_document.rs +++ b/identity_document/src/document/core_document.rs @@ -690,7 +690,7 @@ impl CoreDocument { &'me self, method_query: Q, scope: Option, - ) -> Option<&VerificationMethod> + ) -> Option<&'me VerificationMethod> where Q: Into>, { @@ -773,7 +773,7 @@ impl CoreDocument { /// Returns the first [`Service`] with an `id` property matching the provided `service_query`, if present. // NOTE: This method demonstrates unexpected behavior in the edge cases where the document contains // services whose ids are of the form #. - pub fn resolve_service<'query, 'me, Q>(&'me self, service_query: Q) -> Option<&Service> + pub fn resolve_service<'query, 'me, Q>(&'me self, service_query: Q) -> Option<&'me Service> where Q: Into>, { diff --git a/identity_document/src/utils/did_url_query.rs b/identity_document/src/utils/did_url_query.rs index 1af2b80b4c..d9399457e3 100644 --- a/identity_document/src/utils/did_url_query.rs +++ b/identity_document/src/utils/did_url_query.rs @@ -13,7 +13,7 @@ use identity_did::DID; #[repr(transparent)] pub struct DIDUrlQuery<'query>(Cow<'query, str>); -impl<'query> DIDUrlQuery<'query> { +impl DIDUrlQuery<'_> { /// Returns whether this query matches the given DIDUrl. pub(crate) fn matches(&self, did_url: &DIDUrl) -> bool { // Ensure the DID matches if included in the query. @@ -81,7 +81,7 @@ impl<'query> From<&'query DIDUrl> for DIDUrlQuery<'query> { } } -impl<'query> From for DIDUrlQuery<'query> { +impl From for DIDUrlQuery<'_> { fn from(other: DIDUrl) -> Self { Self(Cow::Owned(other.to_string())) } diff --git a/identity_iota/Cargo.toml b/identity_iota/Cargo.toml index 2475bf0862..260004f95e 100644 --- a/identity_iota/Cargo.toml +++ b/identity_iota/Cargo.toml @@ -21,6 +21,14 @@ identity_resolver = { version = "=1.4.0", path = "../identity_resolver", default identity_storage = { version = "=1.4.0", path = "../identity_storage", default-features = false, features = ["iota-document"] } identity_verification = { version = "=1.4.0", path = "../identity_verification", default-features = false } +[dev-dependencies] +# required for doc test +anyhow = "1.0.64" +identity_iota = { version = "=1.4.0", path = "./", features = ["memstore"] } +iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v0.7.3-rc" } +rand = "0.8.5" +tokio = { version = "1.29.0", features = ["full"] } + [features] default = ["revocation-bitmap", "iota-client", "resolver"] diff --git a/identity_iota/README.md b/identity_iota/README.md index c66dd54e34..2d50abfd5b 100644 --- a/identity_iota/README.md +++ b/identity_iota/README.md @@ -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 --> @@ -92,11 +92,11 @@ version = "1.0.0" edition = "2021" [dependencies] -identity_iota = { git = "https://github.com/iotaledger/identity.rs.git", tag = "v1.6.0-alpha" } -iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v0.7.0-alpha" } -tokio = { version = "1", features = ["full"] } anyhow = "1.0.62" +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.3-rc" } rand = "0.8.5" +tokio = { version = "1", features = ["full"] } ``` _main.__rs_ @@ -113,7 +113,6 @@ timeout 360 cargo build || (echo "Process timed out after 360 seconds" && exit 1 --> - ```rust,no_run use anyhow::Context; use identity_iota::iota::IotaDocument; @@ -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)))?; @@ -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, diff --git a/identity_iota_core/Cargo.toml b/identity_iota_core/Cargo.toml index 2023c6ad53..e2203ffe95 100644 --- a/identity_iota_core/Cargo.toml +++ b/identity_iota_core/Cargo.toml @@ -35,15 +35,15 @@ bcs = { version = "0.1.4", optional = true } fastcrypto = { git = "https://github.com/MystenLabs/fastcrypto", rev = "5f2c63266a065996d53f98156f0412782b468597", package = "fastcrypto", optional = true } identity_eddsa_verifier = { version = "=1.4.0", path = "../identity_eddsa_verifier", optional = true } identity_jose = { version = "=1.4.0", path = "../identity_jose", optional = true } -iota-config = { git = "https://github.com/iotaledger/iota.git", package = "iota-config", rev = "39c83ddcf07894cdee2abd146381d8704205e6e9", optional = true } +iota-config = { git = "https://github.com/iotaledger/iota.git", package = "iota-config", tag = "v0.7.3-rc", optional = true } iota-crypto = { version = "0.23", optional = true } -iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", rev = "39c83ddcf07894cdee2abd146381d8704205e6e9", optional = true } +iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk", tag = "v0.7.3-rc", optional = true } itertools = { version = "0.13.0", optional = true } -move-core-types = { git = "https://github.com/iotaledger/iota.git", package = "move-core-types", rev = "39c83ddcf07894cdee2abd146381d8704205e6e9", optional = true } +move-core-types = { git = "https://github.com/iotaledger/iota.git", package = "move-core-types", tag = "v0.7.3-rc", optional = true } rand = { version = "0.8.5", optional = true } secret-storage = { git = "https://github.com/iotaledger/secret-storage.git", tag = "v0.1.0", optional = true } serde-aux = { version = "4.5.0", optional = true } -shared-crypto = { git = "https://github.com/iotaledger/iota.git", package = "shared-crypto", rev = "39c83ddcf07894cdee2abd146381d8704205e6e9", optional = true } +shared-crypto = { git = "https://github.com/iotaledger/iota.git", package = "shared-crypto", tag = "v0.7.3-rc", optional = true } tokio = { version = "1.29.0", default-features = false, optional = true, features = ["macros", "sync", "rt", "process"] } [dev-dependencies] diff --git a/identity_iota_core/packages/iota_identity/Move.toml b/identity_iota_core/packages/iota_identity/Move.toml index 83cc4519b9..c794264cf4 100644 --- a/identity_iota_core/packages/iota_identity/Move.toml +++ b/identity_iota_core/packages/iota_identity/Move.toml @@ -6,9 +6,11 @@ name = "IotaIdentity" edition = "2024.beta" [dependencies] -MoveStdlib = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/move-stdlib", rev = "ead968e573d8feaa1aa78dddadb8b18a8a99870d" } -Iota = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/iota-framework", rev = "ead968e573d8feaa1aa78dddadb8b18a8a99870d" } -Stardust = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/stardust", rev = "ead968e573d8feaa1aa78dddadb8b18a8a99870d" } +# 'tag' keyword not supported here, therefore use rev instead +# 'tag = "v0.7.3-rc"' equals 'rev = "34da09d2684e7e3356bc457b5e412405357f9972"', which we use here +MoveStdlib = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/move-stdlib", rev = "34da09d2684e7e3356bc457b5e412405357f9972" } +Iota = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/iota-framework", rev = "34da09d2684e7e3356bc457b5e412405357f9972" } +Stardust = { git = "https://github.com/iotaledger/iota.git", subdir = "crates/iota-framework/packages/stardust", rev = "34da09d2684e7e3356bc457b5e412405357f9972" } [addresses] iota_identity = "0x0" diff --git a/identity_iota_core/scripts/publish_identity_package.sh b/identity_iota_core/scripts/publish_identity_package.sh index 977e9f27ca..620d39289f 100755 --- a/identity_iota_core/scripts/publish_identity_package.sh +++ b/identity_iota_core/scripts/publish_identity_package.sh @@ -3,9 +3,10 @@ # Copyright 2020-2024 IOTA Stiftung # SPDX-License-Identifier: Apache-2.0 -script_dir=$(dirname $0) +script_dir=$(cd "$(dirname $0)" && pwd) package_dir=$script_dir/../packages/iota_identity # echo "publishing package from $package_dir" -cd $package_dir -iota client publish --with-unpublished-dependencies --skip-dependency-verification --json --gas-budget 500000000 . +package_id=$(iota client publish --with-unpublished-dependencies --skip-dependency-verification --silence-warnings --json --gas-budget 500000000 $package_dir | jq --raw-output '.objectChanges[] | select(.type | contains("published")) | .packageId') +export IOTA_IDENTITY_PKG_ID=$package_id +echo "${IOTA_IDENTITY_PKG_ID}" \ No newline at end of file diff --git a/identity_iota_core/src/document/iota_document.rs b/identity_iota_core/src/document/iota_document.rs index f08a2ae85f..42701d3162 100644 --- a/identity_iota_core/src/document/iota_document.rs +++ b/identity_iota_core/src/document/iota_document.rs @@ -332,7 +332,7 @@ impl IotaDocument { /// Returns the first [`Service`] with an `id` property matching the provided `service_query`, if present. // NOTE: This method demonstrates unexpected behaviour in the edge cases where the document contains // services whose ids are of the form #. - pub fn resolve_service<'query, 'me, Q>(&'me self, service_query: Q) -> Option<&Service> + pub fn resolve_service<'query, 'me, Q>(&'me self, service_query: Q) -> Option<&'me Service> where Q: Into>, { @@ -347,7 +347,7 @@ impl IotaDocument { &'me self, method_query: Q, scope: Option, - ) -> Option<&VerificationMethod> + ) -> Option<&'me VerificationMethod> where Q: Into>, { diff --git a/identity_iota_core/src/rebased/assets/asset.rs b/identity_iota_core/src/rebased/assets/asset.rs index e1e60b3e41..e96554262e 100644 --- a/identity_iota_core/src/rebased/assets/asset.rs +++ b/identity_iota_core/src/rebased/assets/asset.rs @@ -223,7 +223,7 @@ impl AuthenticatedAssetBuilder { } /// Proposal for the transfer of an [`AuthenticatedAsset`]'s ownership from one [`IotaAddress`] to another. - +/// /// # Detailed Workflow /// A [`TransferProposal`] is a **shared** _Move_ object that represents a request to transfer ownership /// of an [`AuthenticatedAsset`] to a new owner. @@ -375,7 +375,7 @@ pub struct UpdateContentTx<'a, T> { } #[async_trait] -impl<'a, T> Transaction for UpdateContentTx<'a, T> +impl Transaction for UpdateContentTx<'_, T> where T: MoveType + Serialize + Clone + Send + Sync, { diff --git a/identity_iota_core/src/rebased/migration/alias.rs b/identity_iota_core/src/rebased/migration/alias.rs index ba56ca3790..917edf4c13 100644 --- a/identity_iota_core/src/rebased/migration/alias.rs +++ b/identity_iota_core/src/rebased/migration/alias.rs @@ -45,7 +45,6 @@ pub struct UnmigratedAlias { /// The sender feature. pub sender: Option, - /// The metadata feature. pub metadata: Option>, /// The immutable issuer feature. pub immutable_issuer: Option, diff --git a/identity_iota_core/src/rebased/migration/identity.rs b/identity_iota_core/src/rebased/migration/identity.rs index 6258cc042d..cdea687da4 100644 --- a/identity_iota_core/src/rebased/migration/identity.rs +++ b/identity_iota_core/src/rebased/migration/identity.rs @@ -501,7 +501,7 @@ impl MoveType for OnChainIdentity { pub struct CreateIdentityTx<'a>(IdentityBuilder<'a>); #[async_trait] -impl<'a> Transaction for CreateIdentityTx<'a> { +impl Transaction for CreateIdentityTx<'_> { type Output = OnChainIdentity; async fn execute_with_opt_gas( self, diff --git a/identity_iota_core/src/rebased/proposals/borrow.rs b/identity_iota_core/src/rebased/proposals/borrow.rs index 3ff90dc495..145b3a8bf2 100644 --- a/identity_iota_core/src/rebased/proposals/borrow.rs +++ b/identity_iota_core/src/rebased/proposals/borrow.rs @@ -73,7 +73,7 @@ impl BorrowAction { } } -impl<'i> ProposalBuilder<'i, BorrowAction> { +impl ProposalBuilder<'_, BorrowAction> { /// Adds an object to the list of objects that will be borrowed when executing this action. pub fn borrow(mut self, object_id: ObjectID) -> Self { self.borrow_object(object_id); @@ -177,7 +177,7 @@ impl<'i> ProtoTransaction for UserDrivenTx<'i, BorrowAction> { } #[async_trait] -impl<'i, F> Transaction for UserDrivenTx<'i, BorrowActionWithIntent> +impl Transaction for UserDrivenTx<'_, BorrowActionWithIntent> where F: FnOnce(&mut Ptb, &HashMap) + Send, { diff --git a/identity_iota_core/src/rebased/proposals/config_change.rs b/identity_iota_core/src/rebased/proposals/config_change.rs index cec2bc10c5..eec2b54cb5 100644 --- a/identity_iota_core/src/rebased/proposals/config_change.rs +++ b/identity_iota_core/src/rebased/proposals/config_change.rs @@ -52,7 +52,7 @@ impl MoveType for ConfigChange { } } -impl<'i> ProposalBuilder<'i, ConfigChange> { +impl ProposalBuilder<'_, ConfigChange> { /// Sets a new value for the identity's threshold. pub fn threshold(mut self, threshold: u64) -> Self { self.set_threshold(threshold); diff --git a/identity_iota_core/src/rebased/proposals/controller.rs b/identity_iota_core/src/rebased/proposals/controller.rs index ec71fc0ecd..4be8b08e84 100644 --- a/identity_iota_core/src/rebased/proposals/controller.rs +++ b/identity_iota_core/src/rebased/proposals/controller.rs @@ -160,7 +160,7 @@ impl<'i> ProtoTransaction for UserDrivenTx<'i, ControllerExecution> { } #[async_trait] -impl<'i, F> Transaction for UserDrivenTx<'i, ControllerExecutionWithIntent> +impl Transaction for UserDrivenTx<'_, ControllerExecutionWithIntent> where F: FnOnce(&mut Ptb, &Argument) + Send, { diff --git a/identity_iota_core/src/rebased/proposals/mod.rs b/identity_iota_core/src/rebased/proposals/mod.rs index cb9f61987b..a5b8b53808 100644 --- a/identity_iota_core/src/rebased/proposals/mod.rs +++ b/identity_iota_core/src/rebased/proposals/mod.rs @@ -96,14 +96,14 @@ pub struct ProposalBuilder<'i, A> { action: A, } -impl<'i, A> Deref for ProposalBuilder<'i, A> { +impl Deref for ProposalBuilder<'_, A> { type Target = A; fn deref(&self) -> &Self::Target { &self.action } } -impl<'i, A> DerefMut for ProposalBuilder<'i, A> { +impl DerefMut for ProposalBuilder<'_, A> { fn deref_mut(&mut self) -> &mut Self::Target { &mut self.action } @@ -161,7 +161,7 @@ pub struct CreateProposalTx<'i, A> { } #[async_trait] -impl<'i, A> Transaction for CreateProposalTx<'i, A> +impl Transaction for CreateProposalTx<'_, A> where Proposal: ProposalT + DeserializeOwned, A: Send, @@ -234,7 +234,7 @@ pub struct ExecuteProposalTx<'i, A> { } #[async_trait] -impl<'i, A> Transaction for ExecuteProposalTx<'i, A> +impl Transaction for ExecuteProposalTx<'_, A> where Proposal: ProposalT, A: Send, @@ -278,7 +278,7 @@ pub struct ApproveProposalTx<'p, 'i, A> { } #[async_trait] -impl<'p, 'i, A> Transaction for ApproveProposalTx<'p, 'i, A> +impl Transaction for ApproveProposalTx<'_, '_, A> where Proposal: ProposalT, A: MoveType + Send, diff --git a/identity_iota_core/src/rebased/proposals/send.rs b/identity_iota_core/src/rebased/proposals/send.rs index 61ee22bae0..5b68a2d67e 100644 --- a/identity_iota_core/src/rebased/proposals/send.rs +++ b/identity_iota_core/src/rebased/proposals/send.rs @@ -63,7 +63,7 @@ impl SendAction { } } -impl<'i> ProposalBuilder<'i, SendAction> { +impl ProposalBuilder<'_, SendAction> { /// Adds one object to the list of objects to send. pub fn object(mut self, object_id: ObjectID, recipient: IotaAddress) -> Self { self.send_object(object_id, recipient); diff --git a/identity_iota_core/tests/e2e/common.rs b/identity_iota_core/tests/e2e/common.rs index 1a4fad9846..025fa3c1e5 100644 --- a/identity_iota_core/tests/e2e/common.rs +++ b/identity_iota_core/tests/e2e/common.rs @@ -38,6 +38,7 @@ use secret_storage::Signer; use serde_json::Value; use std::io::Write; use std::ops::Deref; +use std::str::FromStr; use std::sync::Arc; use tokio::process::Command; use tokio::sync::OnceCell; @@ -140,20 +141,13 @@ async fn publish_package(active_address: IotaAddress) -> anyhow::Result(output_str[start_of_json..].trim())? + let package_id: ObjectID = { + let output_str = std::str::from_utf8(&output.stdout).unwrap().trim(); + ObjectID::from_str(output_str).context(format!( + "failed to find IDENTITY_IOTA_PKG_ID in response from: {output_str}" + ))? }; - let package_id = publish_result - .path("$.objectChanges[?(@.type == 'published')].packageId") - .map_err(|e| anyhow!("Failed to parse JSONPath: {e}")) - .and_then(|value| Ok(serde_json::from_value::>(value)?))? - .first() - .copied() - .ok_or_else(|| anyhow!("Failed to parse package ID after publishing"))?; - // Persist package ID in order to avoid publishing the package for every test. let package_id_str = package_id.to_string(); std::env::set_var("IDENTITY_IOTA_PKG_ID", package_id_str.as_str()); @@ -236,7 +230,9 @@ impl TestClient { .await?; let new_address = { let output_str = std::str::from_utf8(&output.stdout).unwrap(); - let start_of_json = output_str.find('{').ok_or(anyhow!("No json in output"))?; + let start_of_json = output_str + .find('{') + .ok_or(anyhow!("No json in output: {}", output_str))?; let json_result = serde_json::from_str::(output_str[start_of_json..].trim())?; let address_json = json_result .path("$.address") diff --git a/identity_jose/src/jws/decoder.rs b/identity_jose/src/jws/decoder.rs index 6b93488acf..c1635c86d3 100644 --- a/identity_jose/src/jws/decoder.rs +++ b/identity_jose/src/jws/decoder.rs @@ -322,7 +322,7 @@ pub struct JwsValidationIter<'decoder, 'payload, 'signatures> { payload: &'payload [u8], } -impl<'decoder, 'payload, 'signatures> Iterator for JwsValidationIter<'decoder, 'payload, 'signatures> { +impl<'payload> Iterator for JwsValidationIter<'_, 'payload, '_> { type Item = Result>; fn next(&mut self) -> Option { diff --git a/identity_jose/src/jws/encoding/utils.rs b/identity_jose/src/jws/encoding/utils.rs index b1d903e612..2be2703488 100644 --- a/identity_jose/src/jws/encoding/utils.rs +++ b/identity_jose/src/jws/encoding/utils.rs @@ -86,7 +86,7 @@ pub(super) struct Flatten<'payload, 'unprotected> { pub(super) signature: JwsSignature<'unprotected>, } -impl<'payload, 'unprotected> Flatten<'payload, 'unprotected> { +impl Flatten<'_, '_> { pub(super) fn to_json(&self) -> Result { serde_json::to_string(&self).map_err(Error::InvalidJson) } @@ -99,7 +99,7 @@ pub(super) struct General<'payload, 'unprotected> { pub(super) signatures: Vec>, } -impl<'payload, 'unprotected> General<'payload, 'unprotected> { +impl General<'_, '_> { pub(super) fn to_json(&self) -> Result { serde_json::to_string(&self).map_err(Error::InvalidJson) } diff --git a/identity_jose/src/jws/recipient.rs b/identity_jose/src/jws/recipient.rs index 602f1e6f3f..96dd410fa0 100644 --- a/identity_jose/src/jws/recipient.rs +++ b/identity_jose/src/jws/recipient.rs @@ -15,7 +15,7 @@ pub struct Recipient<'a> { pub unprotected: Option<&'a JwsHeader>, } -impl<'a> Default for Recipient<'a> { +impl Default for Recipient<'_> { fn default() -> Self { Self::new() } diff --git a/identity_storage/src/storage/storage_signer.rs b/identity_storage/src/storage/storage_signer.rs index 13ab3a1ecc..1c64ba3c05 100644 --- a/identity_storage/src/storage/storage_signer.rs +++ b/identity_storage/src/storage/storage_signer.rs @@ -24,7 +24,7 @@ pub struct StorageSigner<'a, K, I> { storage: &'a Storage, } -impl<'a, K, I> Clone for StorageSigner<'a, K, I> { +impl Clone for StorageSigner<'_, K, I> { fn clone(&self) -> Self { StorageSigner { key_id: self.key_id.clone(), @@ -62,7 +62,7 @@ impl<'a, K, I> StorageSigner<'a, K, I> { #[cfg_attr(not(feature = "send-sync-storage"), async_trait(?Send))] #[cfg_attr(feature = "send-sync-storage", async_trait)] -impl<'a, K, I> Signer for StorageSigner<'a, K, I> +impl Signer for StorageSigner<'_, K, I> where K: JwkStorage + Sync, I: KeyIdStorage + Sync,