lib.rs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // This file is autogenerated with https://github.com/acheroncrypto/native-to-anchor
  2. use anchor_lang::prelude::*;
  3. declare_id!("11111111111111111111111111111111");
  4. #[program]
  5. pub mod spl_record {
  6. use super::*;
  7. pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
  8. Ok(())
  9. }
  10. pub fn write(ctx: Context<Write>, offset: u64, data: Vec<u8>) -> Result<()> {
  11. Ok(())
  12. }
  13. pub fn set_authority(ctx: Context<SetAuthority>) -> Result<()> {
  14. Ok(())
  15. }
  16. pub fn close_account(ctx: Context<CloseAccount>) -> Result<()> {
  17. Ok(())
  18. }
  19. }
  20. #[derive(Accounts)]
  21. pub struct Initialize<'info> {
  22. #[account(mut)]
  23. record_account: AccountInfo<'info>,
  24. authority: AccountInfo<'info>,
  25. }
  26. #[derive(Accounts)]
  27. pub struct Write<'info> {
  28. #[account(mut)]
  29. record_account: AccountInfo<'info>,
  30. signer: Signer<'info>,
  31. }
  32. #[derive(Accounts)]
  33. pub struct SetAuthority<'info> {
  34. #[account(mut)]
  35. record_account: AccountInfo<'info>,
  36. signer: Signer<'info>,
  37. new_authority: AccountInfo<'info>,
  38. }
  39. #[derive(Accounts)]
  40. pub struct CloseAccount<'info> {
  41. #[account(mut)]
  42. record_account: AccountInfo<'info>,
  43. signer: Signer<'info>,
  44. #[account(mut)]
  45. receiver: AccountInfo<'info>,
  46. }
  47. #[account]
  48. pub struct RecordData {
  49. /// Struct version, allows for upgrades to the program
  50. pub version: u8,
  51. /// The account allowed to update the data
  52. pub authority: Pubkey,
  53. /// The data contained by the account, could be anything serializable
  54. pub data: Data,
  55. }
  56. #[derive(AnchorSerialize, AnchorDeserialize)]
  57. pub struct Data {
  58. /// The data contained by the account, could be anything or serializable
  59. pub bytes: [u8; 8],
  60. }
  61. #[error_code]
  62. pub enum RecordError {
  63. /// Incorrect authority provided on update or delete
  64. #[msg("Incorrect authority provided on update or delete")]
  65. IncorrectAuthority,
  66. /// Calculation overflow
  67. #[msg("Calculation overflow")]
  68. Overflow,
  69. }