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

### deprader_router contract — `get_config` getter

- **What:** Added `Config` struct (`review_window_secs`, `max_bounty_duration_secs`,
`max_claims_per_bounty`, `max_ref_len`) and `get_config() -> Config` returning
the router's configured limits, so off-chain clients do not hard-code them.
Added `test_get_config_matches_constants`.
- **By:** kevindurant735rocket-creator
- **Closes:** #173
- **Status:** `cargo fmt`, `cargo clippy -- -D warnings`, and
`cargo test --workspace` (22 tests) pass.
20 changes: 20 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, Copy, 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 @@ -173,6 +182,17 @@ impl DepRaderRouter {
env.storage().instance().get(&DataKey::PendingAdmin)
}

/// Returns the router's configured limits so off-chain clients do not
/// need to hard-code them.
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,
}
}

// ------------------------------------------------------------- bounties

/// Locks `amount` of `token` from `creator` against a new bounty and
Expand Down
12 changes: 11 additions & 1 deletion 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,
MAX_BOUNTY_DURATION_SECS, MAX_CLAIMS_PER_BOUNTY, MAX_REF_LEN, REVIEW_WINDOW_SECS,
};
use soroban_sdk::{
symbol_short,
Expand Down Expand Up @@ -513,3 +513,13 @@ fn test_admin_rotation_is_two_step() {
t.client.release(&bounty_id, &claim_id);
assert_eq!(t.last_auth(), new_admin);
}

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