sablier_network_program/state/
fee.rs1use anchor_lang::prelude::*;
2
3use crate::constants::SEED_FEE;
4
5#[account]
7#[derive(Debug, InitSpace)]
8pub struct Fee {
9 pub distributable_balance: u64,
11 pub worker: Pubkey,
13 pub bump: u8,
14}
15
16impl Fee {
17 pub fn pubkey(worker: Pubkey) -> Pubkey {
19 Pubkey::find_program_address(&[SEED_FEE, worker.as_ref()], &crate::ID).0
20 }
21}
22
23pub trait FeeAccount {
25 fn pubkey(&self) -> Pubkey;
27
28 fn init(&mut self, worker: Pubkey, bump: u8) -> Result<()>;
30}
31
32impl FeeAccount for Account<'_, Fee> {
33 fn pubkey(&self) -> Pubkey {
34 Fee::pubkey(self.worker)
35 }
36
37 fn init(&mut self, worker: Pubkey, bump: u8) -> Result<()> {
38 self.distributable_balance = 0;
39 self.worker = worker;
40 self.bump = bump;
41 Ok(())
42 }
43}