mirror of
https://github.com/tornadocash/tornado-pool-factory
synced 2024-02-02 15:04:08 +01:00
Merge remote-tracking branch 'origin/main' into fork-deploy-utils
This commit is contained in:
commit
36fb766248
@ -61,8 +61,8 @@ Check config.js for actual values.
|
|||||||
|
|
||||||
With `salt` = `0x0000000000000000000000000000000000000000000000000000000047941987` address must be:
|
With `salt` = `0x0000000000000000000000000000000000000000000000000000000047941987` address must be:
|
||||||
|
|
||||||
1. `MultipleInstanceFactory` - `0xdacb0a030Bcfc7163922d34092a822cC19D12d40`
|
1. `MultipleInstanceFactory` - `0x70A8e447E58480D68B56d88EF2C277Efe61e2b22`
|
||||||
2. `InstanceFactoryWithRegistry` - `0x6C1F437dFd70501Ad7f152897051446cc51F1eB6`
|
2. `InstanceFactoryWithRegistry` - `0xCAfb424689d3995c74a854e54cD24e2Be64C33D4`
|
||||||
|
|
||||||
Check addresses with current config:
|
Check addresses with current config:
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ contract InstanceFactory is Ownable {
|
|||||||
function createInstanceClone(uint256 _denomination, address _token) public virtual returns (address) {
|
function createInstanceClone(uint256 _denomination, address _token) public virtual returns (address) {
|
||||||
bytes32 salt = keccak256(abi.encodePacked(_denomination, _token));
|
bytes32 salt = keccak256(abi.encodePacked(_denomination, _token));
|
||||||
|
|
||||||
require(!implementation.predictDeterministicAddress(salt).isContract(), "Instance already exists");
|
address newClone = implementation.predictDeterministicAddress(salt);
|
||||||
|
if (!newClone.isContract()) {
|
||||||
address newClone = implementation.cloneDeterministic(salt);
|
implementation.cloneDeterministic(salt);
|
||||||
|
emit NewInstanceCloneCreated(newClone);
|
||||||
emit NewInstanceCloneCreated(newClone);
|
ERC20TornadoCloneable(newClone).init(_denomination, merkleTreeHeight, _token);
|
||||||
ERC20TornadoCloneable(newClone).init(_denomination, merkleTreeHeight, _token);
|
}
|
||||||
return newClone;
|
return newClone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,9 +17,11 @@ contract MultipleInstanceFactory is InstanceFactory {
|
|||||||
* @param _token address of ERC20 token for a new instance
|
* @param _token address of ERC20 token for a new instance
|
||||||
* @param _denominations list of denominations for each 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++) {
|
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.hasher()).to.be.equal(config.hasher)
|
||||||
expect(await instance.levels()).to.be.equal(config.merkleTreeHeight)
|
expect(await instance.levels()).to.be.equal(config.merkleTreeHeight)
|
||||||
expect(await instance.denomination()).to.equal(ethers.utils.parseEther('1000'))
|
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 () {
|
it('Should successfully add instances', async function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user