-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from forta-network/caner/firewall-router
Add FirewallRouter to support ExternalFirewall upgradeability
- Loading branch information
Showing
2 changed files
with
65 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// SPDX-License-Identifier: GNU General Public License Version 3 | ||
// See license at: https://github.com/forta-network/forta-firewall-contracts/blob/master/LICENSE-GPLv3.md | ||
|
||
pragma solidity ^0.8.25; | ||
|
||
import "./interfaces/IExternalFirewall.sol"; | ||
import "./interfaces/ICheckpointHook.sol"; | ||
import "./interfaces/IFirewallAccess.sol"; | ||
import "./FirewallPermissions.sol"; | ||
|
||
/** | ||
* @notice This contract provides external firewall upgradeability. | ||
*/ | ||
contract FirewallRouter is IExternalFirewall, FirewallPermissions { | ||
IExternalFirewall public firewall; | ||
|
||
constructor(IExternalFirewall _firewall, IFirewallAccess _firewallAccess) { | ||
firewall = _firewall; | ||
_updateFirewallAccess(_firewallAccess); | ||
} | ||
|
||
/** | ||
* @notice Allows executing checkpoints externally from an integrator contract. The selector | ||
* is checked against the checkpoints configured on this contract. | ||
* @param selector Selector of the function which the checkpoint is configured and executed for | ||
* @param ref The reference number to compare with the threshold | ||
*/ | ||
function executeCheckpoint(address caller, bytes4 selector, uint256 ref) public onlyCheckpointExecutor { | ||
firewall.executeCheckpoint(caller, selector, ref); | ||
} | ||
|
||
/** | ||
* @notice Allows executing checkpoints externally from an integrator contract. The selector | ||
* is checked against the checkpoints configured on this contract. | ||
* @param selector Selector of the function which the checkpoint is configured and executed for | ||
* @param input The input value to use in checkpoint hash computation | ||
*/ | ||
function executeCheckpoint(address caller, bytes4 selector, bytes32 input) public onlyCheckpointExecutor { | ||
firewall.executeCheckpoint(caller, selector, input); | ||
} | ||
|
||
/** | ||
* @notice Accepts and stores an attestation to the transient storage introduced | ||
* with EIP-1153. Multiple contracts that operate in the same transaction can call | ||
* a singleton of this contract. The stored values are later used during checkpoint | ||
* execution. | ||
* @param attestation The set of fields that correspond to and enable the execution of call(s) | ||
* @param attestationSignature Signature of EIP-712 message | ||
*/ | ||
function saveAttestation(Attestation calldata attestation, bytes calldata attestationSignature) public { | ||
firewall.saveAttestation(attestation, attestationSignature); | ||
} | ||
|
||
function updateFirewall(IExternalFirewall newFirewall) public onlyFirewallAdmin { | ||
firewall = newFirewall; | ||
} | ||
} |
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