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

chore: clippy and fmt fixes and compilation error fix #1452

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .cargo/audit.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ ignore = [
"RUSTSEC-2021-0127", # serde_cbor is unmaintained https://github.com/iotaledger/identity.rs/issues/518
"RUSTSEC-2023-0052", # temporary ignore until fix is provided
"RUSTSEC-2023-0065", # temporary ignore until fix is provided
"RUSTSEC-2023-0071", # temporary ignore until fix is provided
]
20 changes: 12 additions & 8 deletions .github/actions/iota-rebase-sandbox/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,29 @@ runs:
- name: Set up IOTA Node
shell: bash
run: |
set -e
mkdir -p iota
cd iota

# Select platform-specific asset pattern
if [ "${{ inputs.platform }}" = "linux" ]; then
PLATFORM="linux"
else
PLATFORM="macos"
fi
# Set platform
PLATFORM="${{ inputs.platform }}"
echo "Looking for platform: $PLATFORM"

# Get download URL with simpler jq filter
# 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')

# Download and extract
echo "Downloading from: $DOWNLOAD_URL"
curl -L -o iota.tar.gz $DOWNLOAD_URL
tar -xzf iota.tar.gz

echo "$PWD" >> $GITHUB_PATH
export PATH="$PWD:$PATH"

which iota || echo "iota not found in PATH"
ls -la "$PWD"
- name: Start the Network
shell: bash
working-directory: iota
run: ./iota start --with-faucet --force-regenesis &
run: iota start --with-faucet --force-regenesis &
4 changes: 2 additions & 2 deletions .github/actions/rust/sccache/setup-sccache/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ runs:
brew update --preinstall
brew install sccache

- name: Install sccache (ubuntu-latest)
if: inputs.os == 'ubuntu-latest'
- name: Install sccache (ubuntu-24.04)
if: inputs.os == 'ubuntu-24.04'
shell: bash
run: |
SCCACHE_DOWNLOAD_LINK=https://github.com/mozilla/sccache/releases/download
Expand Down
41 changes: 21 additions & 20 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ env:

jobs:
check-for-run-condition:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
outputs:
should-run: ${{ !github.event.pull_request || github.event.pull_request.draft == false }}
steps:
Expand All @@ -38,7 +38,7 @@ jobs:
check-for-modification:
needs: check-for-run-condition
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
outputs:
core-modified: ${{ steps.change-detection.outputs.core-modified }} # map step output to job output
steps:
Expand Down Expand Up @@ -67,9 +67,9 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ ubuntu-24.04, macos-latest, windows-latest ]
include:
- os: ubuntu-latest
- os: ubuntu-24.04
sccache-path: /home/runner/.cache/sccache
- os: macos-latest
sccache-path: /Users/runner/Library/Caches/Mozilla.sccache
Expand Down Expand Up @@ -104,15 +104,15 @@ jobs:
os: ${{matrix.os}}

- name: Check --no-default-features
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-24.04'
run: |
cargo metadata --format-version 1 | \
jq -r '.workspace_members[]' | \
awk '{print $1}' | \
xargs -I {} cargo check -p {} --no-default-features

- name: Check default features
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-24.04'
run: |
cargo metadata --format-version 1 | \
jq -r '.workspace_members[]' | \
Expand All @@ -122,7 +122,7 @@ jobs:
# Clean debug target to avoid bloating the GitHub Actions cache.
# The previous builds cannot be re-used at all for the full --all-features --release build anyway.
- name: Clean target
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-24.04'
run: cargo clean

# Build the library, tests, and examples without running them to avoid recompilation in the run tests step
Expand All @@ -133,7 +133,7 @@ jobs:
if: matrix.os != 'windows-latest'
uses: './.github/actions/iota-rebase-sandbox/setup'
with:
platform: ${{ matrix.os == 'ubuntu-latest' && 'linux' || 'macos' }}
platform: ${{ matrix.os == 'ubuntu-24.04' && 'linux' || 'macos' }}

- name: Run tests excluding `custom_time` feature
if: matrix.os != 'windows-latest'
Expand All @@ -144,7 +144,7 @@ jobs:

- name: Run Rust examples
# run examples only on ubuntu for now
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-24.04'
run: |
cargo metadata --format-version 1 --manifest-path ./examples/Cargo.toml | \
jq -r '.packages[] | select(.name == "examples") | .targets[].name' | \
Expand All @@ -154,7 +154,7 @@ jobs:

- name: Run Rust Readme examples
# run examples only on ubuntu for now
if: matrix.os == 'ubuntu-latest'
if: matrix.os == 'ubuntu-24.04'
run: |
cd bindings/wasm
npm ci
Expand All @@ -167,7 +167,8 @@ jobs:

build-wasm:
needs: check-for-run-condition
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }}
# if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }}
if: ${{ false }} # disable for now, as the wasm bindings are not yet ready
# owner/repository of workflow has to be static, see https://github.community/t/env-variables-in-uses/17466
uses: iotaledger/identity.rs/.github/workflows/shared-build-wasm.yml@main
with:
Expand All @@ -176,13 +177,13 @@ jobs:
test-wasm:
needs: build-wasm
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
os: [ ubuntu-24.04 ]
include:
- os: ubuntu-latest
- os: ubuntu-24.04

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -212,13 +213,13 @@ jobs:
test-wasm-firefox:
needs: build-wasm
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
os: [ ubuntu-24.04 ]
include:
- os: ubuntu-latest
- os: ubuntu-24.04

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -256,13 +257,13 @@ jobs:
test-wasm-chrome:
needs: build-wasm
if: ${{ needs.check-for-run-condition.outputs.should-run == 'true' }}
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
os: [ ubuntu-24.04 ]
include:
- os: ubuntu-latest
- os: ubuntu-24.04

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ jobs:

- name: Wasm clippy check
uses: actions-rs-plus/clippy-check@b09a9c37c9df7db8b1a5d52e8fe8e0b6e3d574c4
if: ${{ false }}
with:
args: --manifest-path ./bindings/wasm/Cargo.toml --target wasm32-unknown-unknown --all-targets --all-features -- -D warnings
3 changes: 1 addition & 2 deletions examples/0_basic/5_create_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ async fn main() -> anyhow::Result<()> {
// create new issuer account with did document
let issuer_storage = get_memstorage()?;
let issuer_identity_client = get_client_and_create_account(&issuer_storage).await?;
let (issuer_document, issuer_vm_fragment) =
create_did_document(&issuer_identity_client, &issuer_storage).await?;
let (issuer_document, issuer_vm_fragment) = create_did_document(&issuer_identity_client, &issuer_storage).await?;

// create new holder account with did document
let holder_storage = get_memstorage()?;
Expand Down
6 changes: 2 additions & 4 deletions examples/0_basic/6_create_vp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ async fn main() -> anyhow::Result<()> {
// create new issuer account with did document
let issuer_storage = get_memstorage()?;
let issuer_identity_client = get_client_and_create_account(&issuer_storage).await?;
let (issuer_document, issuer_vm_fragment) =
create_did_document(&issuer_identity_client, &issuer_storage).await?;
let (issuer_document, issuer_vm_fragment) = create_did_document(&issuer_identity_client, &issuer_storage).await?;

// create new holder account with did document
let holder_storage = get_memstorage()?;
let holder_identity_client = get_client_and_create_account(&holder_storage).await?;
let (holder_document, holder_vm_fragment) =
create_did_document(&holder_identity_client, &holder_storage).await?;
let (holder_document, holder_vm_fragment) = create_did_document(&holder_identity_client, &holder_storage).await?;

// create new client for verifier
// new client actually not necessary, but shows, that client is independent from issuer and holder
Expand Down
3 changes: 1 addition & 2 deletions examples/0_basic/7_revoke_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ async fn main() -> anyhow::Result<()> {
// create new issuer account with did document
let issuer_storage = get_memstorage()?;
let issuer_identity_client = get_client_and_create_account(&issuer_storage).await?;
let (mut issuer_document, issuer_vm_fragment) =
create_did_document(&issuer_identity_client, &issuer_storage).await?;
let (mut issuer_document, issuer_vm_fragment) = create_did_document(&issuer_identity_client, &issuer_storage).await?;

// create new holder account with did document
let holder_storage = get_memstorage()?;
Expand Down
4 changes: 2 additions & 2 deletions examples/1_advanced/4_identity_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ async fn main() -> anyhow::Result<()> {
.into_iter()
.map(|data| IotaDocument::unpack_from_iota_object_data(&did, &data, true))
.collect::<Result<_, _>>()?;
println!("Current version: {}", documents[0].to_string());
println!("Previous version: {}", documents[1].to_string());
println!("Current version: {}", documents[0]);
println!("Previous version: {}", documents[1]);

// Depending on your use case, you can also page through the results
// Alternative Step 2 - Page by looping until no result is returned (here with page size 1)
Expand Down
6 changes: 2 additions & 4 deletions examples/1_advanced/7_sd_jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ async fn main() -> anyhow::Result<()> {
// Create an identity for the issuer with one verification method `key-1`.
let issuer_storage = get_memstorage()?;
let issuer_identity_client = get_client_and_create_account(&issuer_storage).await?;
let (issuer_document, issuer_vm_fragment) =
create_did_document(&issuer_identity_client, &issuer_storage).await?;
let (issuer_document, issuer_vm_fragment) = create_did_document(&issuer_identity_client, &issuer_storage).await?;

// Create an identity for the holder, in this case also the subject.
let holder_storage = get_memstorage()?;
let holder_identity_client = get_client_and_create_account(&holder_storage).await?;
let (holder_document, holder_vm_fragment) =
create_did_document(&holder_identity_client, &holder_storage).await?;
let (holder_document, holder_vm_fragment) = create_did_document(&holder_identity_client, &holder_storage).await?;

// ===========================================================================
// Step 2: Issuer creates and signs a selectively disclosable JWT verifiable credential.
Expand Down
3 changes: 1 addition & 2 deletions examples/1_advanced/8_status_list_2021.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ async fn main() -> anyhow::Result<()> {
// create new issuer account with did document
let issuer_storage = get_memstorage()?;
let issuer_identity_client = get_client_and_create_account(&issuer_storage).await?;
let (issuer_document, issuer_vm_fragment) =
create_did_document(&issuer_identity_client, &issuer_storage).await?;
let (issuer_document, issuer_vm_fragment) = create_did_document(&issuer_identity_client, &issuer_storage).await?;

// create new holder account with did document
let holder_storage = get_memstorage()?;
Expand Down
1 change: 1 addition & 0 deletions identity_credential/src/credential/jwt_serialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ use crate::Result;
#[serde(transparent)]
pub struct JwtCredential(CredentialJwtClaims<'static>);

#[cfg(feature = "validator")]
impl TryFrom<JwtCredential> for Credential {
type Error = Error;
fn try_from(value: JwtCredential) -> std::result::Result<Self, Self::Error> {
Expand Down
4 changes: 2 additions & 2 deletions identity_iota/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ pub mod prelude {
pub use identity_iota_core::IotaDID;
pub use identity_iota_core::IotaDocument;

#[cfg(feature = "client")]
#[cfg_attr(docsrs, doc(cfg(feature = "client")))]
#[cfg(feature = "resolver")]
#[cfg_attr(docsrs, doc(cfg(feature = "resolver")))]
pub use identity_iota_core::DidResolutionHandler;

#[cfg(feature = "resolver")]
Expand Down
5 changes: 3 additions & 2 deletions identity_iota_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ iota-sdk = { git = "https://github.com/iotaledger/iota.git", package = "iota-sdk
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 }
rand = { version = "0.8.5", optional = true }
secret-storage = { git = "https://github.com/iotaledger/secret-storage.git", branch = "main", 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 }
tokio = { version = "1.29.0", default-features = false, optional = true, features = ["macros", "sync", "rt", "process"] }
Expand All @@ -51,9 +51,10 @@ iota-crypto = { version = "0.23", default-features = false, features = ["bip39",
proptest = { version = "1.0.0", default-features = false, features = ["std"] }

# for feature iota-client tests
identity_iota_core= { path = ".", features = ["iota-client"] } # enable for e2e tests
identity_iota_core = { path = ".", features = ["iota-client"] } # enable for e2e tests
identity_storage = { path = "../identity_storage", features = ["send-sync-storage", "storage-signer"] }
jsonpath-rust = "0.5.1"
lazy_static = "1.5.0"
serial_test = "3.1.1"

[package.metadata.docs.rs]
Expand Down
15 changes: 7 additions & 8 deletions identity_iota_core/src/document/iota_document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl IotaDocument {
}

#[cfg(feature = "iota-client")]
pub mod client_document {
mod client_document {
use identity_core::common::Timestamp;
use iota_sdk::rpc_types::IotaObjectData;

Expand All @@ -421,7 +421,7 @@ pub mod client_document {
data: &IotaObjectData,
allow_empty: bool,
) -> Result<IotaDocument> {
let unpacked = unpack_identity_data(&did, data).map_err(|_| {
let unpacked = unpack_identity_data(did, data).map_err(|_| {
Error::InvalidDoc(identity_document::Error::InvalidDocument(
"could not unpack identity data from IotaObjectData",
None,
Expand All @@ -437,7 +437,7 @@ pub mod client_document {
}
};
let did_doc =
Self::from_iota_document_data(multi_controller.controlled_value(), allow_empty, &did, created, updated)?;
Self::from_iota_document_data(multi_controller.controlled_value(), allow_empty, did, created, updated)?;

Ok(did_doc)
}
Expand All @@ -451,7 +451,7 @@ pub mod client_document {
/// * document related parsing Errors from `StateMetadataDocument::unpack`
/// * possible parsing errors when trying to parse `created` and `updated` to a `Timestamp`
pub fn from_iota_document_data(
data: &Vec<u8>,
data: &[u8],
allow_empty: bool,
did: &IotaDID,
created: Timestamp,
Expand All @@ -465,8 +465,7 @@ pub mod client_document {
empty_document
} else {
// we have a value, therefore unpack it
StateMetadataDocument::unpack(data)
.and_then(|state_metadata_doc| state_metadata_doc.into_iota_document(&did))?
StateMetadataDocument::unpack(data).and_then(|state_metadata_doc| state_metadata_doc.into_iota_document(did))?
};

// Overwrite `created` and `updated` with given timestamps
Expand Down Expand Up @@ -732,7 +731,7 @@ mod tests {
.parse()
.unwrap();
let document = IotaDocument::from_iota_document_data(
&vec![],
&[],
true,
&did,
Timestamp::from_unix(12).unwrap(),
Expand All @@ -750,7 +749,7 @@ mod tests {

// INVALID: reject empty document.
assert!(IotaDocument::from_iota_document_data(
&vec![],
&[],
false,
&did,
Timestamp::from_unix(12).unwrap(),
Expand Down
1 change: 1 addition & 0 deletions identity_iota_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ mod document;
mod error;
mod network;
#[cfg(feature = "iota-client")]
/// Contains the rebased Identity and the interaction with the IOTA Client.
pub mod rebased;
mod state_metadata;
Loading