diff --git a/Cargo.lock b/Cargo.lock index ae1d7741..fdaba6cf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1554,15 +1554,6 @@ version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" -[[package]] -name = "hashed-macro" -version = "0.1.0" -dependencies = [ - "proc-macro2 1.0.76", - "quote 1.0.35", - "syn 1.0.109", -] - [[package]] name = "heck" version = "0.4.1" diff --git a/clients/js/src/generated/errors/mplAsset.ts b/clients/js/src/generated/errors/mplAsset.ts index 1660f465..6be1708f 100644 --- a/clients/js/src/generated/errors/mplAsset.ts +++ b/clients/js/src/generated/errors/mplAsset.ts @@ -200,6 +200,19 @@ export class CannotMigratePrintsError extends ProgramError { codeToErrorMap.set(0xd, CannotMigratePrintsError); nameToErrorMap.set('CannotMigratePrints', CannotMigratePrintsError); +/** CannotBurnCollection: Cannot burn a collection NFT */ +export class CannotBurnCollectionError extends ProgramError { + readonly name: string = 'CannotBurnCollection'; + + readonly code: number = 0xe; // 14 + + constructor(program: Program, cause?: Error) { + super('Cannot burn a collection NFT', program, cause); + } +} +codeToErrorMap.set(0xe, CannotBurnCollectionError); +nameToErrorMap.set('CannotBurnCollection', CannotBurnCollectionError); + /** * Attempts to resolve a custom program error from the provided error code. * @category Errors diff --git a/clients/rust/Cargo.toml b/clients/rust/Cargo.toml index 575f49f8..b8efd31b 100644 --- a/clients/rust/Cargo.toml +++ b/clients/rust/Cargo.toml @@ -18,10 +18,10 @@ num-derive = "^0.3" num-traits = "^0.2" serde = { version = "^1.0", features = ["derive"], optional = true } serde_with = { version = "^3.0", optional = true } -solana-program = "~1.16" +solana-program = "> 1.14, <= 1.18" thiserror = "^1.0" [dev-dependencies] assert_matches = "1.5.0" -solana-program-test = "~1.16" -solana-sdk = "~1.16" +solana-program-test = "> 1.14, <= 1.18" +solana-sdk = "> 1.14, <= 1.18" diff --git a/clients/rust/src/generated/errors/mpl_asset.rs b/clients/rust/src/generated/errors/mpl_asset.rs index 97d4749d..e6ad29ca 100644 --- a/clients/rust/src/generated/errors/mpl_asset.rs +++ b/clients/rust/src/generated/errors/mpl_asset.rs @@ -52,6 +52,9 @@ pub enum MplAssetError { /// 13 (0xD) - Cannot migrate a print edition #[error("Cannot migrate a print edition")] CannotMigratePrints, + /// 14 (0xE) - Cannot burn a collection NFT + #[error("Cannot burn a collection NFT")] + CannotBurnCollection, } impl solana_program::program_error::PrintProgramError for MplAssetError { diff --git a/idls/mpl_asset_program.json b/idls/mpl_asset_program.json index ffd7e39a..01502381 100644 --- a/idls/mpl_asset_program.json +++ b/idls/mpl_asset_program.json @@ -1394,6 +1394,11 @@ "code": 13, "name": "CannotMigratePrints", "msg": "Cannot migrate a print edition" + }, + { + "code": 14, + "name": "CannotBurnCollection", + "msg": "Cannot burn a collection NFT" } ], "metadata": { diff --git a/programs/mpl-asset/Cargo.toml b/programs/mpl-asset/Cargo.toml index 6c320c1a..188e8342 100644 --- a/programs/mpl-asset/Cargo.toml +++ b/programs/mpl-asset/Cargo.toml @@ -14,7 +14,7 @@ borsh = "^0.10" shank = "0.3.0" num-derive = "^0.3" num-traits = "^0.2" -solana-program = "~1.16" +solana-program = "^1.16" thiserror = "^1.0" bytemuck = "1.14.1" mpl-utils = "0.3.3" diff --git a/programs/mpl-asset/src/error.rs b/programs/mpl-asset/src/error.rs index 68f2fbaf..ce4a28f9 100644 --- a/programs/mpl-asset/src/error.rs +++ b/programs/mpl-asset/src/error.rs @@ -63,6 +63,10 @@ pub enum MplAssetError { /// 13 - Cannot migrate a print edition #[error("Cannot migrate a print edition")] CannotMigratePrints, + + /// 14 - Cannot burn a collection NFT + #[error("Cannot burn a collection NFT")] + CannotBurnCollection, } impl PrintProgramError for MplAssetError { diff --git a/programs/mpl-asset/src/instruction.rs b/programs/mpl-asset/src/instruction.rs index fbc3a04a..ab5d2949 100644 --- a/programs/mpl-asset/src/instruction.rs +++ b/programs/mpl-asset/src/instruction.rs @@ -27,18 +27,19 @@ pub enum MplAssetInstruction { #[account(1, optional, signer, name="owner", desc = "The authority of the new asset")] #[account(2, writable, signer, name="payer", desc = "The account paying for the storage fees")] // Dependent on how migration is handled - #[account(3, optional, writable, name="collection", desc="mpl-token-metadata collection metadata or mpl-asset collection")] - #[account(4, writable, name="token", desc="Token account")] - #[account(5, writable, name="mint", desc="Mint of token asset")] - #[account(6, writable, name="metadata", desc="Metadata (pda of ['metadata', program id, mint id])")] - #[account(7, writable, name="edition", desc="Edition of token asset")] - #[account(8, optional, writable, name="owner_token_record", desc="Owner token record account")] - #[account(9, name="spl_token_program", desc="SPL Token Program")] - #[account(10, name="spl_ata_program", desc="SPL Associated Token Account program")] - #[account(11, name="system_program", desc = "The system program")] - #[account(12, optional, name="log_wrapper", desc = "The SPL Noop Program")] - #[account(13, optional, name="authorization_rules_program", desc="Token Authorization Rules Program")] - #[account(14, optional, name="authorization_rules", desc="Token Authorization Rules account")] + #[account(3, optional, name="collection_metadata", desc="mpl-token-metadata collection metadata")] + #[account(4, optional, writable, name="collection", desc="mpl-asset collection")] + #[account(5, writable, name="token", desc="Token account")] + #[account(6, writable, name="mint", desc="Mint of token asset")] + #[account(7, writable, name="metadata", desc="Metadata (pda of ['metadata', program id, mint id])")] + #[account(8, writable, name="edition", desc="Edition of token asset")] + #[account(9, optional, writable, name="owner_token_record", desc="Owner token record account")] + #[account(10, name="spl_token_program", desc="SPL Token Program")] + #[account(11, name="spl_ata_program", desc="SPL Associated Token Account program")] + #[account(12, name="system_program", desc = "The system program")] + #[account(13, optional, name="log_wrapper", desc = "The SPL Noop Program")] + #[account(14, optional, name="authorization_rules_program", desc="Token Authorization Rules Program")] + #[account(15, optional, name="authorization_rules", desc="Token Authorization Rules account")] Migrate(MigrateArgs), /// Delegate an mpl-asset. diff --git a/programs/mpl-asset/src/processor/migrate.rs b/programs/mpl-asset/src/processor/migrate.rs index 3c656a9c..18bf610f 100644 --- a/programs/mpl-asset/src/processor/migrate.rs +++ b/programs/mpl-asset/src/processor/migrate.rs @@ -29,10 +29,18 @@ pub(crate) fn migrate<'a>(accounts: &'a [AccountInfo<'a>], args: MigrateArgs) -> }; let metadata = Metadata::safe_deserialize(&ctx.accounts.metadata.data.borrow())?; - match metadata.collection_details { // If this is a collection NFT then we need to initialize migration for the whole collection. - Some(_) => {} + Some(_) => { + // We don't want to burn the collection NFT if we are migrating the whole collection. + if args.level != MigrationLevel::MigrateOnly { + return Err(MplAssetError::CannotBurnCollection.into()); + } + + // If the mpl-asset collection doesn't already exist, then create it. + + + } // Otherwise, we need to migrate the NFT None => { // Assert that the NFT is not a print edition. diff --git a/programs/mpl-asset/src/state/asset_signer.rs b/programs/mpl-asset/src/state/asset_signer.rs new file mode 100644 index 00000000..1f0e2002 --- /dev/null +++ b/programs/mpl-asset/src/state/asset_signer.rs @@ -0,0 +1,31 @@ +use borsh::{BorshDeserialize, BorshSerialize}; +use solana_program::pubkey::Pubkey; + +#[derive(Clone, BorshSerialize, BorshDeserialize, Debug, ShankAccount)] +pub struct AssetSigner { + pub key: Key, //1 +} + +impl DataBlob for AssetSigner { + fn get_initial_size() -> usize { + 1 + } + + fn get_size(&self) -> usize { + 1 + } +} + +impl SolanaAccount for AssetSigner { + fn key() -> Key { + Key::AssetSigner + } +} + +impl Default for AssetSigner { + fn default() -> Self { + AssetSigner { + key: Key::AssetSigner, + } + } +} \ No newline at end of file