diff --git a/contracts/receipt-anchor/src/lib.rs b/contracts/receipt-anchor/src/lib.rs index dcb67168..4ec529fc 100644 --- a/contracts/receipt-anchor/src/lib.rs +++ b/contracts/receipt-anchor/src/lib.rs @@ -47,7 +47,6 @@ pub struct BatchRecord { pub count: u32, pub period_start: u64, pub period_end: u64, - pub anchored_ledger: u32, } /// The `ReceiptShard` entry points this router calls into. Declared as a @@ -167,7 +166,7 @@ impl ReceiptAnchor { shard_wasm_hash: BytesN<32>, ) -> Result<(), Error> { if env.storage().instance().has(&DataKey::Admin) { - return Err(Error::AlreadyInitialized); + return Err(Symbol::new(&env, "AlreadyInitialized")); } env.storage().instance().set(&DataKey::Admin, &merchant); env.storage().instance().set(&DataKey::BatchCount, &0u64); @@ -457,10 +456,10 @@ impl ReceiptAnchor { /// Returns the maximum number of receipts allowed in a single `anchor_batch`. /// - /// Clients should call this rather than hard-coding the limit so they stay - /// in sync if the constant is ever tuned. - pub fn get_max_batch_size(_env: Env) -> u32 { - MAX_BATCH_SIZE + /// # Errors + /// - `BatchNotFound`: If the batch ID does not exist. + pub fn get_batch(env: Env, batch_id: u64) -> Result { + env.storage().persistent().get(&DataKey::Batch(batch_id)).ok_or(Symbol::new(&env, "BatchNotFound")) } pub fn get_max_proof_len(_env: Env) -> u32 { diff --git a/contracts/receipt-anchor/src/test.rs b/contracts/receipt-anchor/src/test.rs index 4f6d25f5..77ff1626 100644 --- a/contracts/receipt-anchor/src/test.rs +++ b/contracts/receipt-anchor/src/test.rs @@ -1,4 +1,7 @@ -#![cfg(test)] +#[cfg(test)] +mod test { + use super::*; + use soroban_sdk::{testutils::Address as _, Address, Env, BytesN, Symbol}; use super::*; use soroban_sdk::{ diff --git a/contracts/refund-vault/src/lib.rs b/contracts/refund-vault/src/lib.rs index 1b9ffab9..bd39bf81 100644 --- a/contracts/refund-vault/src/lib.rs +++ b/contracts/refund-vault/src/lib.rs @@ -1,4 +1,4 @@ -#![no_std] +use soroban_sdk::{contract, contractimpl, contracttype, Address, Env, Symbol, token}; use accensa_common::Error; use soroban_sdk::{ @@ -808,15 +808,11 @@ const INITIAL_STORAGE_VERSION: u32 = 1; #[contractimpl] impl RefundVault { - pub fn initialize( - env: Env, - merchant: Address, - token: Address, - refund_window_ledgers: u32, - ) -> Result<(), Error> { - if env.storage().instance().has(&DataKey::Admin) { - return Err(Error::AlreadyInitialized); - } + /// Initializes the vault. + /// # Errors + /// - `AlreadyInitialized`: If already set. + pub fn initialize(env: Env, merchant: Address, token: Address, refund_window: u32) -> Result<(), Symbol> { + if env.storage().instance().has(&DataKey::Admin) { return Err(Symbol::new(&env, "AlreadyInitialized")); } env.storage().instance().set(&DataKey::Admin, &merchant); env.storage().instance().set(&DataKey::Token, &token); env.storage() @@ -2145,14 +2141,9 @@ impl RefundVault { Ok(()) } - pub fn unpause(env: Env) -> Result<(), Error> { - let merchant: Address = env - .storage() - .instance() - .get(&DataKey::Admin) - .ok_or(Error::NotInitialized)?; - merchant.require_auth(); - + pub fn unpause(env: Env) -> Result<(), Symbol> { + let admin: Address = env.storage().instance().get(&DataKey::Admin).ok_or(Symbol::new(&env, "NotInitialized"))?; + admin.require_auth(); env.storage().instance().set(&DataKey::IsPaused, &false); UnpauseEvent { diff --git a/contracts/refund-vault/src/test.rs b/contracts/refund-vault/src/test.rs index af7e25cc..10aa48b7 100644 --- a/contracts/refund-vault/src/test.rs +++ b/contracts/refund-vault/src/test.rs @@ -1,4 +1,7 @@ -#![cfg(test)] +#[cfg(test)] +mod test { + use super::*; + use soroban_sdk::{testutils::Address as _, Address, Env, BytesN}; use super::*; use soroban_sdk::{