Add Natspec and remove clone address array and getter
Removing the array cuts cost on deposit init
We now rely entirely on events
@@ -3,22 +3,35 @@ pragma solidity ^0.4.25;
import "./CloneFactory.sol";
import "../deposit/Deposit.sol";
+
+// We avoid redeployment of deposit contract by using the cloneFactory.
+// Proxy delegates calls to Deposit and therefore does not effect deposit state
+// This means that we only need to deploy the deposit contracts once.
+// The factory provides clean state for every new deposit clone.
+
contract DepositFactory is CloneFactory{
// holds the address of the deposit contract
address public implementation;
- //holds list of all clones for easy access
- address[] public cloneContracts;
-
event DepositCloneCreated(address clonedContract);
- //we set the deposit address on contract initialization
+ /// @dev Set the deposit address on contract initialization
+ /// @param _implementation The address of the deployed Deposit contract
constructor(address _implementation) public {
implementation = _implementation;
}
- //creates a deposit clone, calls deposit `init` method
+ /// @notice Creates a new deposit instance
+ /// @dev Calls createNewDeposit from deposit contract as init method. We don't offer pure createClone,
+ /// meaning that the only way to create a clone is by also calling createNewDeposit()
+ /// Deposits created this way will never pass by state 0 (START)
+ /// @param _TBTCSystem Address of system contract
+ /// @param _TBTCToken Address of Token contract
+ /// @param _KeepBridge Address of Keep contract
+ /// @param _m m for m-of-n
+ /// @param _n n for m-of-n
+ /// @return True if successful, otherwise revert
function createDeposit (
address _TBTCSystem,
address _TBTCToken,
@@ -27,25 +40,9 @@ contract DepositFactory is CloneFactory{
uint256 _n
) public {
- //Note 1: we don't offer pure createClone.
- //This means the only way to create a clone is by also calling the deposit init function
- //Deposits created this way will never pass by state 0 (START)
-
- //Note 2: we can avoid using the cloneContract array by listening to events
- //This will forgo the cost asociated with writing to storage, but keeping it for testing temporarily.
-
address clone = createClone(implementation);
Deposit(clone).createNewDeposit(_TBTCSystem, _TBTCToken, _KeepBridge, _m, _n);
emit DepositCloneCreated(clone);
-
- //store clone address so we can access later
- cloneContracts.push(clone);
- }
-
- //retreive clone address from array using index
- function getAddress(uint _index) public view returns (address) {
- require(_index < cloneContracts.length, "index out of bounds");
- return cloneContracts[_index];
}
}
\ No newline at end of file
