lib.rs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. use anchor_lang::prelude::*;
  2. declare_id!("9NxAd91hhJ3ZBTHytYP894y4ESRKG7n8VbLgdyYGJFLB");
  3. #[program]
  4. pub mod native_system {
  5. use super::*;
  6. pub fn create_account(
  7. ctx: Context<CreateAccount>,
  8. lamports: u64,
  9. space: u64,
  10. owner: Pubkey,
  11. ) -> Result<()> {
  12. Ok(())
  13. }
  14. pub fn assign(ctx: Context<Assign>, owner: Pubkey) -> Result<()> {
  15. Ok(())
  16. }
  17. pub fn transfer(ctx: Context<Transfer>, lamports: u64) -> Result<()> {
  18. Ok(())
  19. }
  20. pub fn create_account_with_seed(
  21. ctx: Context<CreateAccountWithSeed>,
  22. base: Pubkey,
  23. seed: String,
  24. lamports: u64,
  25. space: u64,
  26. owner: Pubkey,
  27. ) -> Result<()> {
  28. Ok(())
  29. }
  30. pub fn advance_nonce_account(
  31. ctx: Context<AdvanceNonceAccount>,
  32. authorized: Pubkey,
  33. ) -> Result<()> {
  34. Ok(())
  35. }
  36. pub fn withdraw_nonce_account(ctx: Context<WithdrawNonceAccount>, lamports: u64) -> Result<()> {
  37. Ok(())
  38. }
  39. pub fn initialize_nonce_account(
  40. ctx: Context<InitializeNonceAccount>,
  41. authorized: Pubkey,
  42. ) -> Result<()> {
  43. Ok(())
  44. }
  45. pub fn authorize_nonce_account(
  46. ctx: Context<AuthorizeNonceAccount>,
  47. authorized: Pubkey,
  48. ) -> Result<()> {
  49. Ok(())
  50. }
  51. pub fn allocate(ctx: Context<Allocate>, space: u64) -> Result<()> {
  52. Ok(())
  53. }
  54. pub fn allocate_with_seed(
  55. ctx: Context<AllocateWithSeed>,
  56. base: Pubkey,
  57. seed: String,
  58. space: u64,
  59. owner: Pubkey,
  60. ) -> Result<()> {
  61. Ok(())
  62. }
  63. pub fn assign_with_seed(
  64. ctx: Context<AssignWithSeed>,
  65. base: Pubkey,
  66. seed: String,
  67. owner: Pubkey,
  68. ) -> Result<()> {
  69. Ok(())
  70. }
  71. pub fn transfer_with_seed(
  72. ctx: Context<TransferWithSeed>,
  73. lamports: u64,
  74. seed: String,
  75. owner: Pubkey,
  76. ) -> Result<()> {
  77. Ok(())
  78. }
  79. }
  80. #[derive(Accounts)]
  81. pub struct CreateAccount<'info> {
  82. #[account(mut)]
  83. from: Signer<'info>,
  84. #[account(mut)]
  85. to: Signer<'info>,
  86. }
  87. #[derive(Accounts)]
  88. pub struct Assign<'info> {
  89. #[account(mut)]
  90. pubkey: Signer<'info>,
  91. }
  92. #[derive(Accounts)]
  93. pub struct Transfer<'info> {
  94. #[account(mut)]
  95. from: Signer<'info>,
  96. #[account(mut)]
  97. /// CHECK:
  98. to: AccountInfo<'info>,
  99. }
  100. #[derive(Accounts)]
  101. pub struct CreateAccountWithSeed<'info> {
  102. #[account(mut)]
  103. from: Signer<'info>,
  104. #[account(mut)]
  105. /// CHECK:
  106. to: AccountInfo<'info>,
  107. base: Signer<'info>,
  108. }
  109. #[derive(Accounts)]
  110. pub struct AdvanceNonceAccount<'info> {
  111. #[account(mut)]
  112. /// CHECK:
  113. nonce: AccountInfo<'info>,
  114. /// CHECK:
  115. recent_blockhashes: AccountInfo<'info>,
  116. authorized: Signer<'info>,
  117. }
  118. #[derive(Accounts)]
  119. pub struct WithdrawNonceAccount<'info> {
  120. #[account(mut)]
  121. /// CHECK:
  122. nonce: AccountInfo<'info>,
  123. #[account(mut)]
  124. /// CHECK:
  125. to: AccountInfo<'info>,
  126. /// CHECK:
  127. recent_blockhashes: AccountInfo<'info>,
  128. rent: Sysvar<'info, Rent>,
  129. authorized: Signer<'info>,
  130. }
  131. #[derive(Accounts)]
  132. pub struct InitializeNonceAccount<'info> {
  133. #[account(mut)]
  134. nonce: Signer<'info>,
  135. /// CHECK:
  136. recent_blockhashes: AccountInfo<'info>,
  137. rent: Sysvar<'info, Rent>,
  138. }
  139. #[derive(Accounts)]
  140. pub struct AuthorizeNonceAccount<'info> {
  141. #[account(mut)]
  142. /// CHECK:
  143. nonce: AccountInfo<'info>,
  144. authorized: Signer<'info>,
  145. }
  146. #[derive(Accounts)]
  147. pub struct Allocate<'info> {
  148. #[account(mut)]
  149. pubkey: Signer<'info>,
  150. }
  151. #[derive(Accounts)]
  152. pub struct AllocateWithSeed<'info> {
  153. #[account(mut)]
  154. /// CHECK:
  155. account: AccountInfo<'info>,
  156. base: Signer<'info>,
  157. }
  158. #[derive(Accounts)]
  159. pub struct AssignWithSeed<'info> {
  160. #[account(mut)]
  161. /// CHECK:
  162. account: AccountInfo<'info>,
  163. base: Signer<'info>,
  164. }
  165. #[derive(Accounts)]
  166. pub struct TransferWithSeed<'info> {
  167. #[account(mut)]
  168. /// CHECK:
  169. from: AccountInfo<'info>,
  170. base: Signer<'info>,
  171. #[account(mut)]
  172. /// CHECK:
  173. to: AccountInfo<'info>,
  174. }
  175. #[derive(AnchorSerialize, AnchorDeserialize, Clone)]
  176. pub struct FeeCalculator {
  177. pub lamports_per_signature: u64,
  178. }
  179. #[account]
  180. pub struct Nonce {
  181. pub version: u32,
  182. pub state: u32,
  183. pub authorized_pubkey: Pubkey,
  184. pub nonce: Pubkey,
  185. pub fee_calculator: FeeCalculator,
  186. }