lib.rs 843 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. use anchor_lang::prelude::*;
  2. declare_id!("Eoiuq1dXvHxh6dLx3wh9gj8kSAUpga11krTrbfF5XYsC");
  3. mod state;
  4. mod instructions;
  5. mod error;
  6. mod constants;
  7. use instructions::*;
  8. use error::*;
  9. pub use constants::*;
  10. #[program]
  11. pub mod fundraiser {
  12. use super::*;
  13. pub fn initialize(ctx: Context<Initialize>, amount: u64, duration: u16) -> Result<()> {
  14. ctx.accounts.initialize(amount, duration, &ctx.bumps)?;
  15. Ok(())
  16. }
  17. pub fn contribute(ctx: Context<Contribute>, amount: u64) -> Result<()> {
  18. ctx.accounts.contribute(amount)?;
  19. Ok(())
  20. }
  21. pub fn check_contributions(ctx: Context<CheckContributions>) -> Result<()> {
  22. ctx.accounts.check_contributions()?;
  23. Ok(())
  24. }
  25. pub fn refund(ctx: Context<Refund>) -> Result<()> {
  26. ctx.accounts.refund()?;
  27. Ok(())
  28. }
  29. }