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

feat: access module #77

Merged
merged 11 commits into from
Nov 10, 2024
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();
0xJabberwock marked this conversation as resolved.
Show resolved Hide resolved
}
// todo: probably a change name is required here, something like `_ensureAccess`?
_hasAccess(_accessModule, _typehash, _params, _accessControl);
_;
}
}