Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Apply suggestions from review
  • Loading branch information
ntn-x2 committed Aug 4, 2022
commit e95d50e7eee6f3542cd090e82930a842d5c0f0fd
2 changes: 1 addition & 1 deletion pallets/public-credentials/src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct CredentialEntry<CTypeHash, Attester, BlockNumber, AccountId, Balance,
pub ctype_hash: CTypeHash,
/// The attester of the credential.
pub attester: Attester,
/// A flag indicating the revocation status of the credential
/// A flag indicating the revocation status of the credential.
pub revoked: bool,
/// The block number in which the credential tx was evaluated and included
/// in the block.
Expand Down
18 changes: 10 additions & 8 deletions pallets/public-credentials/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ pub mod pallet {
CredentialEntryOf<T>,
>;

// This map ensures that at any time a credential is only linked (i.e., issued)
// to a single subject, as it maps from a credential ID to the subject it was
// issued to.
/// A reverse index mapping from credential ID to the subject the credential
/// was issued to.
///
/// It it used to perform efficient lookup of credential given their ID.
#[pallet::storage]
#[pallet::getter(fn get_credential_subject)]
pub type CredentialSubjects<T> = StorageMap<_, Blake2_128Concat, CredentialIdOf<T>, <T as Config>::SubjectId>;
Expand All @@ -206,12 +207,12 @@ pub mod pallet {
/// The id of the removed credential.
credential_id: CredentialIdOf<T>,
},
/// A public credentials has been revoked.
/// A public credential has been revoked.
CredentialRevoked {
/// The id of the revoked credential.
credential_id: CredentialIdOf<T>,
},
/// A public credentials has been unrevoked.
/// A public credential has been unrevoked.
CredentialUnrevoked {
/// The id of the unrevoked credential.
credential_id: CredentialIdOf<T>,
Expand Down Expand Up @@ -332,7 +333,7 @@ pub mod pallet {
/// If a credential was already revoked, this function does not fail but
/// simply results in a noop.
///
/// Only authorized callers can revoke the credential.
/// /// The dispatch origin must be authorized to revoke the credential.
///
/// Emits `CredentialRevoked`.
#[pallet::weight({
Expand Down Expand Up @@ -369,7 +370,8 @@ pub mod pallet {
/// If a credential was not revoked, this function does not fail but
/// simply results in a noop.
///
/// Only authorized callers can unrevoke the credential.
/// /// The dispatch origin must be authorized to unrevoke the
/// credential.
///
/// Emits `CredentialUnrevoked`.
#[pallet::weight({
Expand Down Expand Up @@ -415,7 +417,7 @@ pub mod pallet {
/// This function fails if a credential already exists for the specified
/// subject.
///
/// Only authorized callers can remove the credential.
/// /// The dispatch origin must be authorized to remove the credential.
///
/// Emits `CredentialRemoved`.
#[pallet::weight({
Expand Down
12 changes: 6 additions & 6 deletions pallets/public-credentials/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,8 +532,8 @@ fn remove_successful() {
));

// Test this pallet logic
assert_eq!(Credentials::<Test>::get(&subject_id, &credential_id), None);
assert_eq!(CredentialSubjects::<Test>::get(&credential_id), None);
assert!(Credentials::<Test>::get(&subject_id, &credential_id).is_none());
assert!(CredentialSubjects::<Test>::get(&credential_id).is_none());

// Check deposit release logic
assert!(Balances::reserved_balance(ACCOUNT_00).is_zero());
Expand Down Expand Up @@ -568,8 +568,8 @@ fn remove_same_attester_wrong_ac() {
));

// Test this pallet logic
assert_eq!(Credentials::<Test>::get(&subject_id, &credential_id), None);
assert_eq!(CredentialSubjects::<Test>::get(&credential_id), None);
assert!(Credentials::<Test>::get(&subject_id, &credential_id).is_none());
assert!(CredentialSubjects::<Test>::get(&credential_id).is_none());
});
}

Expand Down Expand Up @@ -663,8 +663,8 @@ fn reclaim_deposit_successful() {
));

// Test this pallet logic
assert_eq!(Credentials::<Test>::get(&subject_id, &credential_id), None);
assert_eq!(CredentialSubjects::<Test>::get(&credential_id), None);
assert!(Credentials::<Test>::get(&subject_id, &credential_id).is_none());
assert!(CredentialSubjects::<Test>::get(&credential_id).is_none());

// Check deposit release logic
assert!(Balances::reserved_balance(ACCOUNT_00).is_zero());
Expand Down