feat(kyc): add revoke_kyc to clean up persistent storage on identity …#318
Open
Geff115 wants to merge 2 commits intoceejaylaboratory:mainfrom
Open
feat(kyc): add revoke_kyc to clean up persistent storage on identity …#318Geff115 wants to merge 2 commits intoceejaylaboratory:mainfrom
Geff115 wants to merge 2 commits intoceejaylaboratory:mainfrom
Conversation
…revocation, fixed merging conflicts. Closes ceejaylaboratory#251
|
@Geff115 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #251
Implements
revoke_kyc, a new public function on theKycVerifiercontractthat removes all persistent storage associated with a user's KYC identity when
it is revoked.
Motivation
Without explicit cleanup, revoked users leave behind a
UserKyc(Address)entry in Soroban's persistent storage indefinitely. This occupies rent-exempt
storage that is never reclaimed, growing the contract's ledger footprint
unnecessarily over time. This PR addresses that by calling
env.storage().persistent().remove()on revocation.What changed
lib.rs— Addedrevoke_kyc(env: Env, user: Address)toKycVerifier:admin.require_auth()UserKyc(Address)entry from persistent storagekyc_revevent for auditabilitytests.rs— Added a test module covering:test_revoke_kyc_removes_record— confirmsis_kyc_validreturnsfalseafter revocation and the storage key is fully gone
test_revoke_kyc_panics_on_missing_record— confirms a helpful panicwhen no record exists for the given user
test_revoke_kyc_rejects_non_admin— confirmsrequire_auth()blocksany caller that isn't the stored admin
Testing
All 3 tests pass.
Notes
kyc_revevent symbol is 7 characters, withinsymbol_short!'s 9-char limit.the entry is being permanently deleted, not just left to expire.