I have created a contract based on the following example https://github.com/Concordium/concordium-rust-smart-contracts/tree/main/examples/credential-registry
I changed the schema for credential registry as following
/// Parameters for registering a credential
#[derive(Serialize, SchemaType, Clone, Debug)]
pub struct RegisterCredentialParam {
/// Public credential data.
credential_info: CredentialInfo,
/// Any additional data required by the issuer in the registration process.
/// This data is not used in this contract. However, it is part of the CIS-4
/// standard that this contract implements; `auxiliary_data` can be
/// used, for example, to implement signature-based authentication.
#[concordium(size_length = 2)]
auxiliary_data: Vec<u8>,
}
#[derive(Serialize, SchemaType, PartialEq, Eq, Clone, Debug)]
pub struct CredentialInfo {
/// The holder's identifier is a public key.
review_id: CredentialHolderId,
holder_id: CredentialHolderId,
/// If this flag is set to `true` the holder can send a signed message to
/// revoke their credential.
holder_revocable: bool,
/// The date from which the credential is considered valid.
valid_from: Timestamp,
/// After this date, the credential becomes expired. `None` corresponds to a
/// credential that cannot expire.
valid_until: Option<Timestamp>,
/// Link to the metadata of this credential.
metadata_url: MetadataUrl,
}
The credential registry function was changed to following
fn contract_register_credential<S: HasStateApi>(
ctx: &impl HasReceiveContext,
host: &mut impl HasHost<State<S>, StateApiType = S>,
// logger: &mut impl HasLogger,
) -> Result<(), ContractError> {
// ensure!(sender_is_issuer(ctx, host.state()), ContractError::NotAuthorized);
let parameter: RegisterCredentialParam = ctx.parameter_cursor().get()?;
let credential_info = parameter.credential_info;
let (state, state_builder) = host.state_and_builder();
state.register_credential(&credential_info, state_builder)?;
Ok(())
}
The credientialEntry scheme was modified to following
/// Public data of a verifiable credential.
#[derive(Serial, DeserialWithState, Debug)]
#[concordium(state_parameter = "S")]
pub struct CredentialEntry<S: HasStateApi> {
/// If this flag is set to `true` the holder can send a signed message to
/// revoke their credential.
holder_revocable: bool,
review_id: CredentialHolderId,
holder_id: CredentialHolderId,
/// The date from which the credential is considered valid.
valid_from: Timestamp,
/// After this date, the credential becomes expired. `None` corresponds to a
/// credential that cannot expire.
valid_until: Option<Timestamp>,
/// The nonce is used to avoid replay attacks when checking the holder's
/// signature on a revocation message.
revocation_nonce: u64,
/// Revocation flag
revoked: bool,
/// Metadata URL of the credential (not to be confused with the metadata URL
/// of the **issuer**).
/// This data is only needed when credential info is requested. In other
/// operations, `StateBox` defers loading the metadata url.
metadata_url: StateBox<MetadataUrl, S>,
}
#[receive(
contract = "hash_reg",
name = "credentialEntry",
parameter = "CredentialHolderId",
error = "ContractError",
return_value = "CredentialQueryResponse"
)]
fn contract_credential_entry<S: HasStateApi>(
ctx: &impl HasReceiveContext,
host: &impl HasHost<State<S>, StateApiType = S>,
) -> Result<CredentialQueryResponse, ContractError> {
let review_id = ctx.parameter_cursor().get()?;
// host.state().view_credential_info(credential_id)
host.state().view_review_info(review_id)
}
fn view_review_info(
&self,
review_id: CredentialHolderId,
) -> ContractResult<CredentialQueryResponse> {
let entry =
self.credentials.get(&review_id).ok_or(ContractError::CredentialNotFound)?;
Ok(CredentialQueryResponse {
credential_info: entry.info(review_id),
revocation_nonce: entry.revocation_nonce,
schema_ref: self.credential_schema.clone(),
})
}
The issue is that i am able to successfully register the new credential based on the new changes, but the crediential entry returns not found