pitchtalk_solana/lib.rs
1use anchor_lang::prelude::*;
2use context::*;
3
4mod context;
5mod error;
6mod state;
7
8declare_id!("PTcbNDgvFXhhKyqfXnzpnNyFaxA9o6a1Cxz1QyLUh8Y");
9
10pub use crate::state::{
11 admin::Admin,
12 donation::Donation,
13 fund::Fund,
14 fund_participant::FundParticipant,
15 grant::Grant,
16 investment_round::InvestmentRound,
17 investor::Investor,
18 project::Project,
19 vesting::{DistributionPeriod, Vesting},
20 whitelist_token::WhitelistToken,
21};
22
23#[program]
24pub mod pitchtalk_solana {
25 use super::*;
26
27 pub fn initialize_contract_state(
28 ctx: Context<InitializeContractState>,
29 donation_fee: u64,
30 grant_fee: u64,
31 investment_fee: u64,
32 event_fee: u64,
33 bump: u8,
34 ) -> Result<()> {
35 ctx.accounts.initialize_contract_state(
36 donation_fee,
37 grant_fee,
38 investment_fee,
39 event_fee,
40 bump,
41 )
42 }
43
44 pub fn update_contract_state(
45 ctx: Context<UpdateContractState>,
46 donation_fee: u64,
47 grant_fee: u64,
48 investment_fee: u64,
49 event_fee: u64,
50 ) -> Result<()> {
51 ctx.accounts
52 .update_contract_state(donation_fee, grant_fee, investment_fee, event_fee)
53 }
54
55 pub fn create_admin(
56 ctx: Context<CreateAdmin>,
57 admin_id: u128,
58 account: Pubkey,
59 name: String,
60 bump: u8,
61 ) -> Result<()> {
62 ctx.accounts.create_admin(admin_id, account, name, bump)
63 }
64
65 pub fn update_admin(ctx: Context<UpdateAdmin>, account: Pubkey, name: String) -> Result<()> {
66 ctx.accounts.update_admin(account, name)
67 }
68
69 pub fn remove_admin(ctx: Context<RemoveAdmin>) -> Result<()> {
70 ctx.accounts.remove_admin()
71 }
72
73 pub fn add_whitelist_token(
74 ctx: Context<AddWhitelistToken>,
75 decimals: u8,
76 bump: u8,
77 ) -> Result<()> {
78 ctx.accounts.add_whitelist_token(decimals, bump)
79 }
80
81 pub fn create_project(
82 ctx: Context<CreateProject>,
83 project_id: u128,
84 author: Option<Pubkey>,
85 bump: u8,
86 ) -> Result<()> {
87 ctx.accounts.create_project(project_id, author, bump)
88 }
89
90 pub fn toggle_project_status(ctx: Context<UpdateProject>) -> Result<()> {
91 ctx.accounts.toggle_project_status()
92 }
93
94 pub fn toggle_donation_status(ctx: Context<UpdateProject>) -> Result<()> {
95 ctx.accounts.toggle_donation_status()
96 }
97
98 pub fn toggle_grant_status(ctx: Context<UpdateProject>) -> Result<()> {
99 ctx.accounts.toggle_grant_status()
100 }
101
102 pub fn toggle_investment_status(ctx: Context<UpdateProject>) -> Result<()> {
103 ctx.accounts.toggle_investment_status()
104 }
105
106 pub fn update_project_author(ctx: Context<UpdateProject>, author: Pubkey) -> Result<()> {
107 ctx.accounts.update_project_author(author)
108 }
109
110 pub fn set_project_token_account(ctx: Context<SetProjectTokenAccount>, bump: u8) -> Result<()> {
111 ctx.accounts.set_project_token_account(bump)
112 }
113
114 pub fn create_donation(ctx: Context<CreateDonation>, amount: u64, bump: u8) -> Result<()> {
115 ctx.accounts.create_donation(amount, bump)
116 }
117
118 pub fn withdraw_donations(
119 ctx: Context<WithdrawProjectAccumulations>,
120 amount: u64,
121 ) -> Result<()> {
122 ctx.accounts.withdraw_donations(amount)
123 }
124
125 pub fn withdraw_grants(ctx: Context<WithdrawProjectAccumulations>, amount: u64) -> Result<()> {
126 ctx.accounts.withdraw_grants(amount)
127 }
128
129 pub fn withdraw_investments(
130 ctx: Context<WithdrawProjectAccumulations>,
131 amount: u64,
132 ) -> Result<()> {
133 ctx.accounts.withdraw_investments(amount)
134 }
135
136 pub fn create_fund(
137 ctx: Context<CreateFund>,
138 fund_id: u128,
139 authority: Pubkey,
140 bump: u8,
141 ) -> Result<()> {
142 ctx.accounts.create_fund(fund_id, authority, bump)
143 }
144
145 pub fn update_fund_authority(ctx: Context<UpdateFund>, authority: Pubkey) -> Result<()> {
146 ctx.accounts.update_fund_authority(authority)
147 }
148
149 pub fn toggle_fund_status(ctx: Context<UpdateFund>) -> Result<()> {
150 ctx.accounts.toggle_fund_status()
151 }
152
153 pub fn add_fund_participant(
154 ctx: Context<AddFundParticipant>,
155 account: Pubkey,
156 bump: u8,
157 ) -> Result<()> {
158 ctx.accounts.add_fund_participant(account, bump)
159 }
160
161 pub fn remove_fund_participant(ctx: Context<RemoveFundParticipant>) -> Result<()> {
162 ctx.accounts.remove_fund_participant()
163 }
164
165 pub fn create_grant(ctx: Context<CreateGrant>, amount: u64, bump: u8) -> Result<()> {
166 ctx.accounts.create_grant(amount, bump)
167 }
168
169 // pub fn create_investment_round(
170 // ctx: Context<CreateInvestmentRound>,
171 // round_id: u128,
172 // start_date: i64,
173 // end_date: i64,
174 // min_amount: u64,
175 // max_amount: u64,
176 // target_amount: u64,
177 // bump: u8,
178 // ) -> Result<()> {
179 // ctx.accounts.create_investment_round(
180 // round_id,
181 // start_date,
182 // end_date,
183 // min_amount,
184 // max_amount,
185 // target_amount,
186 // bump,
187 // )
188 // }
189
190 // pub fn update_investment_round(
191 // ctx: Context<UpdateInvestmentRound>,
192 // start_date: i64,
193 // end_date: i64,
194 // min_amount: u64,
195 // max_amount: u64,
196 // target_amount: u64,
197 // ) -> Result<()> {
198 // ctx.accounts.update_investment_round(
199 // start_date,
200 // end_date,
201 // min_amount,
202 // max_amount,
203 // target_amount,
204 // )
205 // }
206
207 // pub fn remove_investment_round(ctx: Context<RemoveInvestmentRound>) -> Result<()> {
208 // ctx.accounts.remove_investment_round()
209 // }
210
211 // pub fn invest(ctx: Context<Invest>, amount: u64, bump: u8) -> Result<()> {
212 // ctx.accounts.invest(amount, bump)
213 // }
214
215 // pub fn setup_vesting(
216 // ctx: Context<SetupVesting>,
217 // start_date: i64,
218 // cliff_end_date: Option<i64>,
219 // is_termination_available: bool,
220 // price: u64,
221 // schedule: Vec<DistributionPeriod>,
222 // bump: u8,
223 // ) -> Result<()> {
224 // ctx.accounts.setup_vesting(
225 // start_date,
226 // cliff_end_date,
227 // is_termination_available,
228 // price,
229 // schedule,
230 // bump,
231 // )
232 // }
233
234 // pub fn activate_investment_round(ctx: Context<ActivateInvestmentRound>) -> Result<()> {
235 // ctx.accounts.activate_investment_round()
236 // }
237
238 // pub fn claim(ctx: Context<Claim>) -> Result<()> {
239 // ctx.accounts.claim()
240 // }
241
242 // pub fn terminate_investor(ctx: Context<TerminateInvestor>) -> Result<()> {
243 // ctx.accounts.terminate_investor()
244 // }
245
246 // pub fn withdraw_residue_amount(ctx: Context<WithdrawResidueAmount>) -> Result<()> {
247 // ctx.accounts.withdraw_residue_amount()
248 // }
249
250 // pub fn create_event(
251 // ctx: Context<CreateEvent>,
252 // event_id: u128,
253 // author: Option<Pubkey>,
254 // registration_end_date: Option<i64>,
255 // start_date: i64,
256 // end_date: i64,
257 // max_participant_count: Option<u64>,
258 // fee: u64,
259 // bump: u8,
260 // ) -> Result<()> {
261 // ctx.accounts.create_event(
262 // event_id,
263 // author,
264 // registration_end_date,
265 // start_date,
266 // end_date,
267 // max_participant_count,
268 // fee,
269 // bump,
270 // )
271 // }
272
273 // pub fn toggle_event_status(ctx: Context<UpdateEvent>) -> Result<()> {
274 // ctx.accounts.toggle_event_status()
275 // }
276
277 // pub fn update_event_author(ctx: Context<UpdateEvent>, author: Pubkey) -> Result<()> {
278 // ctx.accounts.update_event_author(author)
279 // }
280
281 // pub fn update_event_fee(ctx: Context<UpdateEvent>, fee: u64) -> Result<()> {
282 // ctx.accounts.update_event_fee(fee)
283 // }
284
285 // pub fn update_event_data(
286 // ctx: Context<UpdateEvent>,
287 // registration_end_date: Option<i64>,
288 // start_date: i64,
289 // end_date: i64,
290 // max_participant_count: Option<u64>,
291 // ) -> Result<()> {
292 // ctx.accounts.update_event_data(
293 // registration_end_date,
294 // start_date,
295 // end_date,
296 // max_participant_count,
297 // )
298 // }
299
300 // pub fn participate_in_the_event(
301 // ctx: Context<ParticipateInTheEvent>,
302 // participation_id: Option<u128>,
303 // bump: u8,
304 // ) -> Result<()> {
305 // ctx.accounts
306 // .participate_in_the_event(participation_id, bump)
307 // }
308
309 // pub fn withdraw_event_accumulations(
310 // ctx: Context<WithdrawEventAccumulations>,
311 // amount: u64,
312 // ) -> Result<()> {
313 // ctx.accounts.withdraw_event_accumulations(amount)
314 // }
315}