lib.rs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. use anchor_lang::prelude::*;
  2. declare_id!("CmP2djJgABZ4cRokm4ndxuq6LerqpNHLBsaUv2XKEJua");
  3. #[program]
  4. pub mod bolt_component {
  5. use super::*;
  6. pub fn initialize(_ctx: Context<Initialize>) -> Result<()> {
  7. Ok(())
  8. }
  9. pub fn destroy(_ctx: Context<Destroy>) -> Result<()> {
  10. Ok(())
  11. }
  12. pub fn set_owner(_ctx: Context<SetOwner>, _owner: Pubkey) -> Result<()> {
  13. Ok(())
  14. }
  15. pub fn set_data(_ctx: Context<SetData>) -> Result<()> {
  16. Ok(())
  17. }
  18. }
  19. #[derive(Accounts)]
  20. pub struct Initialize<'info> {
  21. #[account()]
  22. pub cpi_auth: Signer<'info>,
  23. #[account(mut)]
  24. pub payer: Signer<'info>,
  25. #[account(mut)]
  26. /// CHECK: The component to initialize
  27. pub data: UncheckedAccount<'info>,
  28. #[account()]
  29. /// CHECK: A generic entity account
  30. pub entity: AccountInfo<'info>,
  31. #[account()]
  32. /// CHECK: The authority of the component
  33. pub authority: AccountInfo<'info>,
  34. pub system_program: Program<'info, System>,
  35. }
  36. #[derive(Accounts)]
  37. pub struct Destroy<'info> {
  38. #[account()]
  39. pub cpi_auth: Signer<'info>,
  40. #[account()]
  41. pub authority: Signer<'info>,
  42. #[account(mut)]
  43. /// CHECK: The receiver of the component
  44. pub receiver: AccountInfo<'info>,
  45. #[account()]
  46. /// CHECK: The entity to destroy the component on
  47. pub entity: AccountInfo<'info>,
  48. #[account(mut)]
  49. /// CHECK: The component to destroy
  50. pub component: UncheckedAccount<'info>,
  51. #[account()]
  52. /// CHECK: The component program data
  53. pub component_program_data: AccountInfo<'info>,
  54. pub system_program: Program<'info, System>,
  55. }
  56. #[derive(Accounts)]
  57. pub struct SetOwner<'info> {
  58. #[account()]
  59. pub cpi_auth: Signer<'info>,
  60. #[account(mut)]
  61. /// CHECK: The component to set the owner on
  62. pub component: UncheckedAccount<'info>,
  63. }
  64. #[derive(Accounts, Clone)]
  65. pub struct SetData<'info> {
  66. #[account()]
  67. pub cpi_auth: Signer<'info>,
  68. /// CHECK: buffer data check
  69. #[account()]
  70. pub buffer: UncheckedAccount<'info>,
  71. /// CHECK: component data check
  72. #[account(mut)]
  73. pub component: UncheckedAccount<'info>,
  74. }
  75. #[derive(InitSpace, AnchorSerialize, AnchorDeserialize, Default, Copy, Clone)]
  76. pub struct BoltMetadata {
  77. pub authority: Pubkey,
  78. }
  79. #[cfg(feature = "cpi")]
  80. pub trait CpiContextBuilder<'a, 'b, 'c, 'info>:
  81. ToAccountMetas + ToAccountInfos<'info> + Sized
  82. {
  83. fn build_cpi_context(
  84. self,
  85. program: AccountInfo<'info>,
  86. signer_seeds: &'a [&'b [&'c [u8]]],
  87. ) -> CpiContext<'a, 'b, 'c, 'info, Self>;
  88. }