lib.rs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. extern crate proc_macro;
  2. use proc_macro::TokenStream;
  3. use quote::ToTokens;
  4. use syn::parse_macro_input;
  5. /// Implements an [`Accounts`](./trait.Accounts.html) deserializer on the given
  6. /// struct. Can provide further functionality through the use of attributes.
  7. ///
  8. /// # Table of Contents
  9. /// - [Instruction Attribute](#instruction-attribute)
  10. /// - [Constraints](#constraints)
  11. ///
  12. /// # Instruction Attribute
  13. ///
  14. /// You can access the instruction's arguments with the
  15. /// `#[instruction(..)]` attribute. You have to list them
  16. /// in the same order as in the instruction but you can
  17. /// omit all arguments after the last one you need.
  18. ///
  19. /// # Example
  20. ///
  21. /// ```ignore
  22. /// ...
  23. /// pub fn initialize(ctx: Context<Create>, bump: u8, authority: Pubkey, data: u64) -> ProgramResult {
  24. /// ...
  25. /// Ok(())
  26. /// }
  27. /// ...
  28. /// #[derive(Accounts)]
  29. /// #[instruction(bump: u8)]
  30. /// pub struct Initialize<'info> {
  31. /// ...
  32. /// }
  33. /// ```
  34. ///
  35. /// # Constraints
  36. ///
  37. /// There are different types of constraints that can be applied with the `#[account(..)]` attribute.
  38. ///
  39. /// Attributes may reference other data structures. When `<expr>` is used in the tables below, an arbitrary expression
  40. /// may be passed in as long as it evaluates to a value of the expected type, e.g. `owner = token_program.key()`. If `target_account`
  41. /// used, the `target_account` must exist in the struct and the `.key()` is implicit, e.g. `payer = authority`.
  42. ///
  43. /// - [Normal Constraints](#normal-constraints)
  44. /// - [SPL Constraints](#spl-constraints)
  45. /// # Normal Constraints
  46. /// <table>
  47. /// <thead>
  48. /// <tr>
  49. /// <th>Attribute</th>
  50. /// <th>Description</th>
  51. /// </tr>
  52. /// </thead>
  53. /// <tbody>
  54. /// <tr>
  55. /// <td>
  56. /// <code>#[account(signer)]</code> <br><br><code>#[account(signer @ &lt;custom_error&gt;)]</code>
  57. /// </td>
  58. /// <td>
  59. /// Checks the given account signed the transaction.<br>
  60. /// Custom errors are supported via <code>@</code>.<br>
  61. /// Consider using the <code>Signer</code> type if you would only have this constraint on the account.<br><br>
  62. /// Example:
  63. /// <pre><code>
  64. /// #[account(signer)]
  65. /// pub authority: AccountInfo<'info>,
  66. /// #[account(signer @ MyError::MyErrorCode)]
  67. /// pub payer: AccountInfo<'info>
  68. /// </code></pre>
  69. /// </td>
  70. /// </tr>
  71. /// <tr>
  72. /// <td>
  73. /// <code>#[account(mut)]</code> <br><br><code>#[account(mut @ &lt;custom_error&gt;)]</code>
  74. /// </td>
  75. /// <td>
  76. /// Checks the given account is mutable.<br>
  77. /// Makes anchor persist any state changes.<br>
  78. /// Custom errors are supported via <code>@</code>.<br><br>
  79. /// Example:
  80. /// <pre><code>
  81. /// #[account(mut)]
  82. /// pub data_account: Account<'info, MyData>,
  83. /// #[account(mut @ MyError::MyErrorCode)]
  84. /// pub data_account_two: Account<'info, MyData>
  85. /// </code></pre>
  86. /// </td>
  87. /// </tr>
  88. /// <tr>
  89. /// <td>
  90. /// <code>#[account(init, payer = &lt;target_account&gt;)]</code><br><br>
  91. /// <code>#[account(init, payer = &lt;target_account&gt;, space = &lt;num_bytes&gt;)]</code>
  92. /// </td>
  93. /// <td>
  94. /// Creates the account via a CPI to the system program and
  95. /// initializes it (sets its account discriminator).<br>
  96. /// Marks the account as mutable and is mutually exclusive with <code>mut</code>.<br>
  97. /// Makes the account rent exempt unless skipped with `rent_exempt = skip`.<br>
  98. /// <ul>
  99. /// <li>
  100. /// Requires the <code>payer</code> constraint to also be on the account.
  101. /// The <code>payer</code> account pays for the
  102. /// account creation.
  103. /// </li>
  104. /// <li>
  105. /// Requires the system program to exist on the struct
  106. /// and be called <code>system_program</code>.
  107. /// </li>
  108. /// <li>
  109. /// Requires that the <code>space</code> constraint is specified
  110. /// or, if creating an <code>Account</code> type, the <code>T</code> of <code>Account</code>
  111. /// to implement the rust std <code>Default</code> trait.<br>
  112. /// When using the <code>space</code> constraint, one must remember to add 8 to it
  113. /// which is the size of the account discriminator.<br>
  114. /// The given number is the size of the account in bytes, so accounts that hold
  115. /// a variable number of items such as a <code>Vec</code> should use the <code>space</code>
  116. /// constraint instead of using the <code>Default</code> trait and allocate sufficient space for all items that may
  117. /// be added to the data structure because account size is fixed. Check out the <a href = "https://borsh.io/" target = "_blank" rel = "noopener noreferrer">borsh library</a>
  118. /// (which anchor uses under the hood for serialization) specification to learn how much
  119. /// space different data structures require.
  120. /// </li>
  121. /// <br>
  122. /// Example:
  123. /// <pre>
  124. /// #[account]
  125. /// #[derive(Default)]
  126. /// pub struct MyData {
  127. /// &nbsp;&nbsp;&nbsp;&nbsp;pub data: u64
  128. /// }&#10;
  129. /// #[account]
  130. /// pub struct OtherData {
  131. /// &nbsp;&nbsp;&nbsp;&nbsp;pub data: u64
  132. /// }&#10;
  133. /// #[derive(Accounts)]
  134. /// pub struct Initialize<'info> {
  135. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(init, payer = payer)]
  136. /// &nbsp;&nbsp;&nbsp;&nbsp;pub data_account: Account<'info, MyData>,
  137. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(init, payer = payer, space = 8 + 8)]
  138. /// &nbsp;&nbsp;&nbsp;&nbsp;pub data_account_two: Account<'info, OtherData>,
  139. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(mut)]
  140. /// &nbsp;&nbsp;&nbsp;&nbsp;pub payer: Signer<'info>,
  141. /// &nbsp;&nbsp;&nbsp;&nbsp;pub system_program: Program<'info, System>,
  142. /// }
  143. /// </pre>
  144. /// </ul>
  145. /// <code>init</code> can be combined with other constraints (at the same time):
  146. /// <ul>
  147. /// <li>
  148. /// By default <code>init</code> sets the owner field of the created account to the
  149. /// currently executing program. Add the <code>owner</code> constraint to specify a
  150. /// different program owner.
  151. /// </li>
  152. /// <li>
  153. /// Use the <code>seeds</code> constraint together with <code>bump</code>to create PDAs.<br>
  154. /// <code>init</code> uses <code>find_program_address</code> to calculate the pda so the
  155. /// bump value can be left empty.<br>
  156. /// However, if you want to use the bump in your instruction,
  157. /// you can pass it in as instruction data and set the bump value like shown in the example,
  158. /// using the <code>instruction_data</code> attribute.
  159. /// Anchor will then check that the bump returned by <code>find_program_address</code> equals
  160. /// the bump in the instruction data.
  161. /// </li>
  162. /// </ul>
  163. /// Example:
  164. /// <pre>
  165. /// #[derive(Accounts)]
  166. /// #[instruction(bump: u8)]
  167. /// pub struct Initialize<'info> {
  168. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(
  169. /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;init, payer = payer,
  170. /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;seeds = [b"example_seed".as_ref()], bump = bump
  171. /// &nbsp;&nbsp;&nbsp;&nbsp;)]
  172. /// &nbsp;&nbsp;&nbsp;&nbsp;pub pda_data_account: Account<'info, MyData>,
  173. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(
  174. /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;init, payer = payer,
  175. /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;space = 8 + 8, owner = other_program.key()
  176. /// &nbsp;&nbsp;&nbsp;&nbsp;)]
  177. /// &nbsp;&nbsp;&nbsp;&nbsp;pub account_for_other_program: AccountInfo<'info>,
  178. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(
  179. /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;init,payer = payer, space = 8 + 8,
  180. /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;owner = other_program.key(),
  181. /// &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;seeds = [b"other_seed".as_ref()], bump
  182. /// &nbsp;&nbsp;&nbsp;&nbsp;)]
  183. /// &nbsp;&nbsp;&nbsp;&nbsp;pub pda_for_other_program: AccountInfo<'info>,
  184. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(mut)]
  185. /// &nbsp;&nbsp;&nbsp;&nbsp;pub payer: Signer<'info>,
  186. /// &nbsp;&nbsp;&nbsp;&nbsp;pub system_program: Program<'info, System>,
  187. /// &nbsp;&nbsp;&nbsp;&nbsp;pub other_program: Program<'info, OtherProgram>
  188. /// }
  189. /// </pre>
  190. /// </td>
  191. /// </tr>
  192. /// <tr>
  193. /// <td>
  194. /// <code>#[account(init_if_needed, payer = &lt;target_account&gt;)]</code><br><br>
  195. /// <code>#[account(init_if_needed, payer = &lt;target_account&gt;, space = &lt;num_bytes&gt;)]</code>
  196. /// </td>
  197. /// <td>
  198. /// Exact same functionality as the <code>init</code> constraint but only runs if the account does not exist yet.<br>
  199. /// If it does exist, it still checks whether the given init constraints are correct,
  200. /// e.g. that the account has the expected amount of space and, if it's a PDA, the correct seeds etc.
  201. /// <br><br>
  202. /// Example:
  203. /// <pre>
  204. /// #[account]
  205. /// #[derive(Default)]
  206. /// pub struct MyData {
  207. /// &nbsp;&nbsp;&nbsp;&nbsp;pub data: u64
  208. /// }&#10;
  209. /// #[account]
  210. /// pub struct OtherData {
  211. /// &nbsp;&nbsp;&nbsp;&nbsp;pub data: u64
  212. /// }&#10;
  213. /// #[derive(Accounts)]
  214. /// pub struct Initialize<'info> {
  215. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(init_if_needed, payer = payer)]
  216. /// &nbsp;&nbsp;&nbsp;&nbsp;pub data_account: Account<'info, MyData>,
  217. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(init_if_needed, payer = payer, space = 8 + 8)]
  218. /// &nbsp;&nbsp;&nbsp;&nbsp;pub data_account_two: Account<'info, OtherData>,
  219. /// &nbsp;&nbsp;&nbsp;&nbsp;#[account(mut)]
  220. /// &nbsp;&nbsp;&nbsp;&nbsp;pub payer: Signer<'info>,
  221. /// &nbsp;&nbsp;&nbsp;&nbsp;pub system_program: Program<'info, System>
  222. /// }
  223. /// </pre>
  224. /// </td>
  225. /// </tr>
  226. /// <tr>
  227. /// <td>
  228. /// <code>#[account(seeds = &lt;seeds&gt;, bump)]</code><br><br>
  229. /// <code>#[account(seeds = &lt;seeds&gt;, bump = &lt;expr&gt;)]</code>
  230. /// </td>
  231. /// <td>
  232. /// Checks that given account is a PDA derived from the currently executing program,
  233. /// the seeds, and if provided, the bump. If not provided, anchor uses the canonical
  234. /// bump. Will be adjusted in the future to allow PDA to be derived from other programs.<br>
  235. /// This constraint behaves slightly differently when used with <code>init</code>.
  236. /// See its description.
  237. /// <br><br>
  238. /// Example:
  239. /// <pre><code>
  240. /// #[account(seeds = [b"example_seed], bump)]
  241. /// pub canonical_pda: AccountInfo<'info>,
  242. /// #[account(seeds = [b"other_seed], bump = 142)]
  243. /// pub arbitrary_pda: AccountInfo<'info>
  244. /// </code></pre>
  245. /// </td>
  246. /// </tr>
  247. /// <tr>
  248. /// <td>
  249. /// <code>#[account(has_one = &lt;target_account&gt;)]</code><br><br>
  250. /// <code>#[account(has_one = &lt;target_account&gt; @ &lt;custom_error&gt;)]</code>
  251. /// </td>
  252. /// <td>
  253. /// Checks the <code>target_account</code> field on the account matches the
  254. /// key of the <code>target_account</code> field in the Accounts struct.<br>
  255. /// Custom errors are supported via <code>@</code>.<br><br>
  256. /// Example:
  257. /// <pre><code>
  258. /// #[account(mut, has_one = authority)]
  259. /// pub data: Account<'info, MyData>,
  260. /// pub authority: Signer<'info>
  261. /// </code></pre>
  262. /// In this example <code>has_one</code> checks that <code>data.authority = authority.key()</code>
  263. /// </td>
  264. /// </tr>
  265. /// <tr>
  266. /// <td>
  267. /// <code>#[account(address = &lt;expr&gt;)]</code><br><br>
  268. /// <code>#[account(address = &lt;expr&gt; @ &lt;custom_error&gt;)]</code>
  269. /// </td>
  270. /// <td>
  271. /// Checks the account key matches the pubkey.<br>
  272. /// Custom errors are supported via <code>@</code>.<br><br>
  273. /// Example:
  274. /// <pre><code>
  275. /// #[account(address = crate::ID)]
  276. /// pub data: Account<'info, MyData>,
  277. /// #[account(address = crate::ID @ MyError::MyErrorCode)]
  278. /// pub data_two: Account<'info, MyData>
  279. /// </code></pre>
  280. /// </td>
  281. /// </tr>
  282. /// <tr>
  283. /// <td>
  284. /// <code>#[account(owner = &lt;expr&gt;)]</code><br><br>
  285. /// <code>#[account(owner = &lt;expr&gt; @ &lt;custom_error&gt;)]</code>
  286. /// </td>
  287. /// <td>
  288. /// Checks the account owner matches <code>expr</code>.<br>
  289. /// Custom errors are supported via <code>@</code>.<br><br>
  290. /// Example:
  291. /// <pre><code>
  292. /// #[account(owner = Token::ID @ MyError::MyErrorCode)]
  293. /// pub data: Account<'info, MyData>,
  294. /// #[account(owner = token_program.key())]
  295. /// pub data_two: Account<'info, MyData>,
  296. /// pub token_program: Program<'info, Token>
  297. /// </code></pre>
  298. /// </td>
  299. /// </tr>
  300. /// <tr>
  301. /// <td>
  302. /// <code>#[account(executable)]</code>
  303. /// </td>
  304. /// <td>
  305. /// Checks the account is executable (i.e. the account is a program).<br>
  306. /// You may want to use the <code>Program</code> type instead.<br><br>
  307. /// Example:
  308. /// <pre><code>
  309. /// #[account(executable)]
  310. /// pub my_program: AccountInfo<'info>
  311. /// </code></pre>
  312. /// </td>
  313. /// </tr>
  314. /// <tr>
  315. /// <td>
  316. /// <code>#[account(rent_exempt = skip)]</code><br><br>
  317. /// <code>#[account(rent_exempt = enforce)]</code>
  318. /// </td>
  319. /// <td>
  320. /// Enforces rent exemption with <code>= enforce</code>.<br>
  321. /// Skips rent exemption check that would normally be done
  322. /// through other constraints with <code>= skip</code>,
  323. /// e.g. when used with the <code>zero</code> constraint<br><br>
  324. /// Example:
  325. /// <pre><code>
  326. /// #[account(zero, rent_exempt = skip)]
  327. /// pub skipped_account: Account<'info, MyData>,
  328. /// #[account(rent_exempt = enforce)]
  329. /// pub enforced_account: AccountInfo<'info>
  330. /// </code></pre>
  331. /// </td>
  332. /// </tr>
  333. /// <tr>
  334. /// <td>
  335. /// <code>#[account(zero)]</code>
  336. /// </td>
  337. /// <td>
  338. /// Checks the account discriminator is zero.<br>
  339. /// Enforces rent exemption unless skipped with <code>rent_exempt = skip</code><br><br>
  340. /// Example:
  341. /// <pre><code>
  342. /// #[account(zero)]
  343. /// pub my_account: Account<'info, MyData>
  344. /// </code></pre>
  345. /// </td>
  346. /// </tr>
  347. /// <tr>
  348. /// <td>
  349. /// <code>#[account(close = &lt;target_account&gt;)]</code>
  350. /// </td>
  351. /// <td>
  352. /// Marks the account as closed at the end of the instruction’s execution
  353. /// (sets its discriminator to the <code>CLOSED_ACCOUNT_DISCRIMINATOR</code>)
  354. /// and sends its lamports to the specified account.<br>
  355. /// Setting the discriminator to a special variant
  356. /// makes account revival attacks (where a subsequent instruction
  357. /// adds the rent exemption lamports again) impossible.<br>
  358. /// Requires <code>mut</code> to exist on the account.
  359. /// <br><br>
  360. /// Example:
  361. /// <pre><code>
  362. /// #[account(mut, close = receiver)]
  363. /// pub data_account: Account<'info, MyData>,
  364. /// #[account(mut)]
  365. /// pub receiver: SystemAccount<'info>
  366. /// </code></pre>
  367. /// </td>
  368. /// </tr>
  369. /// <tr>
  370. /// <td>
  371. /// <code>#[account(constraint = &lt;expr&gt;)]</code><br><br><code>#[account(constraint = &lt;expr&gt; @ &lt;custom_error&gt;)]</code>
  372. /// </td>
  373. /// <td>
  374. /// Constraint that checks whether the given expression evaluates to true.<br>
  375. /// Use this when no other constraint fits your use case.
  376. /// <br><br>
  377. /// Example:
  378. /// <pre><code>
  379. /// #[account(constraint = one.keys[0].age == two.apple.age)]
  380. /// pub one: Account<'info, MyData>,
  381. /// pub two: Account<'info, OtherData>
  382. /// </code></pre>
  383. /// </td>
  384. /// </tr>
  385. /// </tbody>
  386. /// </table>
  387. ///
  388. /// # SPL Constraints
  389. ///
  390. /// Anchor provides constraints that make verifying SPL accounts easier.
  391. ///
  392. /// <table>
  393. /// <thead>
  394. /// <tr>
  395. /// <th>Attribute</th>
  396. /// <th>Description</th>
  397. /// </tr>
  398. /// </thead>
  399. /// <tbody>
  400. /// <tr>
  401. /// <td>
  402. /// <code>#[account(token::mint = &lt;target_account&gt;, token::authority = &lt;target_account&gt;)]</code>
  403. /// </td>
  404. /// <td>
  405. /// Can currently only be used with <code>init</code> to create a token
  406. /// account with the given mint address and authority.
  407. /// <br><br>
  408. /// Example:
  409. /// <pre>
  410. /// use anchor_spl::{mint, token::{TokenAccount, Mint, Token}};
  411. /// ...&#10;
  412. /// #[account(
  413. /// init,
  414. /// payer = payer,
  415. /// token::mint = mint,
  416. /// token::authority = payer,
  417. /// )]
  418. /// pub token: Account<'info, TokenAccount>,
  419. /// #[account(address = mint::USDC)]
  420. /// pub mint: Account<'info, Mint>,
  421. /// #[account(mut)]
  422. /// pub payer: Signer<'info>,
  423. /// pub token_program: Program<'info, Token>,
  424. /// pub system_program: Program<'info, System>
  425. /// </pre>
  426. /// </td>
  427. /// </tr>
  428. /// <tr>
  429. /// <td>
  430. /// <code>#[account(mint::authority = &lt;target_account&gt;, mint::decimals = &lt;expr&gt;)]</code>
  431. /// <br><br>
  432. /// <code>#[account(mint::authority = &lt;target_account&gt;, mint::decimals = &lt;expr&gt;, mint::freeze_authority = &lt;target_account&gt;)]</code>
  433. /// </td>
  434. /// <td>
  435. /// Can currently only be used with <code>init</code> to create a mint
  436. /// account with the given mint decimals and mint authority.<br>
  437. /// The freeze authority is optional.
  438. /// <br><br>
  439. /// Example:
  440. /// <pre>
  441. /// use anchor_spl::token::{Mint, Token};
  442. /// ...&#10;
  443. /// #[account(
  444. /// init,
  445. /// payer = payer,
  446. /// mint::decimals = 9,
  447. /// mint::authority = payer,
  448. /// )]
  449. /// pub mint_one: Account<'info, Mint>,
  450. /// #[account(
  451. /// init,
  452. /// payer = payer,
  453. /// mint::decimals = 9,
  454. /// mint::authority = payer,
  455. /// mint::freeze_authority = payer
  456. /// )]
  457. /// pub mint_two: Account<'info, Mint>,
  458. /// #[account(mut)]
  459. /// pub payer: Signer<'info>,
  460. /// pub token_program: Program<'info, Token>,
  461. /// pub system_program: Program<'info, System>
  462. /// </pre>
  463. /// </td>
  464. /// </tr>
  465. /// <tr>
  466. /// <td>
  467. /// <code>#[account(associated_token::mint = &lt;target_account&gt;, associated_token::authority = &lt;target_account&gt;)]</code>
  468. /// </td>
  469. /// <td>
  470. /// Can be used as a standalone as a check or with <code>init</code> to create an associated token
  471. /// account with the given mint address and authority.
  472. /// <br><br>
  473. /// Example:
  474. /// <pre>
  475. /// use anchor_spl::{
  476. /// associated_token::AssociatedToken,
  477. /// mint,
  478. /// token::{TokenAccount, Mint, Token}
  479. /// };
  480. /// ...&#10;
  481. /// #[account(
  482. /// init,
  483. /// payer = payer,
  484. /// associated_token::mint = mint,
  485. /// associated_token::authority = payer,
  486. /// )]
  487. /// pub token: Account<'info, TokenAccount>,
  488. /// #[account(
  489. /// associated_token::mint = mint,
  490. /// associated_token::authority = payer,
  491. /// )]
  492. /// pub second_token: Account<'info, TokenAccount>,
  493. /// #[account(address = mint::USDC)]
  494. /// pub mint: Account<'info, Mint>,
  495. /// #[account(mut)]
  496. /// pub payer: Signer<'info>,
  497. /// pub token_program: Program<'info, Token>,
  498. /// pub associated_token_program: Program<'info, AssociatedToken>,
  499. /// pub system_program: Program<'info, System>
  500. /// </pre>
  501. /// </td>
  502. /// </tr>
  503. /// <tbody>
  504. /// </table>
  505. #[proc_macro_derive(Accounts, attributes(account, instruction))]
  506. pub fn derive_anchor_deserialize(item: TokenStream) -> TokenStream {
  507. parse_macro_input!(item as anchor_syn::AccountsStruct)
  508. .to_token_stream()
  509. .into()
  510. }