1use anchor_lang::prelude::*;
2
3declare_id!("CmP2djJgABZ4cRokm4ndxuq6LerqpNHLBsaUv2XKEJua");
4
5#[program]
6pub mod bolt_component {
7 use super::*;
8
9 pub fn initialize(_ctx: Context<Initialize>) -> Result<()> {
10 Ok(())
11 }
12
13 pub fn destroy(_ctx: Context<Destroy>) -> Result<()> {
14 Ok(())
15 }
16
17 pub fn update(_ctx: Context<Update>, _data: Vec<u8>) -> Result<()> {
18 Ok(())
19 }
20
21 pub fn update_with_session(_ctx: Context<UpdateWithSession>, _data: Vec<u8>) -> Result<()> {
22 Ok(())
23 }
24
25 #[derive(Accounts)]
26 pub struct Update<'info> {
27 #[account()]
28 pub cpi_auth: Signer<'info>,
29 #[account(mut)]
30 pub bolt_component: UncheckedAccount<'info>,
32 #[account()]
33 pub authority: Signer<'info>,
35 }
36
37 #[derive(Accounts)]
38 pub struct UpdateWithSession<'info> {
39 #[account()]
40 pub cpi_auth: Signer<'info>,
41 #[account(mut)]
42 pub bolt_component: UncheckedAccount<'info>,
44 #[account()]
45 pub authority: Signer<'info>,
47 #[account()]
48 pub session_token: UncheckedAccount<'info>,
50 }
51}
52
53#[derive(Accounts)]
54pub struct Initialize<'info> {
55 #[account()]
56 pub cpi_auth: Signer<'info>,
57 #[account(mut)]
58 pub payer: Signer<'info>,
59 #[account(mut)]
60 pub data: UncheckedAccount<'info>,
62 #[account()]
63 pub entity: AccountInfo<'info>,
65 #[account()]
66 pub authority: AccountInfo<'info>,
68 pub system_program: Program<'info, System>,
69}
70
71#[derive(Accounts)]
72pub struct Destroy<'info> {
73 #[account()]
74 pub cpi_auth: Signer<'info>,
75 #[account()]
76 pub authority: Signer<'info>,
77 #[account(mut)]
78 pub receiver: AccountInfo<'info>,
80 #[account()]
81 pub entity: AccountInfo<'info>,
83 #[account(mut)]
84 pub component: UncheckedAccount<'info>,
86 #[account()]
87 pub component_program_data: AccountInfo<'info>,
89 pub system_program: Program<'info, System>,
90}
91
92#[derive(InitSpace, AnchorSerialize, AnchorDeserialize, Default, Copy, Clone)]
93pub struct BoltMetadata {
94 pub authority: Pubkey,
95}
96
97#[cfg(feature = "cpi")]
98pub trait CpiContextBuilder<'a, 'b, 'c, 'info>:
99 ToAccountMetas + ToAccountInfos<'info> + Sized
100{
101 fn build_cpi_context(
102 self,
103 program: AccountInfo<'info>,
104 signer_seeds: &'a [&'b [&'c [u8]]],
105 ) -> CpiContext<'a, 'b, 'c, 'info, Self>;
106}
107
108#[cfg(feature = "cpi")]
109impl<'a, 'b, 'c, 'info> CpiContextBuilder<'a, 'b, 'c, 'info> for cpi::accounts::Update<'info> {
110 fn build_cpi_context(
111 self,
112 program: AccountInfo<'info>,
113 signer_seeds: &'a [&'b [&'c [u8]]],
114 ) -> CpiContext<'a, 'b, 'c, 'info, Self> {
115 let cpi_program = program.to_account_info();
116 CpiContext::new_with_signer(cpi_program, self, signer_seeds)
117 }
118}
119
120#[cfg(feature = "cpi")]
121impl<'a, 'b, 'c, 'info> CpiContextBuilder<'a, 'b, 'c, 'info>
122 for cpi::accounts::UpdateWithSession<'info>
123{
124 fn build_cpi_context(
125 self,
126 program: AccountInfo<'info>,
127 signer_seeds: &'a [&'b [&'c [u8]]],
128 ) -> CpiContext<'a, 'b, 'c, 'info, Self> {
129 let cpi_program = program.to_account_info();
130 CpiContext::new_with_signer(cpi_program, self, signer_seeds)
131 }
132}