Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
A few codeRabbitAi fixes
  • Loading branch information
danenbm committed May 7, 2025
commit 9ea03ff8f41bd981a074714c2fa9803faf44dc08
66 changes: 65 additions & 1 deletion clients/js/test/plugins/collection/bubblegumV2.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from 'ava';
import { PublicKey } from '@metaplex-foundation/umi';
import { generateSigner, PublicKey } from '@metaplex-foundation/umi';
import {
addCollectionPluginV1,
createPlugin,
Expand Down Expand Up @@ -324,3 +324,67 @@ test('it cannot add external plugin to collection with BubblegumV2 plugin', asyn
name: 'InvalidAuthority',
});
});

test('it cannot create collection with BubblegumV2 plugin using wrong authority', async (t) => {
const umi = await createUmi();
const updateAuthorityResult = createCollection(umi, {
plugins: [
{
type: 'BubblegumV2',
authority: {
type: 'UpdateAuthority',
},
},
],
});

await t.throwsAsync(updateAuthorityResult, {
name: 'InvalidAuthority',
});

const noneResult = createCollection(umi, {
plugins: [
{
type: 'BubblegumV2',
authority: {
type: 'None',
},
},
],
});

await t.throwsAsync(noneResult, {
name: 'InvalidAuthority',
});

const ownerResult = createCollection(umi, {
plugins: [
{
type: 'BubblegumV2',
authority: {
type: 'Owner',
},
},
],
});

await t.throwsAsync(ownerResult, {
name: 'InvalidAuthority',
});

const addressResult = createCollection(umi, {
plugins: [
{
type: 'BubblegumV2',
authority: {
type: 'Address',
address: generateSigner(umi).publicKey,
},
},
],
});

await t.throwsAsync(addressResult, {
name: 'InvalidAuthority',
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ pub struct BubblegumV2 {}

impl BubblegumV2 {
/// List of other plugins allowed on collections with the Bubblegum V2 plugin.
/// The BubblegumV2 plugin limits what can be on the collection to plugins that are
/// supported and validated at runtime by the Bubblegum program.
pub const ALLOW_LIST: [PluginType; 6] = [
PluginType::Attributes,
PluginType::PermanentFreezeDelegate,
Expand Down Expand Up @@ -76,7 +78,9 @@ impl PluginValidation for BubblegumV2 {
_ctx: &PluginValidationContext,
) -> Result<ValidationResult, ProgramError> {
// If the BubblegumV2 plugin is present, no external plugin adapters
// can be added.
// can be added. The BubblegumV2 plugin limits what can be on the
// collection to plugins that are supported and validated at runtime
// by the Bubblegum program.
reject!()
}
}
Expand Down
5 changes: 5 additions & 0 deletions programs/mpl-core/src/processor/create_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,11 @@ pub(crate) fn process_create_collection<'a>(

// Bubblegum V2 plugin always has a fixed authority.
let authority = if plugin_type == PluginType::BubblegumV2 {
if let Some(supplied) = &plugin.authority {
if supplied != &plugin.plugin.manager() {
return Err(MplCoreError::InvalidAuthority.into());
}
}
plugin.plugin.manager()
} else {
plugin.authority.unwrap_or(plugin.plugin.manager())
Expand Down