diff --git a/clients/js/test/plugins/asset/updateDelegate.test.ts b/clients/js/test/plugins/asset/updateDelegate.test.ts index 9598851a..9355ef91 100644 --- a/clients/js/test/plugins/asset/updateDelegate.test.ts +++ b/clients/js/test/plugins/asset/updateDelegate.test.ts @@ -689,7 +689,7 @@ test('it cannot add updateDelegate plugin with additional delegate as additional await t.throwsAsync(result, { name: 'NoApprovals' }); }); -test('it cannot update the update authority of the asset as an updateDelegate additional delegate', async (t) => { +test('it can update the update authority of the asset as an updateDelegate additional delegate', async (t) => { const umi = await createUmi(); const updateDelegate = generateSigner(umi); const updateDelegate2 = generateSigner(umi); @@ -703,16 +703,21 @@ test('it cannot update the update authority of the asset as an updateDelegate ad ], }); - const result = update(umi, { + await update(umi, { asset, authority: updateDelegate, newUpdateAuthority: updateAuthority('Address', [updateDelegate2.publicKey]), }).sendAndConfirm(umi); - await t.throwsAsync(result, { name: 'NoApprovals' }); + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: umi.identity.publicKey, + updateAuthority: { type: 'Address', address: updateDelegate2.publicKey }, + }); }); -test('it cannot update the update authority of the asset as an updateDelegate root authority', async (t) => { +test('it can update the update authority of the asset as an updateDelegate root authority', async (t) => { const umi = await createUmi(); const updateDelegate = generateSigner(umi); const updateDelegate2 = generateSigner(umi); @@ -727,13 +732,18 @@ test('it cannot update the update authority of the asset as an updateDelegate ro ], }); - const result = update(umi, { + await update(umi, { asset, authority: updateDelegate, newUpdateAuthority: updateAuthority('Address', [updateDelegate2.publicKey]), }).sendAndConfirm(umi); - await t.throwsAsync(result, { name: 'NoApprovals' }); + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: umi.identity.publicKey, + updateAuthority: { type: 'Address', address: updateDelegate2.publicKey }, + }); }); test('an updateDelegate can add a plugin to an asset', async (t) => { diff --git a/clients/js/test/plugins/collection/updateDelegate.test.ts b/clients/js/test/plugins/collection/updateDelegate.test.ts index 8c27330f..7b0197aa 100644 --- a/clients/js/test/plugins/collection/updateDelegate.test.ts +++ b/clients/js/test/plugins/collection/updateDelegate.test.ts @@ -654,7 +654,7 @@ test('it can approve/revoke non-updateDelegate plugin on an asset as collection }); }); -test('it cannot update the update authority of the collection as an updateDelegate additional delegate', async (t) => { +test('it can update the update authority of the collection as an updateDelegate additional delegate', async (t) => { const umi = await createUmi(); const updateDelegate = generateSigner(umi); const updateDelegate2 = generateSigner(umi); @@ -668,16 +668,20 @@ test('it cannot update the update authority of the collection as an updateDelega ], }); - const result = updateCollection(umi, { + await updateCollection(umi, { collection: collection.publicKey, authority: updateDelegate, newUpdateAuthority: updateDelegate2.publicKey, }).sendAndConfirm(umi); - await t.throwsAsync(result, { name: 'InvalidAuthority' }); + await assertCollection(t, umi, { + ...DEFAULT_COLLECTION, + collection: collection.publicKey, + updateAuthority: updateDelegate2.publicKey, + }); }); -test('it cannot update the update authority of the collection as an updateDelegate root authority', async (t) => { +test('it can update the update authority of the collection as an updateDelegate root authority', async (t) => { const umi = await createUmi(); const updateDelegate = generateSigner(umi); const updateDelegate2 = generateSigner(umi); @@ -692,13 +696,17 @@ test('it cannot update the update authority of the collection as an updateDelega ], }); - const result = updateCollection(umi, { + await updateCollection(umi, { collection: collection.publicKey, authority: updateDelegate, newUpdateAuthority: updateDelegate2.publicKey, }).sendAndConfirm(umi); - await t.throwsAsync(result, { name: 'InvalidAuthority' }); + await assertCollection(t, umi, { + ...DEFAULT_COLLECTION, + collection: collection.publicKey, + updateAuthority: updateDelegate2.publicKey, + }); }); test('it can update collection details as an updateDelegate additional delegate', async (t) => { diff --git a/clients/js/test/updateV2.test.ts b/clients/js/test/updateV2.test.ts index bcee1b63..691ad390 100644 --- a/clients/js/test/updateV2.test.ts +++ b/clients/js/test/updateV2.test.ts @@ -1046,7 +1046,7 @@ test('it can change an asset collection using same update authority (delegate ex }); }); -test('it cannot remove an asset from collection using update delegate', async (t) => { +test('it can remove an asset from collection using update delegate', async (t) => { const umi = await createUmi(); const collectionAuthority = generateSigner(umi); const { asset, collection } = await createAssetWithCollection( @@ -1107,17 +1107,22 @@ test('it cannot remove an asset from collection using update delegate', async (t numMinted: 1, }); - const result = update(umi, { + await update(umi, { asset, collection, newUpdateAuthority: updateAuthority('Address', [umi.identity.publicKey]), authority: updateDelegate, }).sendAndConfirm(umi); - await t.throwsAsync(result, { name: 'NoApprovals' }); + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: umi.identity.publicKey, + updateAuthority: { type: 'Address', address: umi.identity.publicKey }, + }); }); -test('it cannot remove an asset from collection using additional update delegate', async (t) => { +test('it can remove an asset from collection using additional update delegate', async (t) => { const umi = await createUmi(); const collectionAuthority = generateSigner(umi); const { asset, collection } = await createAssetWithCollection( @@ -1157,14 +1162,19 @@ test('it cannot remove an asset from collection using additional update delegate numMinted: 1, }); - const result = update(umi, { + await update(umi, { asset, collection, newUpdateAuthority: updateAuthority('Address', [umi.identity.publicKey]), authority: additionalDelegate, }).sendAndConfirm(umi); - await t.throwsAsync(result, { name: 'NoApprovals' }); + await assertAsset(t, umi, { + ...DEFAULT_ASSET, + asset: asset.publicKey, + owner: umi.identity.publicKey, + updateAuthority: { type: 'Address', address: umi.identity.publicKey }, + }); }); test('it cannot add asset to collection using additional update delegate on new collection', async (t) => { diff --git a/programs/mpl-core/src/plugins/internal/authority_managed/update_delegate.rs b/programs/mpl-core/src/plugins/internal/authority_managed/update_delegate.rs index d8a952d2..471755da 100644 --- a/programs/mpl-core/src/plugins/internal/authority_managed/update_delegate.rs +++ b/programs/mpl-core/src/plugins/internal/authority_managed/update_delegate.rs @@ -164,14 +164,12 @@ impl PluginValidation for UpdateDelegate { &self, ctx: &PluginValidationContext, ) -> Result { - if ((ctx.resolved_authorities.is_some() - && ctx - .resolved_authorities - .unwrap() - .contains(ctx.self_authority)) - || self.additional_delegates.contains(ctx.authority_info.key)) - // We do not allow the root authority (either Collection or Address) to be changed by this delegate. - && ctx.new_collection_authority.is_none() && ctx.new_asset_authority.is_none() + if (ctx.resolved_authorities.is_some() + && ctx + .resolved_authorities + .unwrap() + .contains(ctx.self_authority)) + || self.additional_delegates.contains(ctx.authority_info.key) { approve!() } else {