diff --git a/bindings/wasm/src/credential/revocation/status_list_2021/credential.rs b/bindings/wasm/src/credential/revocation/status_list_2021/credential.rs index 290dd2085b..d440dc8814 100644 --- a/bindings/wasm/src/credential/revocation/status_list_2021/credential.rs +++ b/bindings/wasm/src/credential/revocation/status_list_2021/credential.rs @@ -127,7 +127,7 @@ impl WasmStatusList2021Credential { pub fn set_credential_status( &mut self, credential: &mut WasmCredential, - index: &str, + index: usize, revoked_or_suspended: bool, ) -> Result { let entry = self diff --git a/bindings/wasm/src/credential/revocation/status_list_2021/entry.rs b/bindings/wasm/src/credential/revocation/status_list_2021/entry.rs index 7bec56cd7d..32194ceade 100644 --- a/bindings/wasm/src/credential/revocation/status_list_2021/entry.rs +++ b/bindings/wasm/src/credential/revocation/status_list_2021/entry.rs @@ -21,7 +21,7 @@ impl WasmStatusList2021Entry { pub fn new( status_list: &str, purpose: WasmStatusPurpose, - index: &str, + index: usize, id: Option, ) -> Result { let status_list = Url::parse(status_list).map_err(|e| JsError::new(&e.to_string()))?; diff --git a/examples/1_advanced/8_status_list_2021.rs b/examples/1_advanced/8_status_list_2021.rs index 73da986343..0a70690e91 100644 --- a/examples/1_advanced/8_status_list_2021.rs +++ b/examples/1_advanced/8_status_list_2021.rs @@ -100,7 +100,7 @@ async fn main() -> anyhow::Result<()> { // Create an unsigned `UniversityDegree` credential for Alice. // The issuer also chooses a unique `StatusList2021` index to be able to revoke it later. - let credential_index: &str = "420"; + let credential_index: usize = 420; let status: Status = StatusList2021Entry::new( status_list_credential.id().cloned().unwrap(), status_list_credential.purpose(), diff --git a/identity_credential/src/revocation/status_list_2021/credential.rs b/identity_credential/src/revocation/status_list_2021/credential.rs index 9bd398b4c1..9f6958abf9 100644 --- a/identity_credential/src/revocation/status_list_2021/credential.rs +++ b/identity_credential/src/revocation/status_list_2021/credential.rs @@ -128,17 +128,17 @@ impl StatusList2021Credential { pub fn set_credential_status( &mut self, credential: &mut Credential, - index: &str, + index: usize, revoked_or_suspended: bool, ) -> Result { let id = self .id() .cloned() .ok_or(StatusList2021CredentialError::Unreferenceable)?; + let entry = StatusList2021Entry::new(id, self.purpose(), index, None); - let index_int = index.parse::().expect("should be integer serialized as string"); - self.set_entry(index_int, revoked_or_suspended)?; + self.set_entry(index, revoked_or_suspended)?; credential.credential_status = Some(entry.clone().into()); Ok(entry) diff --git a/identity_credential/src/revocation/status_list_2021/entry.rs b/identity_credential/src/revocation/status_list_2021/entry.rs index 3cf98501a1..cd8c583a3a 100644 --- a/identity_credential/src/revocation/status_list_2021/entry.rs +++ b/identity_credential/src/revocation/status_list_2021/entry.rs @@ -66,7 +66,7 @@ impl From for Status { impl StatusList2021Entry { /// Creates a new [`StatusList2021Entry`]. - pub fn new(status_list: Url, purpose: StatusPurpose, index: impl Into, id: Option) -> Self { + pub fn new(status_list: Url, purpose: StatusPurpose, index: usize, id: Option) -> Self { let id = id.unwrap_or_else(|| { let mut id = status_list.clone(); id.set_fragment(None); @@ -78,7 +78,7 @@ impl StatusList2021Entry { type_: CREDENTIAL_STATUS_TYPE.to_owned(), status_purpose: purpose, status_list_credential: status_list, - status_list_index: index.into(), + status_list_index: index.to_string(), } } @@ -123,7 +123,7 @@ mod tests { let status = StatusList2021Entry::new( Url::parse("https://example.com/credentials/status/3").unwrap(), StatusPurpose::Revocation, - "94567", + 94567, Url::parse("https://example.com/credentials/status/3#94567").ok(), ); assert_eq!(status, deserialized);