Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.

Commit cbc5a7d

Browse files
cleanup: throw additional errors in the getter
1 parent 2bb0b08 commit cbc5a7d

1 file changed

Lines changed: 13 additions & 11 deletions

File tree

attestation/sources/attestation.move

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,19 @@ public fun attestation<T: key + store>(
226226
receiver: address,
227227
attestation_id: ID,
228228
): &Attestation<T> {
229-
if (
230-
registry.attested.borrow(receiver).contains(attestation_id)
231-
) {
232-
registry.attested.borrow(receiver).borrow(attestation_id)
233-
} else if (
234-
registry.revoked.borrow(receiver).contains(attestation_id)
235-
) {
236-
registry.revoked.borrow(receiver).borrow(attestation_id)
237-
} else {
238-
registry.pinned.borrow(receiver).borrow(attestation_id)
239-
}
229+
// Ensure receiver is known
230+
assert!(registry.attested.contains(receiver), EUnknownReceiver);
231+
232+
// Find attestation in one of the bags
233+
let attested = &registry.attested[receiver];
234+
if (attested.contains(attestation_id)) return &attested[attestation_id];
235+
let revoked = &registry.revoked[receiver];
236+
if (revoked.contains(attestation_id)) return &revoked[attestation_id];
237+
let pinned = &registry.pinned[receiver];
238+
if (pinned.contains(attestation_id)) return &pinned[attestation_id];
239+
240+
// Abort if attestation is not found in any of the bags
241+
abort EUnknownAttestationId
240242
}
241243

242244
/// Return attestation.revoked_by field

0 commit comments

Comments
 (0)