mirror of
https://github.com/tornadocash/tornado-pool-factory
synced 2024-02-02 15:04:08 +01:00
add return list of inst to createInstanceClones()
This commit is contained in:
parent
2137981a3d
commit
dd4e78b6bd
@ -61,8 +61,8 @@ Check config.js for actual values.
|
||||
|
||||
With `salt` = `0x0000000000000000000000000000000000000000000000000000000047941987` address must be:
|
||||
|
||||
1. `MultipleInstanceFactory` - `0xdacb0a030Bcfc7163922d34092a822cC19D12d40`
|
||||
2. `InstanceFactoryWithRegistry` - `0x6C1F437dFd70501Ad7f152897051446cc51F1eB6`
|
||||
1. `MultipleInstanceFactory` - `0x70A8e447E58480D68B56d88EF2C277Efe61e2b22`
|
||||
2. `InstanceFactoryWithRegistry` - `0xCAfb424689d3995c74a854e54cD24e2Be64C33D4`
|
||||
|
||||
Check addresses with current config:
|
||||
|
||||
|
@ -45,12 +45,12 @@ contract InstanceFactory is Ownable {
|
||||
function createInstanceClone(uint256 _denomination, address _token) public virtual returns (address) {
|
||||
bytes32 salt = keccak256(abi.encodePacked(_denomination, _token));
|
||||
|
||||
require(!implementation.predictDeterministicAddress(salt).isContract(), "Instance already exists");
|
||||
|
||||
address newClone = implementation.cloneDeterministic(salt);
|
||||
|
||||
emit NewInstanceCloneCreated(newClone);
|
||||
ERC20TornadoCloneable(newClone).init(_denomination, merkleTreeHeight, _token);
|
||||
address newClone = implementation.predictDeterministicAddress(salt);
|
||||
if (!newClone.isContract()) {
|
||||
implementation.cloneDeterministic(salt);
|
||||
emit NewInstanceCloneCreated(newClone);
|
||||
ERC20TornadoCloneable(newClone).init(_denomination, merkleTreeHeight, _token);
|
||||
}
|
||||
return newClone;
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,11 @@ contract MultipleInstanceFactory is InstanceFactory {
|
||||
* @param _token address of ERC20 token for a new instance
|
||||
* @param _denominations list of denominations for each new instance
|
||||
*/
|
||||
function createInstanceClones(address _token, uint256[] memory _denominations) external {
|
||||
function createInstanceClones(address _token, uint256[] memory _denominations) external returns (address[] memory) {
|
||||
address[] memory newClones = new address[](_denominations.length);
|
||||
for (uint256 i = 0; i < _denominations.length; i++) {
|
||||
createInstanceClone(_denominations[i], _token);
|
||||
newClones[i] = createInstanceClone(_denominations[i], _token);
|
||||
}
|
||||
return newClones;
|
||||
}
|
||||
}
|
||||
|
@ -110,6 +110,13 @@ describe('Multiple Instance Factory Tests', () => {
|
||||
expect(await instance.hasher()).to.be.equal(config.hasher)
|
||||
expect(await instance.levels()).to.be.equal(config.merkleTreeHeight)
|
||||
expect(await instance.denomination()).to.equal(ethers.utils.parseEther('1000'))
|
||||
|
||||
// try to deploy the same instance again
|
||||
await instanceFactory.connect(sender).createInstanceClone(ethers.utils.parseEther('1000'), config.COMP)
|
||||
|
||||
// check that instance has not been created - no new NewInstanceCloneCreated event
|
||||
let curLogs = await instanceFactory.queryFilter('NewInstanceCloneCreated')
|
||||
expect(curLogs.length).to.be.equal(logs.length)
|
||||
})
|
||||
|
||||
it('Should successfully add instances', async function () {
|
||||
|
Loading…
Reference in New Issue
Block a user