HypernativeFirewallProtected
Title: HypernativeFirewallProtected
Author: Merge Layers Inc.
Abstract contract that provides firewall protection for inheriting contracts.
Inherited from Hypernative and refactored for our needs without changing core behavior.
State Variables
HYPERNATIVE_ORACLE_STORAGE_SLOT
Storage slot for the firewall address.
bytes32 private constant HYPERNATIVE_ORACLE_STORAGE_SLOT =
bytes32(uint256(keccak256("eip1967.hypernative.firewall")) - 1)
HYPERNATIVE_ADMIN_STORAGE_SLOT
Storage slot for the firewall admin address.
bytes32 private constant HYPERNATIVE_ADMIN_STORAGE_SLOT =
bytes32(uint256(keccak256("eip1967.hypernative.admin")) - 1)
HYPERNATIVE_MODE_STORAGE_SLOT
Storage slot for the firewall strict mode.
bytes32 private constant HYPERNATIVE_MODE_STORAGE_SLOT =
bytes32(uint256(keccak256("eip1967.hypernative.is_strict_mode")) - 1)
Functions
onlyFirewallAdmin
modifier onlyFirewallAdmin() ;
onlyFirewallApprovedAllowEOA
Modifier to restrict access to only approved firewall addresses and EOAs.
modifier onlyFirewallApprovedAllowEOA() ;
changeFirewallAdmin
Changes the firewall admin.
function changeFirewallAdmin(address _newAdmin) external onlyFirewallAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
_newAdmin | address | The new firewall admin address. |
firewallRegister
Registers an account with the firewall.
function firewallRegister(address _account) public virtual;
Parameters
| Name | Type | Description |
|---|---|---|
_account | address | The account to register. |
setFirewall
Sets the firewall address.
Admin only. Set to address(0) to revoke firewall usage.
function setFirewall(address _firewall) public onlyFirewallAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
_firewall | address | The new firewall address. |
setIsStrictMode
Sets strict mode.
function setIsStrictMode(bool _mode) public onlyFirewallAdmin;
Parameters
| Name | Type | Description |
|---|---|---|
_mode | bool | Whether strict mode is enabled. |
hypernativeFirewallAdmin
Returns the firewall admin address.
function hypernativeFirewallAdmin() public view returns (address admin_);
Returns
| Name | Type | Description |
|---|---|---|
admin_ | address | The firewall admin. |
_firewallGate
Validates the firewall gate.
function _firewallGate(address sender) internal;
Parameters
| Name | Type | Description |
|---|---|---|
sender | address | The sender of the transaction. |
_initHypernativeFirewall
Initializes the firewall.
function _initHypernativeFirewall(address _firewall, address _admin) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_firewall | address | The firewall address. |
_admin | address | The firewall admin address. |
_changeFirewallAdmin
Changes the firewall admin.
function _changeFirewallAdmin(address _newAdmin) internal;
Parameters
| Name | Type | Description |
|---|---|---|
_newAdmin | address | The new firewall admin address. |
_onlyFirewallAdmin
Modifier to restrict access to only approved firewall addresses and EOAs.
function _onlyFirewallAdmin() internal view;
_getAddressBySlot
Returns the address by slot.
function _getAddressBySlot(bytes32 slot) internal view returns (address addr);
Parameters
| Name | Type | Description |
|---|---|---|
slot | bytes32 | The slot to get the address from. |
Returns
| Name | Type | Description |
|---|---|---|
addr | address | The address. |
_getValueBySlot
Returns the value by slot.
function _getValueBySlot(bytes32 _slot) internal view returns (uint256 value);
Parameters
| Name | Type | Description |
|---|---|---|
_slot | bytes32 | The slot to get the value from. |
Returns
| Name | Type | Description |
|---|---|---|
value | uint256 | The value. |
_setAddressBySlot
Sets the address by slot.
function _setAddressBySlot(bytes32 slot, address newAddress) private;
Parameters
| Name | Type | Description |
|---|---|---|
slot | bytes32 | The slot to set the address to. |
newAddress | address | The new address. |
_setValueBySlot
Sets the value by slot.
function _setValueBySlot(bytes32 _slot, uint256 _value) private;
Parameters
| Name | Type | Description |
|---|---|---|
_slot | bytes32 | The slot to set the value to. |
_value | uint256 | The new value. |
_hypernativeFirewallIsStrictMode
Returns whether strict mode is enabled.
function _hypernativeFirewallIsStrictMode() private view returns (bool);
Returns
| Name | Type | Description |
|---|---|---|
<none> | bool | True if strict mode is enabled, false otherwise. |
_hypernativeFirewall
Returns the firewall address.
function _hypernativeFirewall() private view returns (address);
Returns
| Name | Type | Description |
|---|---|---|
<none> | address | The firewall address. |
Events
FirewallAdminChanged
Emitted when the firewall admin changes.
event FirewallAdminChanged(address indexed previousAdmin, address indexed newAdmin);
Parameters
| Name | Type | Description |
|---|---|---|
previousAdmin | address | The previous firewall admin. |
newAdmin | address | The new firewall admin. |
FirewallAddressChanged
Emitted when the firewall address is changed.
event FirewallAddressChanged(address indexed previousFirewall, address indexed newFirewall);
Parameters
| Name | Type | Description |
|---|---|---|
previousFirewall | address | The previous firewall address. |
newFirewall | address | The new firewall address. |
Errors
HypernativeFirewallProtected_NotAdmin
error HypernativeFirewallProtected_NotAdmin();
HypernativeFirewallProtected_NotValid
error HypernativeFirewallProtected_NotValid();