hypercall_db/traits/faucet.rs
1//! Faucet (testnet deposit) persistence traits.
2
3use anyhow::Result;
4use hypercall_types::WalletAddress;
5use rust_decimal::Decimal;
6
7/// Result of a faucet credit operation.
8#[derive(Debug, Clone)]
9pub struct FaucetCreditResult {
10 /// New total credits for this wallet in the current window.
11 pub new_total: Decimal,
12 /// Ledger event ID for the deposit record.
13 pub ledger_event_id: i64,
14}
15
16/// Faucet deposit persistence.
17#[async_trait::async_trait]
18pub trait FaucetWriter: Send + Sync {
19 /// Atomically check credit limit and record a deposit audit event.
20 /// Returns error if the credit would exceed the per-window limit.
21 async fn persist_faucet_credit(
22 &self,
23 wallet: &WalletAddress,
24 amount: Decimal,
25 limit: Decimal,
26 window_start_ms: i64,
27 ) -> Result<FaucetCreditResult>;
28}