diff --git a/packages/contracts/src/core/permission/PermissionManager.sol b/packages/contracts/src/core/permission/PermissionManager.sol index f2e2ad97e..25ce60341 100644 --- a/packages/contracts/src/core/permission/PermissionManager.sol +++ b/packages/contracts/src/core/permission/PermissionManager.sol @@ -252,13 +252,15 @@ abstract contract PermissionManager is Initializable { // If this permission is not set, continue. } - // Generic caller (`_who: ANY_ADDR`) condition check + // Generic caller (`_who: ANY_ADDR`) { - // This permission can only be granted in conjunction with a condition via the `grantWithCondition` function. address genericCallerPermission = permissionsHashed[ permissionHash({_where: _where, _who: ANY_ADDR, _permissionId: _permissionId}) ]; + // If the permission was granted directly to (`_who: ANY_ADDR`), return `true`. + if (genericCallerPermission == ALLOW_FLAG) return true; + // If the permission was granted with a condition, check the condition and return the result. if (genericCallerPermission != UNSET_FLAG) { return diff --git a/packages/contracts/test/core/permission/permission-manager.ts b/packages/contracts/test/core/permission/permission-manager.ts index 6d1577c4e..1dc1836f7 100644 --- a/packages/contracts/test/core/permission/permission-manager.ts +++ b/packages/contracts/test/core/permission/permission-manager.ts @@ -36,7 +36,7 @@ interface SingleTargetPermission { permissionId: string; } -describe('Core: PermissionManager', function () { +describe.only('Core: PermissionManager', function () { let pm: PermissionManagerTest; let signers: SignerWithAddress[]; let ownerSigner: SignerWithAddress; @@ -1101,6 +1101,17 @@ describe('Core: PermissionManager', function () { ) ).to.be.true; }); + + it('returns `true` if the permission is granted to `_who == ANY_ADDR`', async () => { + await pm.grant(pm.address, ANY_ADDR, ADMIN_PERMISSION_ID); + const isGranted = await pm.callStatic.isGranted( + pm.address, + otherSigner.address, + ADMIN_PERMISSION_ID, + [] + ); + expect(isGranted).to.be.equal(true); + }); }); describe('_hasPermission', () => {