Skip to content

Commit

Permalink
feat: add stateless variant (#42)
Browse files Browse the repository at this point in the history
* feat: add stateless variant

* fix: use proper error

* fix: add comment

* fix: add header

* fix: add title

* fix: better docs

* fix: remove stateless again

* fix: remove iownable
  • Loading branch information
sakulstra authored Aug 8, 2024
1 parent 5d728d5 commit 6cbcb18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {IWithGuardian} from './interfaces/IWithGuardian.sol';
* Forked version of https://github.com/bgd-labs/solidity-utils/blob/main/src/contracts/access-control/OwnableWithGuardian.sol
* Relying on UpgradableOwnable & moving the storage to 7201
*/
abstract contract UpgradableOwnableWithGuardian is OwnableUpgradeable, IWithGuardian {
abstract contract UpgradeableOwnableWithGuardian is OwnableUpgradeable, IWithGuardian {
/// @custom:storage-location erc7201:aave.storage.OwnableWithGuardian
struct OwnableWithGuardian {
address _guardian;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
pragma solidity ^0.8.20;

import 'forge-std/Test.sol';
import {UpgradableOwnableWithGuardian} from '../src/contracts/access-control/UpgradableOwnableWithGuardian.sol';
import {UpgradeableOwnableWithGuardian} from '../src/contracts/access-control/UpgradeableOwnableWithGuardian.sol';

contract ImplOwnableWithGuardian is UpgradableOwnableWithGuardian {
contract ImplOwnableWithGuardian is UpgradeableOwnableWithGuardian {
function initialize(address owner, address guardian) public initializer {
__Ownable_init(owner);
__Ownable_With_Guardian_init(guardian);
Expand All @@ -16,7 +16,7 @@ contract ImplOwnableWithGuardian is UpgradableOwnableWithGuardian {
}

contract TestOfUpgradableOwnableWithGuardian is Test {
UpgradableOwnableWithGuardian public withGuardian;
UpgradeableOwnableWithGuardian public withGuardian;

address owner = address(0x4);
address guardian = address(0x8);
Expand All @@ -34,7 +34,7 @@ contract TestOfUpgradableOwnableWithGuardian is Test {
function test_onlyGuardian() external {
vm.expectRevert(
abi.encodeWithSelector(
UpgradableOwnableWithGuardian.OnlyGuardianInvalidCaller.selector,
UpgradeableOwnableWithGuardian.OnlyGuardianInvalidCaller.selector,
address(this)
)
);
Expand All @@ -44,7 +44,7 @@ contract TestOfUpgradableOwnableWithGuardian is Test {
function test_onlyOwnerOrGuardian() external {
vm.expectRevert(
abi.encodeWithSelector(
UpgradableOwnableWithGuardian.OnlyGuardianOrOwnerInvalidCaller.selector,
UpgradeableOwnableWithGuardian.OnlyGuardianOrOwnerInvalidCaller.selector,
address(this)
)
);
Expand All @@ -67,7 +67,7 @@ contract TestOfUpgradableOwnableWithGuardian is Test {
vm.prank(eoa);
vm.expectRevert(
abi.encodeWithSelector(
UpgradableOwnableWithGuardian.OnlyGuardianOrOwnerInvalidCaller.selector,
UpgradeableOwnableWithGuardian.OnlyGuardianOrOwnerInvalidCaller.selector,
eoa
)
);
Expand Down

0 comments on commit 6cbcb18

Please sign in to comment.