Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix isGranted #618

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
6 changes: 4 additions & 2 deletions packages/contracts/src/core/permission/PermissionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion packages/contracts/test/core/permission/permission-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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', () => {
Expand Down
Loading