-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(contracts): Refactor duplicated code to manage the Router addre…
…ss (#820)
- Loading branch information
Showing
13 changed files
with
129 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.21; | ||
|
||
import { OwnableUpgradeable } from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; | ||
import { IRouter } from "./interfaces/IRouter.sol"; | ||
|
||
/** | ||
* @title RouterManager | ||
* @notice Centralise la gestion du Router | ||
*/ | ||
abstract contract RouterManager is OwnableUpgradeable { | ||
/// @notice Error thrown when an invalid Router address is given | ||
error RouterInvalid(); | ||
/// @notice Event emitted when the router is updated | ||
event RouterUpdated(address routerAddress); | ||
|
||
/** | ||
* @notice Change l'adresse du Router | ||
* @dev Seul le propriétaire peut appeler cette méthode | ||
* @param _router La nouvelle adresse du Router | ||
*/ | ||
function updateRouter(address _router) public onlyOwner { | ||
if (_router == address(0)) revert RouterInvalid(); | ||
_setRouter(_router); // Appelle une fonction interne pour mettre à jour | ||
emit RouterUpdated(_router); // Émet un événement pour signaler la mise à jour | ||
} | ||
|
||
/** | ||
* @dev Définit l'adresse du Router. Doit être implémentée par les contrats enfants. | ||
* @param _router La nouvelle adresse du Router | ||
*/ | ||
function _setRouter(address _router) internal virtual; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.