RuleProcessorDiamondLib
Author: @oscarsernarosero, built on top of Nick Mudge implementation.
Contract serves as library for the Processor Diamond
Library contract of the diamond pattern. Responsible for checking on rules compliance.
State Variables
DIAMOND_CUT_STORAGE
RULE_DATA_POSITION
Functions
s
Function for position of facets and their selectors. Every facet has its own storage.
Returns
Name | Type | Description |
---|---|---|
ds | RuleProcessorDiamondStorage | Data storage for Rule Processor Facet Storage |
ruleDataStorage
Function to store rules
Returns
Name | Type | Description |
---|---|---|
ds | RuleDataStorage | Data Storage of Rule Data Storage |
diamondCut
Internal function version of _diamondCut
Parameters
Name | Type | Description |
---|---|---|
_diamondCut | FacetCut[] | Facets Array |
init | address | Address of the contract or facet to execute “data” |
data | bytes | A function call, including function selector and arguments calldata is executed with delegatecall on “init” |
addFunctions
Add Function to Diamond
Parameters
Name | Type | Description |
---|---|---|
_facetAddress | address | Address of Facet |
_functionSelectors | bytes4[] | Signature array of function selectors |
replaceFunctions
Replace Function from Diamond
Parameters
Name | Type | Description |
---|---|---|
_facetAddress | address | Address of Facet |
_functionSelectors | bytes4[] | Signature array of function selectors |
removeFunctions
can’t replace immutable functions — functions defined directly in the diamond in this case replace old facet address
Remove Function from Diamond
Parameters
Name | Type | Description |
---|---|---|
_facetAddress | address | Address of Facet |
_functionSelectors | bytes4[] | Signature array of function selectors |
initializeDiamondCut
can’t remove immutable functions — functions defined directly in the diamond replace selector with last selector delete last selector
Initialize Diamond Cut of new Facet
Parameters
Name | Type | Description |
---|---|---|
init | address | The address of the contract or facet to execute “data” |
data | bytes | A function call, including function selector and arguments calldata is executed with delegatecall on “init” |
enforceHasContractCode
Internal function to enforce contract has code
Parameters
Name | Type | Description |
---|---|---|
_contract | address | The address of the contract be checked or enforced |
_errorMessage | string | Error for contract with non matching co |