Capacitors need to be deployed for each new Switchboard.
A Factory should be created that deploys the capacitors based on given type and returns the addresses.
Socket is expected to call this Factory each time new Switchboard is being registered.
All capacitors, decapacitors should follow the same interface so that socket can interact with them.
New Capacitor types can be introduced in future by changing CapacitorFactory.
Factory should be able to deploy different capacitors based on specified sibling chain.
Decapacitors can be reused since they are stateless. This can be done in later iteration.
function deploy(
uint256 type,
uint256 siblingChainSlug
) external returns (ICapacitor, IDecapacitor) {
if (type == 1) {
return (new SingleCapacitor(msg.sender), new SingleDecapacitor());
}
if (type == 2) {
return (new HashChainCapacitor(msg.sender), new HashChainDecapacitor());
}
if (type == 1) {
return (new MerkleCapacitor(msg.sender), new MerkleDecapacitor());
}
}