sablier_network_program/state/
penalty.rs1use anchor_lang::{prelude::*, AnchorDeserialize};
2
3use crate::constants::SEED_PENALTY;
4
5#[account]
7#[derive(Debug, InitSpace)]
8pub struct Penalty {
9 pub worker: Pubkey,
11 pub bump: u8,
12}
13
14impl Penalty {
15 pub fn pubkey(worker: Pubkey) -> Pubkey {
17 Pubkey::find_program_address(&[SEED_PENALTY, worker.as_ref()], &crate::ID).0
18 }
19}
20
21pub trait PenaltyAccount {
23 fn pubkey(&self) -> Pubkey;
25
26 fn init(&mut self, worker: Pubkey, bump: u8) -> Result<()>;
28}
29
30impl PenaltyAccount for Account<'_, Penalty> {
31 fn pubkey(&self) -> Pubkey {
32 Penalty::pubkey(self.worker)
33 }
34
35 fn init(&mut self, worker: Pubkey, bump: u8) -> Result<()> {
36 self.worker = worker;
37 self.bump = bump;
38 Ok(())
39 }
40}