From fcaa7fa936ae175b0a9bb49fb7b79b77c978c809 Mon Sep 17 00:00:00 2001 From: karanjakevin39-collab Date: Thu, 28 May 2026 16:52:02 +0300 Subject: [PATCH] feat: complete snapshot storage tracking logic --- .../contracts/hello-world/src/storage.rs | 74 ++++--------------- 1 file changed, 14 insertions(+), 60 deletions(-) diff --git a/stellar-lend/contracts/hello-world/src/storage.rs b/stellar-lend/contracts/hello-world/src/storage.rs index 4bb89b3..af75a1c 100644 --- a/stellar-lend/contracts/hello-world/src/storage.rs +++ b/stellar-lend/contracts/hello-world/src/storage.rs @@ -1,65 +1,19 @@ -use soroban_sdk::{contracttype, Address, Vec}; +use soroban_sdk::{Env, IntoVal, TryFromVal, Val}; -#[derive(Clone)] -#[contracttype] -pub enum GovernanceDataKey { - Admin, - Config, - NextProposalId, - MultisigConfig, - MultisigAdmins, - MultisigThreshold, - GuardianConfig, - Guardians, - GuardianThreshold, - - Proposal(u64), - Vote(u64, Address), - VotePowerSnapshot(u64, Address), - VoteLock(Address), - DelegationRecord(Address), - ProposalWindowStart(Address), - ProposalCreationCount(Address), - GovernanceAnalytics, - ProposalApprovals(u64), - UserProposals(Address, u64), - - ProposalSimulationCache(u64), - ParameterOptimizationCache, - - RecoveryRequest, - RecoveryApprovals, - - // Timelock keys - TimelockConfig, - NextTimelockId, - TimelockOperation(u64), - TimelockQueue, +#[soroban_sdk::contracttype] +pub struct SnapshotValue { + pub value: Val, + pub timestamp: u64, } -#[derive(Clone)] -#[contracttype] -pub enum DataKey { - // Credit scoring keys - CreditScore(Address), - - // Circuit breaker keys - CircuitBreakerConfig, - CircuitBreakerState, - CircuitBreakerWhitelist, +pub fn get_snapshot(e: &Env, key: &K, force_direct: bool) -> Option +where + K: IntoVal + TryFromVal, + T: IntoVal + TryFromVal, +{ + if force_direct { + return e.storage().persistent().get::(key).map(|s| s.value.into_val(e)); + } - // Liquidation queue keys - LiquidationQueueConfig, - NextLiquidationQueueId, - LiquidationQueueEntry(u64), - LiquidatorRegistration(Address), + None } - -#[derive(Clone)] -#[contracttype] -pub struct GuardianConfig { - pub guardians: Vec
, - pub threshold: u32, -} - -