Skip to content

Commit

Permalink
fix: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
loga4 committed Nov 29, 2024
1 parent 728d828 commit 7166610
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
5 changes: 1 addition & 4 deletions contracts/0.8.25/Accounting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ contract Accounting is VaultHub {
function initialize(address _admin) external initializer {
if (_admin == address(0)) revert ZeroArgument("_admin");

__AccessControlEnumerable_init();
__VaultHub_init();

_grantRole(DEFAULT_ADMIN_ROLE, _admin);
__VaultHub_init(_admin);
}

/// @notice calculates all the state changes that is required to apply the report
Expand Down
6 changes: 3 additions & 3 deletions contracts/0.8.25/vaults/StakingVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ contract StakingVault is IStakingVault, IBeaconProxy, VaultBeaconChainDepositor,
}

modifier onlyBeacon() {
if (msg.sender != getBeacon()) revert UnauthorizedSender(msg.sender);
if (msg.sender != getBeacon()) revert SenderShouldBeBeacon(msg.sender, getBeacon());
_;
}

/// @notice Initialize the contract storage explicitly.
/// The initialize function selector is not changed. For upgrades use `_params` variable
///
/// @param _owner vaultStaffRoom address
/// @param _owner vault owner address
/// @param _params the calldata for initialize contract after upgrades
// solhint-disable-next-line no-unused-vars
function initialize(address _owner, bytes calldata _params) external onlyBeacon initializer {
Expand Down Expand Up @@ -229,5 +229,5 @@ contract StakingVault is IStakingVault, IBeaconProxy, VaultBeaconChainDepositor,
error NotHealthy();
error NotAuthorized(string operation, address sender);
error LockedCannotBeDecreased(uint256 locked);
error UnauthorizedSender(address sender);
error SenderShouldBeBeacon(address sender, address beacon);
}
5 changes: 4 additions & 1 deletion contracts/0.8.25/vaults/VaultHub.sol
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ abstract contract VaultHub is AccessControlEnumerableUpgradeable {
_disableInitializers();
}

function __VaultHub_init() internal onlyInitializing {
function __VaultHub_init(address _admin) internal onlyInitializing {
__AccessControlEnumerable_init();
// stone in the elevator
_getVaultHubStorage().sockets.push(VaultSocket(IHubVault(address(0)), 0, 0, 0, 0, 0));

_grantRole(DEFAULT_ADMIN_ROLE, _admin);
}

/// @notice added factory address to allowed list
Expand Down
4 changes: 2 additions & 2 deletions test/0.8.25/vaults/vault.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ describe("StakingVault.sol", async () => {
it("reverts on impl initialization", async () => {
await expect(stakingVault.initialize(await owner.getAddress(), "0x")).to.be.revertedWithCustomError(
vaultProxy,
"UnauthorizedSender",
"SenderShouldBeBeacon",
);
});

it("reverts if already initialized", async () => {
await expect(vaultProxy.initialize(await owner.getAddress(), "0x")).to.be.revertedWithCustomError(
vaultProxy,
"UnauthorizedSender",
"SenderShouldBeBeacon",
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/0.8.25/vaults/vaultFactory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("VaultFactory.sol", () => {
await accounting.connect(admin).grantRole(await accounting.VAULT_REGISTRY_ROLE(), admin);

//the initialize() function cannot be called on a contract
await expect(implOld.initialize(stranger, "0x")).to.revertedWithCustomError(implOld, "UnauthorizedSender");
await expect(implOld.initialize(stranger, "0x")).to.revertedWithCustomError(implOld, "SenderShouldBeBeacon");
});

beforeEach(async () => (originalState = await Snapshot.take()));
Expand Down
2 changes: 1 addition & 1 deletion test/0.8.25/vaults/vaultStaffRoom.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe("VaultStaffRoom.sol", () => {
await accounting.connect(admin).grantRole(await accounting.VAULT_MASTER_ROLE(), admin);

//the initialize() function cannot be called on a contract
await expect(implOld.initialize(stranger, "0x")).to.revertedWithCustomError(implOld, "UnauthorizedSender");
await expect(implOld.initialize(stranger, "0x")).to.revertedWithCustomError(implOld, "SenderShouldBeBeacon");
});

beforeEach(async () => (originalState = await Snapshot.take()));
Expand Down

0 comments on commit 7166610

Please sign in to comment.