metadata.rs 26 KB

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