refactor(StakeVault): use custom error over error strings (#35)

This commit is contained in:
r4bbit 2023-11-07 09:38:00 +01:00 committed by GitHub
parent 6f591dd674
commit 70c74e2c2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -1,16 +1,17 @@
ExecuteAccountTest:testDeployment() (gas: 26400)
ExecuteAccountTest:test_RevertWhen_InvalidLimitEpoch() (gas: 974502)
ExecuteAccountTest:test_RevertWhen_InvalidLimitEpoch() (gas: 964423)
LeaveTest:testDeployment() (gas: 26172)
LeaveTest:test_RevertWhen_NoPendingMigration() (gas: 662520)
LeaveTest:test_RevertWhen_NoPendingMigration() (gas: 652901)
LeaveTest:test_RevertWhen_SenderIsNotVault() (gas: 10562)
LockTest:testDeployment() (gas: 26400)
LockTest:test_RevertWhen_DecreasingLockTime() (gas: 976972)
LockTest:test_RevertWhen_DecreasingLockTime() (gas: 967353)
LockTest:test_RevertWhen_SenderIsNotVault() (gas: 10607)
MigrateTest:testDeployment() (gas: 26172)
MigrateTest:test_RevertWhen_NoPendingMigration() (gas: 652740)
MigrateTest:test_RevertWhen_SenderIsNotVault() (gas: 10629)
StakeManagerTest:testDeployment() (gas: 26172)
StakeTest:testDeployment() (gas: 26172)
StakeTest:test_RevertWhen_SenderIsNotVault() (gas: 10638)
UnstakeTest:testDeployment() (gas: 26355)
UnstakeTest:test_RevertWhen_FundsLocked() (gas: 973435)
UnstakeTest:test_RevertWhen_FundsLocked() (gas: 963816)
UnstakeTest:test_RevertWhen_SenderIsNotVault() (gas: 10609)

View File

@ -13,6 +13,8 @@ import { StakeManager } from "./StakeManager.sol";
*/
contract StakeVault is Ownable {
error StakeVault__MigrationNotAvailable();
StakeManager private stakeManager;
ERC20 immutable stakedToken;
@ -50,7 +52,7 @@ contract StakeVault is Ownable {
*/
function updateManager() external onlyOwner {
StakeManager migrated = stakeManager.migrate();
require(address(migrated) != address(0), "Migration not available.");
if (address(migrated) == address(0)) revert StakeVault__MigrationNotAvailable();
stakeManager = migrated;
}
}