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
11 changes: 5 additions & 6 deletions contracts/receipt-anchor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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<BatchRecord, Symbol> {
env.storage().persistent().get(&DataKey::Batch(batch_id)).ok_or(Symbol::new(&env, "BatchNotFound"))
}

pub fn get_max_proof_len(_env: Env) -> u32 {
Expand Down
5 changes: 4 additions & 1 deletion contracts/receipt-anchor/src/test.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
27 changes: 9 additions & 18 deletions contracts/refund-vault/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![no_std]
use soroban_sdk::{contract, contractimpl, contracttype, Address, Env, Symbol, token};

use accensa_common::Error;
use soroban_sdk::{
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 4 additions & 1 deletion contracts/refund-vault/src/test.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
Loading