Skip to content

Commit

Permalink
use right modifier (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamBorisov authored Jan 7, 2025
1 parent 82e7e08 commit 38a8651
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion contracts/common/Vesting/Vesting.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract contract Vesting is IVesting, Governed, APRCalculatorConnector {
/**
* @inheritdoc IVesting
*/
function setPenaltyDecreasePerWeek(uint256 newRate) external onlyRole(DEFAULT_ADMIN_ROLE) {
function setPenaltyDecreasePerWeek(uint256 newRate) external onlyGovernance {
if (newRate < 10 || newRate > 150) revert PenaltyRateOutOfRange();
penaltyDecreasePerWeek = newRate;
}
Expand Down
16 changes: 16 additions & 0 deletions docs/common/Vesting/Vesting.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,20 @@ error PenaltyRateOutOfRange()



### Unauthorized

```solidity
error Unauthorized(string only)
```





#### Parameters

| Name | Type | Description |
|---|---|---|
| only | string | undefined |


8 changes: 3 additions & 5 deletions test/HydraDelegation/VestedDelegation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1889,11 +1889,9 @@ export function RunVestedDelegationTests(): void {
it("should revert setting penalty decrease per week if not Governance", async function () {
const { hydraDelegation, delegatedValidator } = await loadFixture(this.fixtures.vestedDelegationFixture);

const admin = await hydraDelegation.DEFAULT_ADMIN_ROLE();

await expect(hydraDelegation.connect(delegatedValidator).setPenaltyDecreasePerWeek(100)).to.be.revertedWith(
ERRORS.accessControl(delegatedValidator.address.toLocaleLowerCase(), admin)
);
await expect(hydraDelegation.connect(delegatedValidator).setPenaltyDecreasePerWeek(100))
.to.be.revertedWithCustomError(hydraDelegation, "Unauthorized")
.withArgs(ERRORS.unauthorized.governanceArg);
});

it("should revert setting penalty decrease per week if amount out of range", async function () {
Expand Down
8 changes: 3 additions & 5 deletions test/HydraStaking/VestedStaking.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,9 @@ export function RunVestedStakingTests(): void {
it("should revert setting penalty decrease per week if not Governance", async function () {
const { hydraStaking, delegatedValidator } = await loadFixture(this.fixtures.vestedDelegationFixture);

const admin = await hydraStaking.DEFAULT_ADMIN_ROLE();

await expect(hydraStaking.connect(delegatedValidator).setPenaltyDecreasePerWeek(100)).to.be.revertedWith(
ERRORS.accessControl(delegatedValidator.address.toLocaleLowerCase(), admin)
);
await expect(hydraStaking.connect(delegatedValidator).setPenaltyDecreasePerWeek(100))
.to.be.revertedWithCustomError(hydraStaking, "Unauthorized")
.withArgs(ERRORS.unauthorized.governanceArg);
});

it("should revert setting penalty decrease per week if amount out of range", async function () {
Expand Down

0 comments on commit 38a8651

Please sign in to comment.