Skip to content
Closed
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
8 changes: 8 additions & 0 deletions PROGRESS.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,3 +319,11 @@ is closed — see [CONTRIBUTING.md](CONTRIBUTING.md).
- **By:** ALLEN-AYODEJI
- **Closes:** N/A
- **Status:** Merged.

### Contract — `get_config` getter for operational limits

- **What:** In `contracts/deprader_router/src/lib.rs`, introduces `Config` struct (`review_window_secs`, `max_bounty_duration_secs`, `max_claims_per_bounty`, `max_ref_len`) and `get_config(env) -> Config` on `DepRaderRouter` so frontends and clients can dynamically read operational parameters without hardcoding constants. Added unit test `test_get_config_matches_constants` in `contracts/deprader_router/src/test.rs`.
- **Verified:** `cargo test --workspace --locked`, `cargo fmt --all -- --check`, `cargo clippy --workspace --all-targets --locked -- -D warnings`, and `cargo build -p deprader-router --target wasm32v1-none --release --locked` pass.
- **By:** dezzy-music
- **Closes:** #173
- **Status:** PR open.
19 changes: 19 additions & 0 deletions contracts/deprader_router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ pub struct Claim {
pub status: ClaimStatus,
}

#[contracttype]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct Config {
pub review_window_secs: u64,
pub max_bounty_duration_secs: u64,
pub max_claims_per_bounty: u32,
pub max_ref_len: u32,
}

#[contracttype]
enum DataKey {
Admin,
Expand Down Expand Up @@ -249,6 +258,16 @@ impl DepRaderRouter {
next - 1
}

/// Returns the contract's fixed operational limits.
pub fn get_config(_env: Env) -> Config {
Config {
review_window_secs: REVIEW_WINDOW_SECS,
max_bounty_duration_secs: MAX_BOUNTY_DURATION_SECS,
max_claims_per_bounty: MAX_CLAIMS_PER_BOUNTY,
max_ref_len: MAX_REF_LEN,
}
}

/// Refunds an open bounty to its creator.
///
/// - The admin may cancel at any time (e.g. the finding was invalid).
Expand Down
19 changes: 17 additions & 2 deletions contracts/deprader_router/src/test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{
BountyStatus, ClaimStatus, DepRaderRouter, DepRaderRouterClient, Error,
MAX_BOUNTY_DURATION_SECS, MAX_CLAIMS_PER_BOUNTY, REVIEW_WINDOW_SECS,
BountyStatus, ClaimStatus, Config, DepRaderRouter, DepRaderRouterClient, Error,
MAX_BOUNTY_DURATION_SECS, MAX_CLAIMS_PER_BOUNTY, MAX_REF_LEN, REVIEW_WINDOW_SECS,
};
use soroban_sdk::{
symbol_short,
Expand Down Expand Up @@ -120,6 +120,21 @@ fn test_create_requires_initialized_contract() {
assert_eq!(result, Err(Ok(Error::NotInitialized)));
}

#[test]
fn test_get_config_matches_constants() {
let t = setup();
let config = t.client.get_config();
assert_eq!(
config,
Config {
review_window_secs: REVIEW_WINDOW_SECS,
max_bounty_duration_secs: MAX_BOUNTY_DURATION_SECS,
max_claims_per_bounty: MAX_CLAIMS_PER_BOUNTY,
max_ref_len: MAX_REF_LEN,
}
);
}

// ------------------------------------------------------------ create_bounty

#[test]
Expand Down
Loading