Skip to content

Commit

Permalink
feat: update hasAccess modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
xorsal committed Nov 8, 2024
1 parent 0610e87 commit fc27d21
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions solidity/contracts/modules/access/ModuleAccessController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ pragma solidity ^0.8.19;

import {CommonAccessController} from '@defi-wonderland/prophet-core/solidity/contracts/CommonAccessController.sol';

import {IModuleAccessController} from '../../../interfaces/modules/access/IModuleAccessController.sol';
import {Module} from '@defi-wonderland/prophet-core/solidity/contracts/Module.sol';
import {IOracle} from '@defi-wonderland/prophet-core/solidity/interfaces/IOracle.sol';

abstract contract ModuleAccessController is CommonAccessController, Module {
abstract contract ModuleAccessController is IModuleAccessController, CommonAccessController, Module {
constructor(IOracle _oracle) Module(_oracle) {}

/**
Expand Down Expand Up @@ -35,13 +36,12 @@ abstract contract ModuleAccessController is CommonAccessController, Module {
bytes memory _params,
AccessControl memory _accessControl
) {
if (_accessModule != address(0)) {
bool _isApproved = ORACLE.isAccessModuleApproved(_accessControl.user, _accessModule);

if (!_isApproved) revert AccessController_NoAccess();

_hasAccess(_accessModule, _typehash, _params, _accessControl);
// Revert if sender is acting for a user without module approval
if (msg.sender != _accessControl.user && !ORACLE.isAccessModuleApproved(_accessControl.user, _accessModule)) {
revert ModuleAccessController_AccessModuleNotApproved();
}
// todo: probably a change name is required here, something like `_ensureAccess`?
_hasAccess(_accessModule, _typehash, _params, _accessControl);
_;
}
}

0 comments on commit fc27d21

Please sign in to comment.