MurePoolFactory
Inherits: Ownable, EIP712
Author: Mure
Factory contract for deploying applications as instances of the BeaconProxy
contract
within the Mure protocol.
Facilitates the secure and efficient deployment of upgradeable app contracts using the beacon proxy pattern. Implements the EIP-712 standard for signature validation and Ownable for access control. The factory contract relies on the MureConfig contract to verify EIP-712 signatures and manage the deployment process. Signatures are added with an expiry to enhance the security of the deployment process by ensuring that the provided signature is only valid within a certain time frame.
State Variables
beaconAddress
address public beaconAddress;
config
MureConfig public config;
DEPLOY_APP_HASH
Struct hash for validating app deployments
keccak256("Deployment(string appName,string version,AppMember[] appMembers,uint256 nonce,uint256 deadline,address caller,string data)AppMember(address member,uint8 role)")
bytes32 private constant DEPLOY_APP_HASH = 0xe78e92e91ab6665af572917421100be08c66583917c23ae7a02b72bed7edc218;
nonces
Nonce mapping for signatures to prevent replay
mapping(address => uint256) public nonces;
Functions
constructor
constructor(address beaconAddress_, address config_, string memory name_, string memory version_)
Ownable(msg.sender)
EIP712(name_, version_);
deployAppProxy
Deploys an instance of the beacon proxy.
Requires signature for authorization.
function deployAppProxy(
string calldata appName,
string calldata version,
AppMember[] calldata appMembers,
uint256 deadline,
string calldata data,
bytes calldata sig
) external returns (address proxy);
Parameters
Name | Type | Description |
---|---|---|
appName | string | name of the app contract instance |
version | string | of the app contract instance |
appMembers | AppMember[] | array of app members and their roles for the app contract instance |
deadline | uint256 | expiration time of the signature |
data | string | data to be emitted on creation |
sig | bytes | signature generated for the user |
setBeaconAddress
Sets the beacon address for future proxy creation.
Can only be called by the contract owner.
function setBeaconAddress(address beaconAddress_) external onlyOwner;
Parameters
Name | Type | Description |
---|---|---|
beaconAddress_ | address | new beacon address to be set |
_hash
Generates a hashed representation of the app name, version, members, deadline, along with the sender's nonce.
function _hash(
string calldata appName,
string calldata version,
AppMember[] calldata appMembers,
uint256 deadline,
string calldata data
) private view returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
appName | string | name of the app contract |
version | string | version of the app contract |
appMembers | AppMember[] | array of admin addresses and their corresponding roles for the app contract |
deadline | uint256 | expiry of the signature |
data | string | data to be emitted on creation |
_hashAppMembers
Computes the keccak256 hash of an array of AppMember structs.
function _hashAppMembers(AppMember[] calldata appMembers) private pure returns (bytes32);
Parameters
Name | Type | Description |
---|---|---|
appMembers | AppMember[] | The array of AppMember structs to be hashed. |
_extractAppRoles
Extracts and categorizes members into admins and operators based on their roles.
function _extractAppRoles(AppMember[] calldata appMembers) private pure returns (address[] memory, address[] memory);
Parameters
Name | Type | Description |
---|---|---|
appMembers | AppMember[] | An array of AppMember structs containing the member address and role. |
_validateAdminRoleExists
Validates that there is at least one member with the DEFAULT_ADMIN role in the provided appMembers array.
function _validateAdminRoleExists(AppMember[] calldata appMembers) private pure returns (bool);
Parameters
Name | Type | Description |
---|---|---|
appMembers | AppMember[] | An array of AppMember structs containing the member address and role. |
Events
Deployment
event Deployment(
string indexed appName, address[] appAdmins, address[] appOperators, address indexed appAddress, string data
);
BeaconUpdate
event BeaconUpdate(address indexed beaconAddress);