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: added hooks "after called" for use after call and initiate events #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@ docs/
# Dotenv file
.env

node_modules/
node_modules/

.lh
36 changes: 36 additions & 0 deletions src/extensions/SharedVaults.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abstract contract SharedVaults is BaseMiddleware, ISharedVaults {
) public checkAccess {
_beforeRegisterSharedVault(sharedVault);
_registerSharedVault(sharedVault);
_afterRegisterSharedVault(sharedVault);
}

/**
Expand All @@ -30,6 +31,7 @@ abstract contract SharedVaults is BaseMiddleware, ISharedVaults {
) public checkAccess {
_beforePauseSharedVault(sharedVault);
_pauseSharedVault(sharedVault);
_afterPauseSharedVault(sharedVault);
}

/**
Expand All @@ -40,6 +42,7 @@ abstract contract SharedVaults is BaseMiddleware, ISharedVaults {
) public checkAccess {
_beforeUnpauseSharedVault(sharedVault);
_unpauseSharedVault(sharedVault);
_afterUnpauseSharedVault(sharedVault);
}

/**
Expand All @@ -50,6 +53,7 @@ abstract contract SharedVaults is BaseMiddleware, ISharedVaults {
) public checkAccess {
_beforeUnregisterSharedVault(sharedVault);
_unregisterSharedVault(sharedVault);
_afterUnregisterSharedVault(sharedVault);
}

/**
Expand All @@ -60,6 +64,14 @@ abstract contract SharedVaults is BaseMiddleware, ISharedVaults {
address sharedVault
) internal virtual {}

/**
* @notice Hook called after registering a shared vault
* @param sharedVault The vault address
*/
function _afterRegisterSharedVault(
address sharedVault
) internal virtual {}

/**
* @notice Hook called before pausing a shared vault
* @param sharedVault The vault address
Expand All @@ -68,6 +80,14 @@ abstract contract SharedVaults is BaseMiddleware, ISharedVaults {
address sharedVault
) internal virtual {}

/**
* @notice Hook called after pausing a shared vault
* @param sharedVault The vault address
*/
function _afterPauseSharedVault(
address sharedVault
) internal virtual {}

/**
* @notice Hook called before unpausing a shared vault
* @param sharedVault The vault address
Expand All @@ -76,11 +96,27 @@ abstract contract SharedVaults is BaseMiddleware, ISharedVaults {
address sharedVault
) internal virtual {}

/**
* @notice Hook called after unpausing a shared vault
* @param sharedVault The vault address
*/
function _afterUnpauseSharedVault(
address sharedVault
) internal virtual {}

/**
* @notice Hook called before unregistering a shared vault
* @param sharedVault The vault address
*/
function _beforeUnregisterSharedVault(
address sharedVault
) internal virtual {}

/**
* @notice Hook called after unregistering a shared vault
* @param sharedVault The vault address
*/
function _afterUnregisterSharedVault(
address sharedVault
) internal virtual {}
}
36 changes: 36 additions & 0 deletions src/extensions/Subnetworks.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ abstract contract Subnetworks is BaseMiddleware, ISubnetworks {
) public checkAccess {
_beforeRegisterSubnetwork(subnetwork);
_registerSubnetwork(subnetwork);
_afterRegisterSubnetwork(subnetwork);
}

/**
Expand All @@ -30,6 +31,7 @@ abstract contract Subnetworks is BaseMiddleware, ISubnetworks {
) public checkAccess {
_beforePauseSubnetwork(subnetwork);
_pauseSubnetwork(subnetwork);
_afterPauseSubnetwork(subnetwork);
}

/**
Expand All @@ -40,6 +42,7 @@ abstract contract Subnetworks is BaseMiddleware, ISubnetworks {
) public checkAccess {
_beforeUnpauseSubnetwork(subnetwork);
_unpauseSubnetwork(subnetwork);
_afterUnpauseSubnetwork(subnetwork);
}

/**
Expand All @@ -50,6 +53,7 @@ abstract contract Subnetworks is BaseMiddleware, ISubnetworks {
) public checkAccess {
_beforeUnregisterSubnetwork(subnetwork);
_unregisterSubnetwork(subnetwork);
_afterUnregisterSubnetwork(subnetwork);
}

/**
Expand All @@ -60,6 +64,14 @@ abstract contract Subnetworks is BaseMiddleware, ISubnetworks {
uint96 subnetwork
) internal virtual {}

/**
* @notice Hook called after registering a subnetwork
* @param subnetwork The subnetwork ID
*/
function _afterRegisterSubnetwork(
uint96 subnetwork
) internal virtual {}

/**
* @notice Hook called before pausing a subnetwork
* @param subnetwork The subnetwork ID
Expand All @@ -68,6 +80,14 @@ abstract contract Subnetworks is BaseMiddleware, ISubnetworks {
uint96 subnetwork
) internal virtual {}

/**
* @notice Hook called after pausing a subnetwork
* @param subnetwork The subnetwork ID
*/
function _afterPauseSubnetwork(
uint96 subnetwork
) internal virtual {}

/**
* @notice Hook called before unpausing a subnetwork
* @param subnetwork The subnetwork ID
Expand All @@ -76,11 +96,27 @@ abstract contract Subnetworks is BaseMiddleware, ISubnetworks {
uint96 subnetwork
) internal virtual {}

/**
* @notice Hook called after unpausing a subnetwork
* @param subnetwork The subnetwork ID
*/
function _afterUnpauseSubnetwork(
uint96 subnetwork
) internal virtual {}

/**
* @notice Hook called before unregistering a subnetwork
* @param subnetwork The subnetwork ID
*/
function _beforeUnregisterSubnetwork(
uint96 subnetwork
) internal virtual {}

/**
* @notice Hook called after unregistering a subnetwork
* @param subnetwork The subnetwork ID
*/
function _afterUnregisterSubnetwork(
uint96 subnetwork
) internal virtual {}
}
76 changes: 76 additions & 0 deletions src/extensions/operators/BaseOperators.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ abstract contract BaseOperators is BaseMiddleware {
_beforeRegisterOperatorVault(operator, vault);
_registerOperatorVault(operator, vault);
}
_afterRegisterOperator(operator, key, vault);
}

/**
Expand All @@ -36,6 +37,7 @@ abstract contract BaseOperators is BaseMiddleware {
) internal virtual {
_beforeUnregisterOperator(operator);
_unregisterOperator(operator);
_afterUnregisterOperator(operator);
}

/**
Expand All @@ -47,6 +49,7 @@ abstract contract BaseOperators is BaseMiddleware {
) internal virtual {
_beforePauseOperator(operator);
_pauseOperator(operator);
_afterPauseOperator(operator);
}

/**
Expand All @@ -58,6 +61,7 @@ abstract contract BaseOperators is BaseMiddleware {
) internal virtual {
_beforeUnpauseOperator(operator);
_unpauseOperator(operator);
_afterUnpauseOperator(operator);
}

/**
Expand All @@ -68,6 +72,7 @@ abstract contract BaseOperators is BaseMiddleware {
function _updateOperatorKeyImpl(address operator, bytes memory key) internal virtual {
_beforeUpdateOperatorKey(operator, key);
_updateKey(operator, key);
_afterUpdateOperatorKey(operator, key);
}

/**
Expand All @@ -82,6 +87,7 @@ abstract contract BaseOperators is BaseMiddleware {
}
_beforeRegisterOperatorVault(operator, vault);
_registerOperatorVault(operator, vault);
_afterRegisterOperatorVault(operator, vault);
}

/**
Expand All @@ -92,6 +98,7 @@ abstract contract BaseOperators is BaseMiddleware {
function _unregisterOperatorVaultImpl(address operator, address vault) internal virtual {
_beforeUnregisterOperatorVault(operator, vault);
_unregisterOperatorVault(operator, vault);
_afterUnregisterOperatorVault(operator, vault);
}

/**
Expand All @@ -102,6 +109,7 @@ abstract contract BaseOperators is BaseMiddleware {
function _pauseOperatorVaultImpl(address operator, address vault) internal virtual {
_beforePauseOperatorVault(operator, vault);
_pauseOperatorVault(operator, vault);
_afterPauseOperatorVault(operator, vault);
}

/**
Expand All @@ -112,6 +120,7 @@ abstract contract BaseOperators is BaseMiddleware {
function _unpauseOperatorVaultImpl(address operator, address vault) internal virtual {
_beforeUnpauseOperatorVault(operator, vault);
_unpauseOperatorVault(operator, vault);
_afterUnpauseOperatorVault(operator, vault);
}

/**
Expand All @@ -121,6 +130,13 @@ abstract contract BaseOperators is BaseMiddleware {
*/
function _beforeUpdateOperatorKey(address operator, bytes memory key) internal virtual {}

/**
* @notice Hook called after updating an operator's key
* @param operator The operator address
* @param key The new key
*/
function _afterUpdateOperatorKey(address operator, bytes memory key) internal virtual {}

/**
* @notice Hook called before registering an operator
* @param operator The operator address
Expand All @@ -129,6 +145,14 @@ abstract contract BaseOperators is BaseMiddleware {
*/
function _beforeRegisterOperator(address operator, bytes memory key, address vault) internal virtual {}

/**
* @notice Hook called after registering an operator
* @param operator The operator address
* @param key The operator's key
* @param vault Optional vault address
*/
function _afterRegisterOperator(address operator, bytes memory key, address vault) internal virtual {}

/**
* @notice Hook called before unregistering an operator
* @param operator The operator address
Expand All @@ -137,6 +161,14 @@ abstract contract BaseOperators is BaseMiddleware {
address operator
) internal virtual {}

/**
* @notice Hook called after unregistering an operator
* @param operator The operator address
*/
function _afterUnregisterOperator(
address operator
) internal virtual {}

/**
* @notice Hook called before pausing an operator
* @param operator The operator address
Expand All @@ -145,6 +177,14 @@ abstract contract BaseOperators is BaseMiddleware {
address operator
) internal virtual {}

/**
* @notice Hook called after pausing an operator
* @param operator The operator address
*/
function _afterPauseOperator(
address operator
) internal virtual {}

/**
* @notice Hook called before unpausing an operator
* @param operator The operator address
Expand All @@ -153,31 +193,67 @@ abstract contract BaseOperators is BaseMiddleware {
address operator
) internal virtual {}

/**
* @notice Hook called after unpausing an operator
* @param operator The operator address
*/
function _afterUnpauseOperator(
address operator
) internal virtual {}

/**
* @notice Hook called before registering an operator-vault pair
* @param operator The operator address
* @param vault The vault address
*/
function _beforeRegisterOperatorVault(address operator, address vault) internal virtual {}

/**
* @notice Hook called after registering an operator-vault pair
* @param operator The operator address
* @param vault The vault address
*/
function _afterRegisterOperatorVault(address operator, address vault) internal virtual {}

/**
* @notice Hook called before unregistering an operator-vault pair
* @param operator The operator address
* @param vault The vault address
*/
function _beforeUnregisterOperatorVault(address operator, address vault) internal virtual {}

/**
* @notice Hook called after unregistering an operator-vault pair
* @param operator The operator address
* @param vault The vault address
*/
function _afterUnregisterOperatorVault(address operator, address vault) internal virtual {}

/**
* @notice Hook called before pausing an operator-vault pair
* @param operator The operator address
* @param vault The vault address
*/
function _beforePauseOperatorVault(address operator, address vault) internal virtual {}

/**
* @notice Hook called after pausing an operator-vault pair
* @param operator The operator address
* @param vault The vault address
*/
function _afterPauseOperatorVault(address operator, address vault) internal virtual {}

/**
* @notice Hook called before unpausing an operator-vault pair
* @param operator The operator address
* @param vault The vault address
*/
function _beforeUnpauseOperatorVault(address operator, address vault) internal virtual {}

/**
* @notice Hook called after unpausing an operator-vault pair
* @param operator The operator address
* @param vault The vault address
*/
function _afterUnpauseOperatorVault(address operator, address vault) internal virtual {}
}