-
Notifications
You must be signed in to change notification settings - Fork 37
feat(contracts): implement issues #271, #272, #273, #274 #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| //! # KYC/KYB Integration Hooks (Issue #215) | ||
| //! # Data Deletion / Right to Be Forgotten (Issue #272) | ||
| //! | ||
| //! Optional KYC verification hooks for the identity contract. | ||
| //! Allows accounts to require KYC verification before participating in sessions. | ||
|
|
@@ -7,6 +8,7 @@ | |
|
|
||
| use soroban_sdk::{ | ||
| contract, contractimpl, contracterror, contracttype, symbol_short, Address, Env, String, | ||
| Symbol, | ||
| }; | ||
|
|
||
| #[contracterror] | ||
|
|
@@ -112,6 +114,38 @@ impl IdentityContract { | |
| } | ||
| } | ||
|
|
||
| /// Standalone data-deletion helper (Issue #272). | ||
| /// | ||
| /// Replaces all `metadata_cid` and `notes_hash` fields associated with | ||
| /// `address` in the main SkillSphere contract storage with the tombstone | ||
| /// value `"DELETED"`. Only callable by the address owner or a SuperAdmin. | ||
| /// Cannot delete data from active sessions. | ||
| /// | ||
| /// # Storage keys touched (in the main contract's persistent storage) | ||
| /// * `DataKey::ExpertProfile(address)` — `metadata_cid` field | ||
| /// * `DataKey::Session(id)` — `metadata_cid` and `encrypted_notes_hash` for | ||
| /// every completed/resolved session where `seeker == address || expert == address` | ||
| /// | ||
| /// Because this module does not have direct access to the main contract's | ||
| /// storage, the function is designed to be called from within the main | ||
| /// `SkillSphereContract` impl (see `lib.rs`). | ||
| pub mod data_deletion { | ||
| use soroban_sdk::{symbol_short, Address, Env, String}; | ||
|
|
||
| /// Tombstone value used to overwrite deleted metadata fields. | ||
| pub fn tombstone(env: &Env) -> String { | ||
| String::from_str(env, "DELETED") | ||
| } | ||
|
|
||
| /// Emit the `DataDeletionRequested` event. | ||
| pub fn emit_deletion_event(env: &Env, address: &Address) { | ||
| env.events().publish( | ||
| (symbol_short!("dataDel"),), | ||
| (address.clone(), env.ledger().timestamp()), | ||
| ); | ||
|
Comment on lines
+140
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Route deletion events through the shared event publisher. Publishing directly here bypasses 🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
| /// Helper macro to check KYC requirement before action execution. | ||
| /// If an account has KycStatus::Required and is not yet Verified, returns error. | ||
| /// No-ops if status is NotRequired or Verified. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
For soroban-sdk 21.0.0, when using env.storage().temporary().set(...), do those entries require explicit TTL extension to remain queryable later, and what is the supported API for extending TTL on temporary-storage keys?💡 Result:
In soroban-sdk 21.0.0, entries created via env.storage.temporary.set(...) do have a limited lifetime (Time-To-Live, or TTL) and will be permanently deleted once that TTL expires [1]. To ensure such entries remain queryable beyond their initial expiration, you must proactively extend their TTL [2][3]. The supported API for extending the TTL of a temporary storage key is the extend_ttl method, accessed through the temporary storage interface [4][5]: env.storage.temporary.extend_ttl(&key, threshold, extend_to); This method works as follows: 1. &key: The identifier for the data entry you wish to extend [4]. 2. threshold: A safeguard parameter; the extension only triggers if the current TTL is lower than this value (measured in ledgers) [4][3]. 3. extend_ttl: The new desired TTL value (measured in ledgers) if the extension is triggered [4][2]. This design allows developers to distribute the cost of TTL management by checking and extending entries during normal contract interactions, rather than performing unnecessary extensions on every call [3]. While temporary entries are ephemeral and generally intended for short-lived data, explicit management is required if you need to maintain access to them over a longer duration [3][1].
Citations:
Extend TTL for replay buffer keys (temporary storage).
append_to_ringwrites both the ring-slot entry (DataKey::EventLog(slot)) and the replay head (head_key()) toenv.storage().temporary()but never refreshes their TTL. Temporary entries in Soroban are deleted when their TTL expires, soget_event_log()/event_log_head()can silently reset and break the replay contract.Add TTL extension for both keys (slot entry and head) using the temporary-storage API, e.g.
env.storage().temporary().extend_ttl(&key, threshold, extend_to—only extend when TTL is low, and sizeextend_toto cover the expected replay window).🤖 Prompt for AI Agents