streak_api/state/user.rs
1//! Per-user account — one PDA per wallet.
2//!
3//! Created by the first `BuyTicket` call; `total_purchased` accumulates on
4//! each subsequent call. This is the on-chain proof of lifetime ticket revenue.
5//!
6//! The *spendable* balance (credits available for bets) is tracked off-chain
7//! by the indexer in `user_balances`. Bets are debited server-side.
8//!
9//! PDA seeds: `[USER_TICKET, user_pubkey]`
10
11use steel::*;
12
13use super::{user_pda, StreakAccount};
14
15#[repr(C)]
16#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
17pub struct User {
18 /// Wallet that owns this account.
19 pub user: Pubkey,
20 /// Cumulative µUSDC spent on tickets (never decreases).
21 pub total_purchased: u64,
22}
23
24impl User {
25 pub fn pda(user: &Pubkey) -> (Pubkey, u8) {
26 user_pda(user)
27 }
28}
29
30account!(StreakAccount, User);