metadata.rs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827
  1. use anchor_lang::context::CpiContext;
  2. use anchor_lang::error::ErrorCode;
  3. use anchor_lang::{Accounts, Result, ToAccountInfos};
  4. use mpl_token_metadata::state::{CollectionDetails, DataV2, TokenMetadataAccount};
  5. use mpl_token_metadata::ID;
  6. use solana_program::account_info::AccountInfo;
  7. use solana_program::pubkey::Pubkey;
  8. use std::ops::Deref;
  9. pub fn approve_collection_authority<'info>(
  10. ctx: CpiContext<'_, '_, '_, 'info, ApproveCollectionAuthority<'info>>,
  11. ) -> Result<()> {
  12. let ix = mpl_token_metadata::instruction::approve_collection_authority(
  13. ID,
  14. *ctx.accounts.collection_authority_record.key,
  15. *ctx.accounts.new_collection_authority.key,
  16. *ctx.accounts.update_authority.key,
  17. *ctx.accounts.payer.key,
  18. *ctx.accounts.metadata.key,
  19. *ctx.accounts.mint.key,
  20. );
  21. solana_program::program::invoke_signed(
  22. &ix,
  23. &ToAccountInfos::to_account_infos(&ctx),
  24. ctx.signer_seeds,
  25. )
  26. .map_err(Into::into)
  27. }
  28. pub fn bubblegum_set_collection_size<'info>(
  29. ctx: CpiContext<'_, '_, '_, 'info, BubblegumSetCollectionSize<'info>>,
  30. collection_authority_record: Option<Pubkey>,
  31. size: u64,
  32. ) -> Result<()> {
  33. let ix = mpl_token_metadata::instruction::bubblegum_set_collection_size(
  34. ID,
  35. *ctx.accounts.metadata_account.key,
  36. *ctx.accounts.update_authority.key,
  37. *ctx.accounts.mint.key,
  38. *ctx.accounts.bubblegum_signer.key,
  39. collection_authority_record,
  40. size,
  41. );
  42. solana_program::program::invoke_signed(
  43. &ix,
  44. &ToAccountInfos::to_account_infos(&ctx),
  45. ctx.signer_seeds,
  46. )
  47. .map_err(Into::into)
  48. }
  49. pub fn burn_edition_nft<'info>(
  50. ctx: CpiContext<'_, '_, '_, 'info, BurnEditionNft<'info>>,
  51. ) -> Result<()> {
  52. let ix = mpl_token_metadata::instruction::burn_edition_nft(
  53. ID,
  54. *ctx.accounts.metadata.key,
  55. *ctx.accounts.owner.key,
  56. *ctx.accounts.print_edition_mint.key,
  57. *ctx.accounts.master_edition_mint.key,
  58. *ctx.accounts.print_edition_token.key,
  59. *ctx.accounts.master_edition_token.key,
  60. *ctx.accounts.master_edition.key,
  61. *ctx.accounts.print_edition.key,
  62. *ctx.accounts.edition_marker.key,
  63. *ctx.accounts.spl_token.key,
  64. );
  65. solana_program::program::invoke_signed(
  66. &ix,
  67. &ToAccountInfos::to_account_infos(&ctx),
  68. ctx.signer_seeds,
  69. )
  70. .map_err(Into::into)
  71. }
  72. pub fn burn_nft<'info>(
  73. ctx: CpiContext<'_, '_, '_, 'info, BurnNft<'info>>,
  74. collection_metadata: Option<Pubkey>,
  75. ) -> Result<()> {
  76. let ix = mpl_token_metadata::instruction::burn_nft(
  77. ID,
  78. *ctx.accounts.metadata.key,
  79. *ctx.accounts.owner.key,
  80. *ctx.accounts.mint.key,
  81. *ctx.accounts.token.key,
  82. *ctx.accounts.edition.key,
  83. *ctx.accounts.spl_token.key,
  84. collection_metadata,
  85. );
  86. solana_program::program::invoke_signed(
  87. &ix,
  88. &ToAccountInfos::to_account_infos(&ctx),
  89. ctx.signer_seeds,
  90. )
  91. .map_err(Into::into)
  92. }
  93. pub fn create_metadata_accounts_v3<'info>(
  94. ctx: CpiContext<'_, '_, '_, 'info, CreateMetadataAccountsV3<'info>>,
  95. data: DataV2,
  96. is_mutable: bool,
  97. update_authority_is_signer: bool,
  98. details: Option<CollectionDetails>,
  99. ) -> Result<()> {
  100. let DataV2 {
  101. name,
  102. symbol,
  103. uri,
  104. creators,
  105. seller_fee_basis_points,
  106. collection,
  107. uses,
  108. } = data;
  109. let ix = mpl_token_metadata::instruction::create_metadata_accounts_v3(
  110. ID,
  111. *ctx.accounts.metadata.key,
  112. *ctx.accounts.mint.key,
  113. *ctx.accounts.mint_authority.key,
  114. *ctx.accounts.payer.key,
  115. *ctx.accounts.update_authority.key,
  116. name,
  117. symbol,
  118. uri,
  119. creators,
  120. seller_fee_basis_points,
  121. update_authority_is_signer,
  122. is_mutable,
  123. collection,
  124. uses,
  125. details,
  126. );
  127. solana_program::program::invoke_signed(
  128. &ix,
  129. &ToAccountInfos::to_account_infos(&ctx),
  130. ctx.signer_seeds,
  131. )
  132. .map_err(Into::into)
  133. }
  134. pub fn update_metadata_accounts_v2<'info>(
  135. ctx: CpiContext<'_, '_, '_, 'info, UpdateMetadataAccountsV2<'info>>,
  136. new_update_authority: Option<Pubkey>,
  137. data: Option<DataV2>,
  138. primary_sale_happened: Option<bool>,
  139. is_mutable: Option<bool>,
  140. ) -> Result<()> {
  141. let ix = mpl_token_metadata::instruction::update_metadata_accounts_v2(
  142. ID,
  143. *ctx.accounts.metadata.key,
  144. *ctx.accounts.update_authority.key,
  145. new_update_authority,
  146. data,
  147. primary_sale_happened,
  148. is_mutable,
  149. );
  150. solana_program::program::invoke_signed(
  151. &ix,
  152. &ToAccountInfos::to_account_infos(&ctx),
  153. ctx.signer_seeds,
  154. )
  155. .map_err(Into::into)
  156. }
  157. pub fn create_master_edition_v3<'info>(
  158. ctx: CpiContext<'_, '_, '_, 'info, CreateMasterEditionV3<'info>>,
  159. max_supply: Option<u64>,
  160. ) -> Result<()> {
  161. let ix = mpl_token_metadata::instruction::create_master_edition_v3(
  162. ID,
  163. *ctx.accounts.edition.key,
  164. *ctx.accounts.mint.key,
  165. *ctx.accounts.update_authority.key,
  166. *ctx.accounts.mint_authority.key,
  167. *ctx.accounts.metadata.key,
  168. *ctx.accounts.payer.key,
  169. max_supply,
  170. );
  171. solana_program::program::invoke_signed(
  172. &ix,
  173. &ToAccountInfos::to_account_infos(&ctx),
  174. ctx.signer_seeds,
  175. )
  176. .map_err(Into::into)
  177. }
  178. pub fn mint_new_edition_from_master_edition_via_token<'info>(
  179. ctx: CpiContext<'_, '_, '_, 'info, MintNewEditionFromMasterEditionViaToken<'info>>,
  180. edition: u64,
  181. ) -> Result<()> {
  182. let ix = mpl_token_metadata::instruction::mint_new_edition_from_master_edition_via_token(
  183. ID,
  184. *ctx.accounts.new_metadata.key,
  185. *ctx.accounts.new_edition.key,
  186. *ctx.accounts.master_edition.key,
  187. *ctx.accounts.new_mint.key,
  188. *ctx.accounts.new_mint_authority.key,
  189. *ctx.accounts.payer.key,
  190. *ctx.accounts.token_account_owner.key,
  191. *ctx.accounts.token_account.key,
  192. *ctx.accounts.new_metadata_update_authority.key,
  193. *ctx.accounts.metadata.key,
  194. *ctx.accounts.metadata_mint.key,
  195. edition,
  196. );
  197. solana_program::program::invoke_signed(
  198. &ix,
  199. &ToAccountInfos::to_account_infos(&ctx),
  200. ctx.signer_seeds,
  201. )
  202. .map_err(Into::into)
  203. }
  204. pub fn revoke_collection_authority<'info>(
  205. ctx: CpiContext<'_, '_, '_, 'info, RevokeCollectionAuthority<'info>>,
  206. ) -> Result<()> {
  207. let ix = mpl_token_metadata::instruction::revoke_collection_authority(
  208. ID,
  209. *ctx.accounts.collection_authority_record.key,
  210. *ctx.accounts.delegate_authority.key,
  211. *ctx.accounts.revoke_authority.key,
  212. *ctx.accounts.metadata.key,
  213. *ctx.accounts.mint.key,
  214. );
  215. solana_program::program::invoke_signed(
  216. &ix,
  217. &ToAccountInfos::to_account_infos(&ctx),
  218. ctx.signer_seeds,
  219. )
  220. .map_err(Into::into)
  221. }
  222. pub fn set_collection_size<'info>(
  223. ctx: CpiContext<'_, '_, '_, 'info, SetCollectionSize<'info>>,
  224. collection_authority_record: Option<Pubkey>,
  225. size: u64,
  226. ) -> Result<()> {
  227. let ix = mpl_token_metadata::instruction::set_collection_size(
  228. ID,
  229. *ctx.accounts.metadata.key,
  230. *ctx.accounts.update_authority.key,
  231. *ctx.accounts.mint.key,
  232. collection_authority_record,
  233. size,
  234. );
  235. solana_program::program::invoke_signed(
  236. &ix,
  237. &ToAccountInfos::to_account_infos(&ctx),
  238. ctx.signer_seeds,
  239. )
  240. .map_err(Into::into)
  241. }
  242. pub fn verify_collection<'info>(
  243. ctx: CpiContext<'_, '_, '_, 'info, VerifyCollection<'info>>,
  244. collection_authority_record: Option<Pubkey>,
  245. ) -> Result<()> {
  246. let ix = mpl_token_metadata::instruction::verify_collection(
  247. ID,
  248. *ctx.accounts.metadata.key,
  249. *ctx.accounts.collection_authority.key,
  250. *ctx.accounts.payer.key,
  251. *ctx.accounts.collection_mint.key,
  252. *ctx.accounts.collection_metadata.key,
  253. *ctx.accounts.collection_master_edition.key,
  254. collection_authority_record,
  255. );
  256. solana_program::program::invoke_signed(
  257. &ix,
  258. &ToAccountInfos::to_account_infos(&ctx),
  259. ctx.signer_seeds,
  260. )
  261. .map_err(Into::into)
  262. }
  263. pub fn verify_sized_collection_item<'info>(
  264. ctx: CpiContext<'_, '_, '_, 'info, VerifySizedCollectionItem<'info>>,
  265. collection_authority_record: Option<Pubkey>,
  266. ) -> Result<()> {
  267. let ix = mpl_token_metadata::instruction::verify_sized_collection_item(
  268. ID,
  269. *ctx.accounts.metadata.key,
  270. *ctx.accounts.collection_authority.key,
  271. *ctx.accounts.payer.key,
  272. *ctx.accounts.collection_mint.key,
  273. *ctx.accounts.collection_metadata.key,
  274. *ctx.accounts.collection_master_edition.key,
  275. collection_authority_record,
  276. );
  277. solana_program::program::invoke_signed(
  278. &ix,
  279. &ToAccountInfos::to_account_infos(&ctx),
  280. ctx.signer_seeds,
  281. )
  282. .map_err(Into::into)
  283. }
  284. pub fn set_and_verify_collection<'info>(
  285. ctx: CpiContext<'_, '_, '_, 'info, SetAndVerifyCollection<'info>>,
  286. collection_authority_record: Option<Pubkey>,
  287. ) -> Result<()> {
  288. let ix = mpl_token_metadata::instruction::set_and_verify_collection(
  289. ID,
  290. *ctx.accounts.metadata.key,
  291. *ctx.accounts.collection_authority.key,
  292. *ctx.accounts.payer.key,
  293. *ctx.accounts.update_authority.key,
  294. *ctx.accounts.collection_mint.key,
  295. *ctx.accounts.collection_metadata.key,
  296. *ctx.accounts.collection_master_edition.key,
  297. collection_authority_record,
  298. );
  299. solana_program::program::invoke_signed(
  300. &ix,
  301. &ToAccountInfos::to_account_infos(&ctx),
  302. ctx.signer_seeds,
  303. )
  304. .map_err(Into::into)
  305. }
  306. pub fn set_and_verify_sized_collection_item<'info>(
  307. ctx: CpiContext<'_, '_, '_, 'info, SetAndVerifySizedCollectionItem<'info>>,
  308. collection_authority_record: Option<Pubkey>,
  309. ) -> Result<()> {
  310. let ix = mpl_token_metadata::instruction::set_and_verify_sized_collection_item(
  311. ID,
  312. *ctx.accounts.metadata.key,
  313. *ctx.accounts.collection_authority.key,
  314. *ctx.accounts.payer.key,
  315. *ctx.accounts.update_authority.key,
  316. *ctx.accounts.collection_mint.key,
  317. *ctx.accounts.collection_metadata.key,
  318. *ctx.accounts.collection_master_edition.key,
  319. collection_authority_record,
  320. );
  321. solana_program::program::invoke_signed(
  322. &ix,
  323. &ToAccountInfos::to_account_infos(&ctx),
  324. ctx.signer_seeds,
  325. )
  326. .map_err(Into::into)
  327. }
  328. pub fn freeze_delegated_account<'info>(
  329. ctx: CpiContext<'_, '_, '_, 'info, FreezeDelegatedAccount<'info>>,
  330. ) -> Result<()> {
  331. let ix = mpl_token_metadata::instruction::freeze_delegated_account(
  332. ID,
  333. *ctx.accounts.delegate.key,
  334. *ctx.accounts.token_account.key,
  335. *ctx.accounts.edition.key,
  336. *ctx.accounts.mint.key,
  337. );
  338. solana_program::program::invoke_signed(
  339. &ix,
  340. &ToAccountInfos::to_account_infos(&ctx),
  341. ctx.signer_seeds,
  342. )
  343. .map_err(Into::into)
  344. }
  345. pub fn thaw_delegated_account<'info>(
  346. ctx: CpiContext<'_, '_, '_, 'info, ThawDelegatedAccount<'info>>,
  347. ) -> Result<()> {
  348. let ix = mpl_token_metadata::instruction::thaw_delegated_account(
  349. ID,
  350. *ctx.accounts.delegate.key,
  351. *ctx.accounts.token_account.key,
  352. *ctx.accounts.edition.key,
  353. *ctx.accounts.mint.key,
  354. );
  355. solana_program::program::invoke_signed(
  356. &ix,
  357. &ToAccountInfos::to_account_infos(&ctx),
  358. ctx.signer_seeds,
  359. )
  360. .map_err(Into::into)
  361. }
  362. pub fn update_primary_sale_happened_via_token<'info>(
  363. ctx: CpiContext<'_, '_, '_, 'info, UpdatePrimarySaleHappenedViaToken<'info>>,
  364. ) -> Result<()> {
  365. let ix = mpl_token_metadata::instruction::update_primary_sale_happened_via_token(
  366. ID,
  367. *ctx.accounts.metadata.key,
  368. *ctx.accounts.owner.key,
  369. *ctx.accounts.token.key,
  370. );
  371. solana_program::program::invoke_signed(
  372. &ix,
  373. &ToAccountInfos::to_account_infos(&ctx),
  374. ctx.signer_seeds,
  375. )?;
  376. Ok(())
  377. }
  378. pub fn set_token_standard<'info>(
  379. ctx: CpiContext<'_, '_, '_, 'info, SetTokenStandard<'info>>,
  380. edition_account: Option<Pubkey>,
  381. ) -> Result<()> {
  382. let ix = mpl_token_metadata::instruction::set_token_standard(
  383. ID,
  384. *ctx.accounts.metadata_account.key,
  385. *ctx.accounts.update_authority.key,
  386. *ctx.accounts.mint_account.key,
  387. edition_account,
  388. );
  389. solana_program::program::invoke_signed(
  390. &ix,
  391. &ToAccountInfos::to_account_infos(&ctx),
  392. ctx.signer_seeds,
  393. )
  394. .map_err(Into::into)
  395. }
  396. pub fn sign_metadata<'info>(ctx: CpiContext<'_, '_, '_, 'info, SignMetadata<'info>>) -> Result<()> {
  397. let ix = mpl_token_metadata::instruction::sign_metadata(
  398. ID,
  399. *ctx.accounts.metadata.key,
  400. *ctx.accounts.creator.key,
  401. );
  402. solana_program::program::invoke_signed(
  403. &ix,
  404. &ToAccountInfos::to_account_infos(&ctx),
  405. ctx.signer_seeds,
  406. )?;
  407. Ok(())
  408. }
  409. pub fn remove_creator_verification<'info>(
  410. ctx: CpiContext<'_, '_, '_, 'info, RemoveCreatorVerification<'info>>,
  411. ) -> Result<()> {
  412. let ix = mpl_token_metadata::instruction::remove_creator_verification(
  413. ID,
  414. *ctx.accounts.metadata.key,
  415. *ctx.accounts.creator.key,
  416. );
  417. solana_program::program::invoke_signed(
  418. &ix,
  419. &ToAccountInfos::to_account_infos(&ctx),
  420. ctx.signer_seeds,
  421. )?;
  422. Ok(())
  423. }
  424. pub fn utilize<'info>(
  425. ctx: CpiContext<'_, '_, '_, 'info, Utilize<'info>>,
  426. use_authority_record_pda: Option<Pubkey>,
  427. burner: Option<Pubkey>,
  428. number_of_uses: u64,
  429. ) -> Result<()> {
  430. let ix = mpl_token_metadata::instruction::utilize(
  431. ID,
  432. *ctx.accounts.metadata.key,
  433. *ctx.accounts.token_account.key,
  434. *ctx.accounts.mint.key,
  435. use_authority_record_pda,
  436. *ctx.accounts.use_authority.key,
  437. *ctx.accounts.owner.key,
  438. burner,
  439. number_of_uses,
  440. );
  441. solana_program::program::invoke_signed(
  442. &ix,
  443. &ToAccountInfos::to_account_infos(&ctx),
  444. ctx.signer_seeds,
  445. )
  446. .map_err(Into::into)
  447. }
  448. pub fn unverify_collection<'info>(
  449. ctx: CpiContext<'_, '_, '_, 'info, UnverifyCollection<'info>>,
  450. collection_authority_record: Option<Pubkey>,
  451. ) -> Result<()> {
  452. let ix = mpl_token_metadata::instruction::unverify_collection(
  453. ID,
  454. *ctx.accounts.metadata.key,
  455. *ctx.accounts.collection_authority.key,
  456. *ctx.accounts.collection_mint.key,
  457. *ctx.accounts.collection.key,
  458. *ctx.accounts.collection_master_edition_account.key,
  459. collection_authority_record,
  460. );
  461. solana_program::program::invoke_signed(
  462. &ix,
  463. &ToAccountInfos::to_account_infos(&ctx),
  464. ctx.signer_seeds,
  465. )
  466. .map_err(Into::into)
  467. }
  468. pub fn unverify_sized_collection_item<'info>(
  469. ctx: CpiContext<'_, '_, '_, 'info, UnverifySizedCollectionItem<'info>>,
  470. collection_authority_record: Option<Pubkey>,
  471. ) -> Result<()> {
  472. let ix = mpl_token_metadata::instruction::unverify_sized_collection_item(
  473. ID,
  474. *ctx.accounts.metadata.key,
  475. *ctx.accounts.collection_authority.key,
  476. *ctx.accounts.payer.key,
  477. *ctx.accounts.collection_mint.key,
  478. *ctx.accounts.collection.key,
  479. *ctx.accounts.collection_master_edition_account.key,
  480. collection_authority_record,
  481. );
  482. solana_program::program::invoke_signed(
  483. &ix,
  484. &ToAccountInfos::to_account_infos(&ctx),
  485. ctx.signer_seeds,
  486. )
  487. .map_err(Into::into)
  488. }
  489. #[derive(Accounts)]
  490. pub struct ApproveCollectionAuthority<'info> {
  491. pub collection_authority_record: AccountInfo<'info>,
  492. pub new_collection_authority: AccountInfo<'info>,
  493. pub update_authority: AccountInfo<'info>,
  494. pub payer: AccountInfo<'info>,
  495. pub metadata: AccountInfo<'info>,
  496. pub mint: AccountInfo<'info>,
  497. }
  498. #[derive(Accounts)]
  499. pub struct BubblegumSetCollectionSize<'info> {
  500. pub metadata_account: AccountInfo<'info>,
  501. pub update_authority: AccountInfo<'info>,
  502. pub mint: AccountInfo<'info>,
  503. pub bubblegum_signer: AccountInfo<'info>,
  504. }
  505. #[derive(Accounts)]
  506. pub struct BurnEditionNft<'info> {
  507. pub metadata: AccountInfo<'info>,
  508. pub owner: AccountInfo<'info>,
  509. pub print_edition_mint: AccountInfo<'info>,
  510. pub master_edition_mint: AccountInfo<'info>,
  511. pub print_edition_token: AccountInfo<'info>,
  512. pub master_edition_token: AccountInfo<'info>,
  513. pub master_edition: AccountInfo<'info>,
  514. pub print_edition: AccountInfo<'info>,
  515. pub edition_marker: AccountInfo<'info>,
  516. pub spl_token: AccountInfo<'info>,
  517. }
  518. #[derive(Accounts)]
  519. pub struct BurnNft<'info> {
  520. pub metadata: AccountInfo<'info>,
  521. pub owner: AccountInfo<'info>,
  522. pub mint: AccountInfo<'info>,
  523. pub token: AccountInfo<'info>,
  524. pub edition: AccountInfo<'info>,
  525. pub spl_token: AccountInfo<'info>,
  526. }
  527. #[derive(Accounts)]
  528. pub struct CreateMetadataAccountsV3<'info> {
  529. pub metadata: AccountInfo<'info>,
  530. pub mint: AccountInfo<'info>,
  531. pub mint_authority: AccountInfo<'info>,
  532. pub payer: AccountInfo<'info>,
  533. pub update_authority: AccountInfo<'info>,
  534. pub system_program: AccountInfo<'info>,
  535. pub rent: AccountInfo<'info>,
  536. }
  537. #[derive(Accounts)]
  538. pub struct UpdateMetadataAccountsV2<'info> {
  539. pub metadata: AccountInfo<'info>,
  540. pub update_authority: AccountInfo<'info>,
  541. }
  542. #[derive(Accounts)]
  543. pub struct CreateMasterEditionV3<'info> {
  544. pub edition: AccountInfo<'info>,
  545. pub mint: AccountInfo<'info>,
  546. pub update_authority: AccountInfo<'info>,
  547. pub mint_authority: AccountInfo<'info>,
  548. pub payer: AccountInfo<'info>,
  549. pub metadata: AccountInfo<'info>,
  550. pub token_program: AccountInfo<'info>,
  551. pub system_program: AccountInfo<'info>,
  552. pub rent: AccountInfo<'info>,
  553. }
  554. #[derive(Accounts)]
  555. pub struct MintNewEditionFromMasterEditionViaToken<'info> {
  556. pub new_metadata: AccountInfo<'info>,
  557. pub new_edition: AccountInfo<'info>,
  558. pub master_edition: AccountInfo<'info>,
  559. pub new_mint: AccountInfo<'info>,
  560. pub edition_mark_pda: AccountInfo<'info>,
  561. pub new_mint_authority: AccountInfo<'info>,
  562. pub payer: AccountInfo<'info>,
  563. pub token_account_owner: AccountInfo<'info>,
  564. pub token_account: AccountInfo<'info>,
  565. pub new_metadata_update_authority: AccountInfo<'info>,
  566. pub metadata: AccountInfo<'info>,
  567. pub token_program: AccountInfo<'info>,
  568. pub system_program: AccountInfo<'info>,
  569. pub rent: AccountInfo<'info>,
  570. //
  571. // Not actually used by the program but still needed because it's needed
  572. // for the pda calculation in the helper. :/
  573. //
  574. // The better thing to do would be to remove this and have the instruction
  575. // helper pass in the `edition_mark_pda` directly.
  576. //
  577. pub metadata_mint: AccountInfo<'info>,
  578. }
  579. #[derive(Accounts)]
  580. pub struct RevokeCollectionAuthority<'info> {
  581. pub collection_authority_record: AccountInfo<'info>,
  582. pub delegate_authority: AccountInfo<'info>,
  583. pub revoke_authority: AccountInfo<'info>,
  584. pub metadata: AccountInfo<'info>,
  585. pub mint: AccountInfo<'info>,
  586. }
  587. #[derive(Accounts)]
  588. pub struct SetCollectionSize<'info> {
  589. pub metadata: AccountInfo<'info>,
  590. pub mint: AccountInfo<'info>,
  591. pub update_authority: AccountInfo<'info>,
  592. pub system_program: AccountInfo<'info>,
  593. }
  594. #[derive(Accounts)]
  595. pub struct SetTokenStandard<'info> {
  596. pub metadata_account: AccountInfo<'info>,
  597. pub update_authority: AccountInfo<'info>,
  598. pub mint_account: AccountInfo<'info>,
  599. }
  600. #[derive(Accounts)]
  601. pub struct VerifyCollection<'info> {
  602. pub payer: AccountInfo<'info>,
  603. pub metadata: AccountInfo<'info>,
  604. pub collection_authority: AccountInfo<'info>,
  605. pub collection_mint: AccountInfo<'info>,
  606. pub collection_metadata: AccountInfo<'info>,
  607. pub collection_master_edition: AccountInfo<'info>,
  608. }
  609. #[derive(Accounts)]
  610. pub struct VerifySizedCollectionItem<'info> {
  611. pub payer: AccountInfo<'info>,
  612. pub metadata: AccountInfo<'info>,
  613. pub collection_authority: AccountInfo<'info>,
  614. pub collection_mint: AccountInfo<'info>,
  615. pub collection_metadata: AccountInfo<'info>,
  616. pub collection_master_edition: AccountInfo<'info>,
  617. }
  618. #[derive(Accounts)]
  619. pub struct SetAndVerifyCollection<'info> {
  620. pub metadata: AccountInfo<'info>,
  621. pub collection_authority: AccountInfo<'info>,
  622. pub payer: AccountInfo<'info>,
  623. pub update_authority: AccountInfo<'info>,
  624. pub collection_mint: AccountInfo<'info>,
  625. pub collection_metadata: AccountInfo<'info>,
  626. pub collection_master_edition: AccountInfo<'info>,
  627. }
  628. #[derive(Accounts)]
  629. pub struct SetAndVerifySizedCollectionItem<'info> {
  630. pub metadata: AccountInfo<'info>,
  631. pub collection_authority: AccountInfo<'info>,
  632. pub payer: AccountInfo<'info>,
  633. pub update_authority: AccountInfo<'info>,
  634. pub collection_mint: AccountInfo<'info>,
  635. pub collection_metadata: AccountInfo<'info>,
  636. pub collection_master_edition: AccountInfo<'info>,
  637. }
  638. #[derive(Accounts)]
  639. pub struct FreezeDelegatedAccount<'info> {
  640. pub metadata: AccountInfo<'info>,
  641. pub delegate: AccountInfo<'info>,
  642. pub token_account: AccountInfo<'info>,
  643. pub edition: AccountInfo<'info>,
  644. pub mint: AccountInfo<'info>,
  645. pub token_program: AccountInfo<'info>,
  646. }
  647. #[derive(Accounts)]
  648. pub struct ThawDelegatedAccount<'info> {
  649. pub metadata: AccountInfo<'info>,
  650. pub delegate: AccountInfo<'info>,
  651. pub token_account: AccountInfo<'info>,
  652. pub edition: AccountInfo<'info>,
  653. pub mint: AccountInfo<'info>,
  654. pub token_program: AccountInfo<'info>,
  655. }
  656. #[derive(Accounts)]
  657. pub struct UpdatePrimarySaleHappenedViaToken<'info> {
  658. pub metadata: AccountInfo<'info>,
  659. pub owner: AccountInfo<'info>,
  660. pub token: AccountInfo<'info>,
  661. }
  662. #[derive(Accounts)]
  663. pub struct SignMetadata<'info> {
  664. pub creator: AccountInfo<'info>,
  665. pub metadata: AccountInfo<'info>,
  666. }
  667. #[derive(Accounts)]
  668. pub struct RemoveCreatorVerification<'info> {
  669. pub creator: AccountInfo<'info>,
  670. pub metadata: AccountInfo<'info>,
  671. }
  672. #[derive(Accounts)]
  673. pub struct Utilize<'info> {
  674. pub metadata: AccountInfo<'info>,
  675. pub token_account: AccountInfo<'info>,
  676. pub mint: AccountInfo<'info>,
  677. pub use_authority: AccountInfo<'info>,
  678. pub owner: AccountInfo<'info>,
  679. }
  680. #[derive(Accounts)]
  681. pub struct UnverifyCollection<'info> {
  682. pub metadata: AccountInfo<'info>,
  683. pub collection_authority: AccountInfo<'info>,
  684. pub collection_mint: AccountInfo<'info>,
  685. pub collection: AccountInfo<'info>,
  686. pub collection_master_edition_account: AccountInfo<'info>,
  687. }
  688. #[derive(Accounts)]
  689. pub struct UnverifySizedCollectionItem<'info> {
  690. pub metadata: AccountInfo<'info>,
  691. pub collection_authority: AccountInfo<'info>,
  692. pub payer: AccountInfo<'info>,
  693. pub collection_mint: AccountInfo<'info>,
  694. pub collection: AccountInfo<'info>,
  695. pub collection_master_edition_account: AccountInfo<'info>,
  696. }
  697. #[derive(Clone, Debug, PartialEq)]
  698. pub struct MetadataAccount(mpl_token_metadata::state::Metadata);
  699. impl MetadataAccount {
  700. pub const LEN: usize = mpl_token_metadata::state::MAX_METADATA_LEN;
  701. }
  702. impl anchor_lang::AccountDeserialize for MetadataAccount {
  703. fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
  704. let md = Self::try_deserialize_unchecked(buf)?;
  705. if md.key != mpl_token_metadata::state::Metadata::key() {
  706. return Err(ErrorCode::AccountNotInitialized.into());
  707. }
  708. Ok(md)
  709. }
  710. fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
  711. let md = mpl_token_metadata::state::Metadata::safe_deserialize(buf)?;
  712. Ok(Self(md))
  713. }
  714. }
  715. impl anchor_lang::AccountSerialize for MetadataAccount {}
  716. impl anchor_lang::Owner for MetadataAccount {
  717. fn owner() -> Pubkey {
  718. ID
  719. }
  720. }
  721. impl Deref for MetadataAccount {
  722. type Target = mpl_token_metadata::state::Metadata;
  723. fn deref(&self) -> &Self::Target {
  724. &self.0
  725. }
  726. }
  727. #[derive(Clone, Debug, PartialEq)]
  728. pub struct MasterEditionAccount(mpl_token_metadata::state::MasterEditionV2);
  729. impl MasterEditionAccount {
  730. pub const LEN: usize = mpl_token_metadata::state::MAX_MASTER_EDITION_LEN;
  731. }
  732. impl anchor_lang::AccountDeserialize for MasterEditionAccount {
  733. fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
  734. let me = Self::try_deserialize_unchecked(buf)?;
  735. if me.key != mpl_token_metadata::state::MasterEditionV2::key() {
  736. return Err(ErrorCode::AccountNotInitialized.into());
  737. }
  738. Ok(me)
  739. }
  740. fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
  741. let result = mpl_token_metadata::state::MasterEditionV2::safe_deserialize(buf)?;
  742. Ok(Self(result))
  743. }
  744. }
  745. impl Deref for MasterEditionAccount {
  746. type Target = mpl_token_metadata::state::MasterEditionV2;
  747. fn deref(&self) -> &Self::Target {
  748. &self.0
  749. }
  750. }
  751. impl anchor_lang::AccountSerialize for MasterEditionAccount {}
  752. impl anchor_lang::Owner for MasterEditionAccount {
  753. fn owner() -> Pubkey {
  754. ID
  755. }
  756. }
  757. #[derive(Clone)]
  758. pub struct Metadata;
  759. impl anchor_lang::Id for Metadata {
  760. fn id() -> Pubkey {
  761. ID
  762. }
  763. }