Skip to content

Commit

Permalink
Fixing tests and revoke logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Mar 8, 2024
1 parent 3d53acd commit 6a41cec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
12 changes: 9 additions & 3 deletions clients/js/test/revokeAuthority.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,12 @@ test('it can remove the default authority from a plugin to make it immutable', a
},
}).sendAndConfirm(umi);

await revokePluginAuthority(umi, {
await approvePluginAuthority(umi, {
asset: assetAddress.publicKey,
pluginType: PluginType.Freeze,
newAuthority: {
__kind: 'None'
}
}).sendAndConfirm(umi);

const asset1 = await fetchAssetWithPlugins(umi, assetAddress.publicKey);
Expand Down Expand Up @@ -354,7 +357,7 @@ test('it can remove a owner authority from a plugin with other authority', async
plugins: [
{
authority:
{ __kind: 'Pubkey', address: pubkeyAuth.publicKey },
{ __kind: 'Owner' },
plugin: {
__kind: 'Freeze',
fields: [{ frozen: false }],
Expand Down Expand Up @@ -383,11 +386,14 @@ test('it cannot remove a none authority from a plugin', async (t) => {
plugin: plugin('Freeze', [{ frozen: false }]),
}).sendAndConfirm(umi);

await revokePluginAuthority(umi, {
await approvePluginAuthority(umi, {
payer: umi.identity,
asset: assetAddress.publicKey,
authority: umi.identity,
pluginType: PluginType.Freeze,
newAuthority: {
__kind: 'None'
}
}).sendAndConfirm(umi);

const err = await t.throwsAsync(() => revokePluginAuthority(umi, {
Expand Down
9 changes: 7 additions & 2 deletions programs/mpl-core/src/plugins/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,15 @@ pub fn revoke_authority_on_plugin<'a>(
.find(|record| record.plugin_type == *plugin_type)
.ok_or(MplCoreError::PluginNotFound)?;

solana_program::msg!("authority_type: {:?}", authority_type);
solana_program::msg!("registry_record.authority: {:?}", registry_record.authority);

// TODO inspect this logic
if *authority_type != registry_record.plugin_type.default_authority() &&
if (*authority_type != registry_record.plugin_type.default_authority() &&
// pubkey authorities can remove themselves if they are a signer
authority_type != &registry_record.authority
authority_type != &registry_record.authority) ||
// Unable to revoke a None authority
registry_record.authority == Authority::None
{
return Err(MplCoreError::InvalidAuthority.into());
}
Expand Down

0 comments on commit 6a41cec

Please sign in to comment.