From 609bf2d557dcdcaf06288345415f82a299eab002 Mon Sep 17 00:00:00 2001 From: Fernando Otero Date: Fri, 29 Dec 2023 14:21:54 +0200 Subject: [PATCH] Add pda prefix values (#74) --- clients/js/package.json | 2 +- clients/js/pnpm-lock.yaml | 2 +- .../accounts/collection_authority_record.rs | 12 ++ .../src/generated/accounts/edition_marker.rs | 11 ++ .../generated/accounts/edition_marker_v2.rs | 15 ++ .../src/generated/accounts/master_edition.rs | 11 ++ .../rust/src/generated/accounts/metadata.rs | 9 + .../accounts/metadata_delegate_record.rs | 11 ++ clients/rust/src/generated/accounts/mod.rs | 40 ++-- .../src/generated/accounts/token_record.rs | 11 ++ .../accounts/use_authority_record.rs | 10 + clients/rust/src/generated/types/mod.rs | 172 +++++++++--------- idls/token_metadata.json | 2 +- package.json | 2 +- pnpm-lock.yaml | 8 +- 15 files changed, 204 insertions(+), 114 deletions(-) diff --git a/clients/js/package.json b/clients/js/package.json index 750f64c7..d763c374 100644 --- a/clients/js/package.json +++ b/clients/js/package.json @@ -48,7 +48,7 @@ "typedoc": "^0.23.16", "typedoc-plugin-expand-object-like-types": "^0.1.1", "typedoc-plugin-missing-exports": "^1.0.0", - "typescript": "^4.6.2", + "typescript": "^4.9.4", "vercel": "^28.16.8" }, "ava": { diff --git a/clients/js/pnpm-lock.yaml b/clients/js/pnpm-lock.yaml index b000257a..ab033b14 100644 --- a/clients/js/pnpm-lock.yaml +++ b/clients/js/pnpm-lock.yaml @@ -58,7 +58,7 @@ devDependencies: specifier: ^1.0.0 version: 1.0.0(typedoc@0.23.25) typescript: - specifier: ^4.6.2 + specifier: ^4.9.4 version: 4.9.5 vercel: specifier: ^28.16.8 diff --git a/clients/rust/src/generated/accounts/collection_authority_record.rs b/clients/rust/src/generated/accounts/collection_authority_record.rs index 13f7a97d..37f55038 100644 --- a/clients/rust/src/generated/accounts/collection_authority_record.rs +++ b/clients/rust/src/generated/accounts/collection_authority_record.rs @@ -19,6 +19,18 @@ pub struct CollectionAuthorityRecord { } impl CollectionAuthorityRecord { + /// Prefix values used to generate a PDA for this account. + /// + /// Values are positional and appear in the following order: + /// + /// 0. `CollectionAuthorityRecord::PREFIX.0` + /// 1. `crate::MPL_TOKEN_METADATA_ID` + /// 2. mint (`Pubkey`) + /// 3. `CollectionAuthorityRecord::PREFIX.1` + /// 4. collection_authority (`Pubkey`) + pub const PREFIX: (&'static [u8], &'static [u8]) = + ("metadata".as_bytes(), "collection_authority".as_bytes()); + pub fn create_pda( mint: Pubkey, collection_authority: Pubkey, diff --git a/clients/rust/src/generated/accounts/edition_marker.rs b/clients/rust/src/generated/accounts/edition_marker.rs index bfcdde76..55cf3e69 100644 --- a/clients/rust/src/generated/accounts/edition_marker.rs +++ b/clients/rust/src/generated/accounts/edition_marker.rs @@ -19,6 +19,17 @@ pub struct EditionMarker { impl EditionMarker { pub const LEN: usize = 32; + /// Prefix values used to generate a PDA for this account. + /// + /// Values are positional and appear in the following order: + /// + /// 0. `EditionMarker::PREFIX.0` + /// 1. `crate::MPL_TOKEN_METADATA_ID` + /// 2. mint (`Pubkey`) + /// 3. `EditionMarker::PREFIX.1` + /// 4. edition_marker (`&str`) + pub const PREFIX: (&'static [u8], &'static [u8]) = + ("metadata".as_bytes(), "edition".as_bytes()); pub fn create_pda( mint: Pubkey, diff --git a/clients/rust/src/generated/accounts/edition_marker_v2.rs b/clients/rust/src/generated/accounts/edition_marker_v2.rs index f65060ba..2c01a670 100644 --- a/clients/rust/src/generated/accounts/edition_marker_v2.rs +++ b/clients/rust/src/generated/accounts/edition_marker_v2.rs @@ -18,6 +18,21 @@ pub struct EditionMarkerV2 { } impl EditionMarkerV2 { + /// Prefix values used to generate a PDA for this account. + /// + /// Values are positional and appear in the following order: + /// + /// 0. `EditionMarkerV2::PREFIX.0` + /// 1. `crate::MPL_TOKEN_METADATA_ID` + /// 2. mint (`Pubkey`) + /// 3. `EditionMarkerV2::PREFIX.1` + /// 4. `EditionMarkerV2::PREFIX.2` + pub const PREFIX: (&'static [u8], &'static [u8], &'static [u8]) = ( + "metadata".as_bytes(), + "edition".as_bytes(), + "marker".as_bytes(), + ); + pub fn create_pda( mint: Pubkey, bump: u8, diff --git a/clients/rust/src/generated/accounts/master_edition.rs b/clients/rust/src/generated/accounts/master_edition.rs index 4416edc7..654dcae5 100644 --- a/clients/rust/src/generated/accounts/master_edition.rs +++ b/clients/rust/src/generated/accounts/master_edition.rs @@ -19,6 +19,17 @@ pub struct MasterEdition { } impl MasterEdition { + /// Prefix values used to generate a PDA for this account. + /// + /// Values are positional and appear in the following order: + /// + /// 0. `MasterEdition::PREFIX.0` + /// 1. `crate::MPL_TOKEN_METADATA_ID` + /// 2. mint (`Pubkey`) + /// 3. `MasterEdition::PREFIX.1` + pub const PREFIX: (&'static [u8], &'static [u8]) = + ("metadata".as_bytes(), "edition".as_bytes()); + pub fn create_pda( mint: Pubkey, bump: u8, diff --git a/clients/rust/src/generated/accounts/metadata.rs b/clients/rust/src/generated/accounts/metadata.rs index 1cf3a826..728505ad 100644 --- a/clients/rust/src/generated/accounts/metadata.rs +++ b/clients/rust/src/generated/accounts/metadata.rs @@ -46,6 +46,15 @@ pub struct Metadata { } impl Metadata { + /// Prefix values used to generate a PDA for this account. + /// + /// Values are positional and appear in the following order: + /// + /// 0. `Metadata::PREFIX` + /// 1. `crate::MPL_TOKEN_METADATA_ID` + /// 2. mint (`Pubkey`) + pub const PREFIX: &'static [u8] = "metadata".as_bytes(); + pub fn create_pda( mint: Pubkey, bump: u8, diff --git a/clients/rust/src/generated/accounts/metadata_delegate_record.rs b/clients/rust/src/generated/accounts/metadata_delegate_record.rs index ed8a89ba..4adf49cf 100644 --- a/clients/rust/src/generated/accounts/metadata_delegate_record.rs +++ b/clients/rust/src/generated/accounts/metadata_delegate_record.rs @@ -35,6 +35,17 @@ pub struct MetadataDelegateRecord { impl MetadataDelegateRecord { pub const LEN: usize = 98; + /// Prefix values used to generate a PDA for this account. + /// + /// Values are positional and appear in the following order: + /// + /// 0. `MetadataDelegateRecord::PREFIX` + /// 1. `crate::MPL_TOKEN_METADATA_ID` + /// 2. mint (`Pubkey`) + /// 3. delegate_role (`MetadataDelegateRoleSeed`) + /// 4. update_authority (`Pubkey`) + /// 5. delegate (`Pubkey`) + pub const PREFIX: &'static [u8] = "metadata".as_bytes(); pub fn create_pda( mint: Pubkey, diff --git a/clients/rust/src/generated/accounts/mod.rs b/clients/rust/src/generated/accounts/mod.rs index 94bed0c0..b3750e14 100644 --- a/clients/rust/src/generated/accounts/mod.rs +++ b/clients/rust/src/generated/accounts/mod.rs @@ -5,24 +5,24 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -pub(crate) mod collection_authority_record; -pub(crate) mod edition; -pub(crate) mod edition_marker; -pub(crate) mod edition_marker_v2; -pub(crate) mod master_edition; -pub(crate) mod metadata; -pub(crate) mod metadata_delegate_record; -pub(crate) mod token_owned_escrow; -pub(crate) mod token_record; -pub(crate) mod use_authority_record; +pub(crate) mod r#collection_authority_record; +pub(crate) mod r#edition; +pub(crate) mod r#edition_marker; +pub(crate) mod r#edition_marker_v2; +pub(crate) mod r#master_edition; +pub(crate) mod r#metadata; +pub(crate) mod r#metadata_delegate_record; +pub(crate) mod r#token_owned_escrow; +pub(crate) mod r#token_record; +pub(crate) mod r#use_authority_record; -pub use self::collection_authority_record::*; -pub use self::edition::*; -pub use self::edition_marker::*; -pub use self::edition_marker_v2::*; -pub use self::master_edition::*; -pub use self::metadata::*; -pub use self::metadata_delegate_record::*; -pub use self::token_owned_escrow::*; -pub use self::token_record::*; -pub use self::use_authority_record::*; +pub use self::r#collection_authority_record::*; +pub use self::r#edition::*; +pub use self::r#edition_marker::*; +pub use self::r#edition_marker_v2::*; +pub use self::r#master_edition::*; +pub use self::r#metadata::*; +pub use self::r#metadata_delegate_record::*; +pub use self::r#token_owned_escrow::*; +pub use self::r#token_record::*; +pub use self::r#use_authority_record::*; diff --git a/clients/rust/src/generated/accounts/token_record.rs b/clients/rust/src/generated/accounts/token_record.rs index 2cc34fb2..b94caf15 100644 --- a/clients/rust/src/generated/accounts/token_record.rs +++ b/clients/rust/src/generated/accounts/token_record.rs @@ -26,6 +26,17 @@ pub struct TokenRecord { impl TokenRecord { pub const LEN: usize = 80; + /// Prefix values used to generate a PDA for this account. + /// + /// Values are positional and appear in the following order: + /// + /// 0. `TokenRecord::PREFIX.0` + /// 1. `crate::MPL_TOKEN_METADATA_ID` + /// 2. mint (`Pubkey`) + /// 3. `TokenRecord::PREFIX.1` + /// 4. token (`Pubkey`) + pub const PREFIX: (&'static [u8], &'static [u8]) = + ("metadata".as_bytes(), "token_record".as_bytes()); pub fn create_pda( mint: Pubkey, diff --git a/clients/rust/src/generated/accounts/use_authority_record.rs b/clients/rust/src/generated/accounts/use_authority_record.rs index 4f642ceb..d7325cdb 100644 --- a/clients/rust/src/generated/accounts/use_authority_record.rs +++ b/clients/rust/src/generated/accounts/use_authority_record.rs @@ -20,6 +20,16 @@ pub struct UseAuthorityRecord { impl UseAuthorityRecord { pub const LEN: usize = 10; + /// Prefix values used to generate a PDA for this account. + /// + /// Values are positional and appear in the following order: + /// + /// 0. `UseAuthorityRecord::PREFIX.0` + /// 1. `crate::MPL_TOKEN_METADATA_ID` + /// 2. mint (`Pubkey`) + /// 3. `UseAuthorityRecord::PREFIX.1` + /// 4. use_authority (`Pubkey`) + pub const PREFIX: (&'static [u8], &'static [u8]) = ("metadata".as_bytes(), "user".as_bytes()); pub fn create_pda( mint: Pubkey, diff --git a/clients/rust/src/generated/types/mod.rs b/clients/rust/src/generated/types/mod.rs index 0f03f091..e249f4dc 100644 --- a/clients/rust/src/generated/types/mod.rs +++ b/clients/rust/src/generated/types/mod.rs @@ -5,90 +5,90 @@ //! [https://github.com/metaplex-foundation/kinobi] //! -pub(crate) mod authority_type; -pub(crate) mod authorization_data; -pub(crate) mod burn_args; -pub(crate) mod collection; -pub(crate) mod collection_details; -pub(crate) mod collection_details_toggle; -pub(crate) mod collection_toggle; -pub(crate) mod create_args; -pub(crate) mod creator; -pub(crate) mod data; -pub(crate) mod data_v2; -pub(crate) mod delegate_args; -pub(crate) mod escrow_authority; -pub(crate) mod key; -pub(crate) mod leaf_info; -pub(crate) mod lock_args; -pub(crate) mod metadata_delegate_role; -pub(crate) mod migration_type; -pub(crate) mod mint_args; -pub(crate) mod mint_new_edition_from_master_edition_via_token_args; -pub(crate) mod payload; -pub(crate) mod payload_key; -pub(crate) mod payload_type; -pub(crate) mod print_args; -pub(crate) mod print_supply; -pub(crate) mod programmable_config; -pub(crate) mod reservation; -pub(crate) mod reservation_v1; -pub(crate) mod revoke_args; -pub(crate) mod rule_set_toggle; -pub(crate) mod seeds_vec; -pub(crate) mod set_collection_size_args; -pub(crate) mod token_delegate_role; -pub(crate) mod token_standard; -pub(crate) mod token_state; -pub(crate) mod transfer_args; -pub(crate) mod unlock_args; -pub(crate) mod update_args; -pub(crate) mod use_args; -pub(crate) mod use_method; -pub(crate) mod uses; -pub(crate) mod uses_toggle; -pub(crate) mod verification_args; +pub(crate) mod r#authority_type; +pub(crate) mod r#authorization_data; +pub(crate) mod r#burn_args; +pub(crate) mod r#collection; +pub(crate) mod r#collection_details; +pub(crate) mod r#collection_details_toggle; +pub(crate) mod r#collection_toggle; +pub(crate) mod r#create_args; +pub(crate) mod r#creator; +pub(crate) mod r#data; +pub(crate) mod r#data_v2; +pub(crate) mod r#delegate_args; +pub(crate) mod r#escrow_authority; +pub(crate) mod r#key; +pub(crate) mod r#leaf_info; +pub(crate) mod r#lock_args; +pub(crate) mod r#metadata_delegate_role; +pub(crate) mod r#migration_type; +pub(crate) mod r#mint_args; +pub(crate) mod r#mint_new_edition_from_master_edition_via_token_args; +pub(crate) mod r#payload; +pub(crate) mod r#payload_key; +pub(crate) mod r#payload_type; +pub(crate) mod r#print_args; +pub(crate) mod r#print_supply; +pub(crate) mod r#programmable_config; +pub(crate) mod r#reservation; +pub(crate) mod r#reservation_v1; +pub(crate) mod r#revoke_args; +pub(crate) mod r#rule_set_toggle; +pub(crate) mod r#seeds_vec; +pub(crate) mod r#set_collection_size_args; +pub(crate) mod r#token_delegate_role; +pub(crate) mod r#token_standard; +pub(crate) mod r#token_state; +pub(crate) mod r#transfer_args; +pub(crate) mod r#unlock_args; +pub(crate) mod r#update_args; +pub(crate) mod r#use_args; +pub(crate) mod r#use_method; +pub(crate) mod r#uses; +pub(crate) mod r#uses_toggle; +pub(crate) mod r#verification_args; -pub use self::authority_type::*; -pub use self::authorization_data::*; -pub use self::burn_args::*; -pub use self::collection::*; -pub use self::collection_details::*; -pub use self::collection_details_toggle::*; -pub use self::collection_toggle::*; -pub use self::create_args::*; -pub use self::creator::*; -pub use self::data::*; -pub use self::data_v2::*; -pub use self::delegate_args::*; -pub use self::escrow_authority::*; -pub use self::key::*; -pub use self::leaf_info::*; -pub use self::lock_args::*; -pub use self::metadata_delegate_role::*; -pub use self::migration_type::*; -pub use self::mint_args::*; -pub use self::mint_new_edition_from_master_edition_via_token_args::*; -pub use self::payload::*; -pub use self::payload_key::*; -pub use self::payload_type::*; -pub use self::print_args::*; -pub use self::print_supply::*; -pub use self::programmable_config::*; -pub use self::reservation::*; -pub use self::reservation_v1::*; -pub use self::revoke_args::*; -pub use self::rule_set_toggle::*; -pub use self::seeds_vec::*; -pub use self::set_collection_size_args::*; -pub use self::token_delegate_role::*; -pub use self::token_standard::*; -pub use self::token_state::*; -pub use self::transfer_args::*; -pub use self::unlock_args::*; -pub use self::update_args::*; -pub use self::use_args::*; -pub use self::use_method::*; -pub use self::uses::*; -pub use self::uses_toggle::*; -pub use self::verification_args::*; +pub use self::r#authority_type::*; +pub use self::r#authorization_data::*; +pub use self::r#burn_args::*; +pub use self::r#collection::*; +pub use self::r#collection_details::*; +pub use self::r#collection_details_toggle::*; +pub use self::r#collection_toggle::*; +pub use self::r#create_args::*; +pub use self::r#creator::*; +pub use self::r#data::*; +pub use self::r#data_v2::*; +pub use self::r#delegate_args::*; +pub use self::r#escrow_authority::*; +pub use self::r#key::*; +pub use self::r#leaf_info::*; +pub use self::r#lock_args::*; +pub use self::r#metadata_delegate_role::*; +pub use self::r#migration_type::*; +pub use self::r#mint_args::*; +pub use self::r#mint_new_edition_from_master_edition_via_token_args::*; +pub use self::r#payload::*; +pub use self::r#payload_key::*; +pub use self::r#payload_type::*; +pub use self::r#print_args::*; +pub use self::r#print_supply::*; +pub use self::r#programmable_config::*; +pub use self::r#reservation::*; +pub use self::r#reservation_v1::*; +pub use self::r#revoke_args::*; +pub use self::r#rule_set_toggle::*; +pub use self::r#seeds_vec::*; +pub use self::r#set_collection_size_args::*; +pub use self::r#token_delegate_role::*; +pub use self::r#token_standard::*; +pub use self::r#token_state::*; +pub use self::r#transfer_args::*; +pub use self::r#unlock_args::*; +pub use self::r#update_args::*; +pub use self::r#use_args::*; +pub use self::r#use_method::*; +pub use self::r#uses::*; +pub use self::r#uses_toggle::*; +pub use self::r#verification_args::*; diff --git a/idls/token_metadata.json b/idls/token_metadata.json index 430159b2..9dd17a3b 100644 --- a/idls/token_metadata.json +++ b/idls/token_metadata.json @@ -7761,4 +7761,4 @@ "binaryVersion": "0.3.0", "libVersion": "0.3.0" } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 9fe554f3..0745c7ee 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "devDependencies": { "@metaplex-foundation/amman": "^0.12.1", - "@metaplex-foundation/kinobi": "^0.16.9", + "@metaplex-foundation/kinobi": "^0.16.15", "@metaplex-foundation/shank-js": "^0.1.0", "typescript": "^4.9.4" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ba9b9a8f..17babb03 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -5,8 +5,8 @@ devDependencies: specifier: ^0.12.1 version: 0.12.1(typescript@4.9.5) '@metaplex-foundation/kinobi': - specifier: ^0.16.9 - version: 0.16.9 + specifier: ^0.16.15 + version: 0.16.15 '@metaplex-foundation/shank-js': specifier: ^0.1.0 version: 0.1.0 @@ -85,8 +85,8 @@ packages: resolution: {integrity: sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA==} dev: true - /@metaplex-foundation/kinobi@0.16.9: - resolution: {integrity: sha512-3wXA9ni9CbMd/5T9xkx7PiSftOpLOpv4O8dU2DSji/a5PD+ls81U8G8CKKfAaF/cWqkQwqyZuYyDvSJnQNgHMw==} + /@metaplex-foundation/kinobi@0.16.15: + resolution: {integrity: sha512-D4uNSoue6+SCBVy4byqMt8O6yFitPTBP0AJC+37cMrtZjo22tGUAGfKklgcuTY3MoBbSh/xhndXXrckU32uExA==} dependencies: '@noble/hashes': 1.2.0 chalk: 4.1.2