Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions project_registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,9 +1223,9 @@ fn require_multisig_disabled(env: &Env) {
}

fn compute_rate(credit_quality: u32, green_impact: u32) -> u32 {
let avg = (credit_quality + green_impact) / 2;
let discount = avg * MAX_DISCOUNT_BPS / 100;
BASE_RATE_BPS - discount
// Single source of truth: logic::calculate_interest_rate already applies
// the underflow guard this local copy lacked.
logic::calculate_interest_rate(BASE_RATE_BPS, MAX_DISCOUNT_BPS, credit_quality, green_impact)
}

fn read_state_version(env: &Env) -> u32 {
Expand Down
3 changes: 0 additions & 3 deletions project_registry/src/logic.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
use crate::types::{CertificationStatus, ProjectData};
use soroban_sdk::{Address, Env, String};

/// Interest-rate calculation for green-bond projects.
///
/// Heliobond uses a two-dimensional scoring model to determine each project's
Expand Down
42 changes: 7 additions & 35 deletions project_registry/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,7 @@
use crate::types::{DataKey, ProjectData, Proposal};
use soroban_sdk::{Address, Env};

pub fn read_project(env: &Env, id: u32) -> Option<ProjectData> {
env.storage().persistent().get(&DataKey::Project(id))
}

pub fn write_project(env: &Env, id: u32, project: &ProjectData) {
env.storage()
.persistent()
.set(&DataKey::Project(id), project);
}

pub fn read_proposal(env: &Env, id: u32) -> Option<Proposal> {
env.storage().persistent().get(&DataKey::Proposal(id))
}

pub fn write_proposal(env: &Env, id: u32, proposal: &Proposal) {
env.storage()
.persistent()
.set(&DataKey::Proposal(id), proposal);
}

pub fn read_whitelist(env: &Env, account: Address) -> bool {
env.storage()
.persistent()
.get(&DataKey::Whitelist(account))
.unwrap_or(false)
}

pub fn write_whitelist(env: &Env, account: Address, status: bool) {
env.storage()
.persistent()
.set(&DataKey::Whitelist(account), &status);
}
//! Storage-accessor helpers.
//!
//! Historically this module exposed read_project / write_project /
//! read_proposal / write_proposal / read_whitelist / write_whitelist wrappers
//! around env.storage(), but lib.rs inlines env.storage() calls directly and
//! never referenced them. They were removed to eliminate dead, drift-prone
//! abstractions (#331).
Loading