Firewall.sol

The Firewall contract is the main contract of the system. It stores and manages all the Policies to which Firewall Consumers subscribe to, and executes them as needed.

Properties

Modifiers

onlyConsumerAdmin()

Only allows the modified function to run if it was called by the Firewall Admin (see setFirewallAdmin()) .

Methods

preExecution()

function preExecution(address sender, bytes calldata data, uint value)

Runs the Pre Execution hook on all the Policies that msg.sender has subscribed to for the method described by the first 4 bytes of data.

postExecution()

function postExecution(address sender, bytes calldata data, uint value)

Runs the Post Execution hook on all the Policies that msg.sender has subscribed to for the method described by the first 4 bytes of data.

setPolicyStatus()

function setPolicyStatus(address policy, bool status)

Callable only by the Firewall Owner, used to approve or revoke approval of a Policy. Revoking approval doesn’t remove existing consumer subscriptions.

addPolicy()

function addPolicy(address consumer, bytes4 methodSig, address policy)

Callable only by the Firewall Admin of the Firewall Consumer, this method adds the Policy to the list of subscribed policies for the given method signature.

removePolicy()

function removePolicy(address consumer, bytes4 methodSig, uint policyIndex)

Callable only by the Firewall Admin of the consumer, this method removes the Policy found at the policyIndex from the list of subscribed policies for the given method signature.

addPolicies()

function addPolicies(address consumer, bytes4[] calldata methodSigs, address[] calldata policies)

Callable only by the Firewall Admin of the Firewall Consumer, this method adds multiple policies to the list of subscribed policies for the given method signatures. Each Policy will be subscribed to the corresponding Method-Sig from the methodSigs array.

removePolicies()

function removePolicies(address consumer, bytes4[] calldata methodSigs, address[] calldata policies)

Callable only by the Firewall Admin of the Firewall Consumer, this method removes multiple policies from the list of subscribed policies for the given method signatures. Each Policy will be removed from the corresponding Method-Sig from the methodSigs array.

addGlobalPolicy()

function addGlobalPolicy(address consumer, address policy)

Callable only by the Firewall Admin of the Firewall Consumer, this method adds a Global Policy to the list of subscribed policies for the Firewall Consumer.

removeGlobalPolicy()

function removeGlobalPolicy(address consumer, uint policyIndex)

Callable only by the Firewall Admin of the Firewall Consumer, this method removes a Global Policy from the list of subscribed policies for the Firewall Consumer.

addGlobalPoliciesForConsumers()

function addGlobalPoliciesForConsumers(address[] consumers, address policy)

Callable only by the Firewall Admin of all the Firewall Consumers, this method adds a Global Policy to the list of subscribed policies for the all the Firewall Consumers.

removeGlobalPoliciesForConsumers()

function removeGlobalPoliciesForConsumers(address[] consumers, address policy)

Callable only by the Firewall Admin of all the Firewall Consumers, this method removes a Global Policy from a list of Firewall Consumers.

View Functions

getActivePolicies()

function getActivePolicies(address consumer, bytes4 methodSig) public returns (address[] memory)

Returns an array of all the policies a Firewall Consumer has subscribed to a method.

getActiveGloablPolicies()

function getActiveGloablPolicies(address consumer) public returns (address[] memory)

Returns an array of all the Global Policies a Firewall Consumer is subscribed to.

Source Code

On our GitHub repository: Firewall.sol

Last updated