Skip to content
Merged
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
17 changes: 17 additions & 0 deletions contracts/receipt-anchor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,23 @@ impl ReceiptAnchor {
.get(&DataKey::MinAnchorInterval)
.unwrap_or(0)
}
/// Returns the admin (merchant) address, or `NotInitialized` if the
/// contract has not been initialized.
pub fn get_admin(env: Env) -> Result<Address, Error> {
env.storage()
.instance()
.get(&DataKey::Admin)
.ok_or(Error::NotInitialized)
}

/// Returns the pruned-up-to batch ID. Batches with IDs less than or equal
/// to this value have been pruned and are no longer verifiable on-chain.
pub fn get_pruned_up_to(env: Env) -> Result<u64, Error> {
env.storage()
.instance()
.get(&DataKey::PrunedUpTo)
.ok_or(Error::NotInitialized)
}

/// Returns the maximum number of receipts allowed in a single `anchor_batch`.
///
Expand Down
36 changes: 36 additions & 0 deletions contracts/refund-vault/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,42 @@ impl RefundVault {
POLICY_TIMELOCK
}

// ── Configuration getters ────────────────────────────────────────────

/// Returns the admin (merchant) address, or `NotInitialized` if the vault
/// has not been initialized.
pub fn get_admin(env: Env) -> Result<Address, Error> {
env.storage()
.instance()
.get(&DataKey::Admin)
.ok_or(Error::NotInitialized)
}

/// Returns the payment token address, or `NotInitialized` if the vault
/// has not been initialized.
pub fn get_token(env: Env) -> Result<Address, Error> {
env.storage()
.instance()
.get(&DataKey::Token)
.ok_or(Error::NotInitialized)
}

/// Returns the refund window in ledgers, or `NotInitialized` if the vault
/// has not been initialized. A value of 0 means no time-based restriction.
pub fn get_refund_window(env: Env) -> Result<u32, Error> {
env.storage()
.instance()
.get(&DataKey::RefundWindow)
.ok_or(Error::NotInitialized)
}

/// Returns whether the vault is currently paused.
pub fn is_paused(env: Env) -> bool {
env.storage()
.instance()
.get(&DataKey::IsPaused)
.unwrap_or(false)
}
/// Returns the current policy deadline as a Unix timestamp (read-only).
/// `0` means no deadline is configured.
pub fn get_refund_deadline(env: Env) -> u64 {
Expand Down
Loading