diff --git a/contracts/tge/HATAirdropFactory.sol b/contracts/tge/HATAirdropFactory.sol index f4afc8af..0f317617 100644 --- a/contracts/tge/HATAirdropFactory.sol +++ b/contracts/tge/HATAirdropFactory.sol @@ -10,9 +10,6 @@ import "./HATAirdrop.sol"; contract HATAirdropFactory is Ownable { using SafeERC20Upgradeable for IERC20Upgradeable; - address public implementation; - - event ImplementationUpdated(address indexed _newImplementation); event TokensWithdrawn(address indexed _owner, uint256 _amount); event HATAirdropCreated( address indexed _hatAirdrop, @@ -27,15 +24,6 @@ contract HATAirdropFactory is Ownable { ITokenLockFactory _tokenLockFactory ); - constructor (address _implementation) { - implementation = _implementation; - } - - function updateImplementation(address _newImplementation) external onlyOwner { - implementation = _newImplementation; - emit ImplementationUpdated(_newImplementation); - } - function withdrawTokens(IERC20Upgradeable _token, uint256 _amount) external onlyOwner { address owner = owner(); _token.safeTransfer(owner, _amount); @@ -43,6 +31,7 @@ contract HATAirdropFactory is Ownable { } function createHATAirdrop( + address _implementation, string memory _merkleTreeIPFSRef, bytes32 _root, uint256 _startTime, @@ -53,7 +42,7 @@ contract HATAirdropFactory is Ownable { IERC20Upgradeable _token, ITokenLockFactory _tokenLockFactory ) external onlyOwner returns (address result) { - result = Clones.cloneDeterministic(implementation, keccak256(abi.encodePacked( + result = Clones.cloneDeterministic(_implementation, keccak256(abi.encodePacked( _merkleTreeIPFSRef, _root, _startTime, @@ -92,6 +81,7 @@ contract HATAirdropFactory is Ownable { } function predictHATAirdropAddress( + address _implementation, string memory _merkleTreeIPFSRef, bytes32 _root, uint256 _startTime, @@ -101,7 +91,7 @@ contract HATAirdropFactory is Ownable { IERC20 _token, ITokenLockFactory _tokenLockFactory ) external view returns (address) { - return Clones.predictDeterministicAddress(implementation, keccak256(abi.encodePacked( + return Clones.predictDeterministicAddress(_implementation, keccak256(abi.encodePacked( _merkleTreeIPFSRef, _root, _startTime, diff --git a/docs/dodoc/tge/HATAirdropFactory.md b/docs/dodoc/tge/HATAirdropFactory.md index ee39fdde..72f2a72b 100644 --- a/docs/dodoc/tge/HATAirdropFactory.md +++ b/docs/dodoc/tge/HATAirdropFactory.md @@ -13,7 +13,7 @@ ### createHATAirdrop ```solidity -function createHATAirdrop(string _merkleTreeIPFSRef, bytes32 _root, uint256 _startTime, uint256 _deadline, uint256 _lockEndTime, uint256 _periods, uint256 _totalAmount, contract IERC20Upgradeable _token, contract ITokenLockFactory _tokenLockFactory) external nonpayable returns (address result) +function createHATAirdrop(address _implementation, string _merkleTreeIPFSRef, bytes32 _root, uint256 _startTime, uint256 _deadline, uint256 _lockEndTime, uint256 _periods, uint256 _totalAmount, contract IERC20Upgradeable _token, contract ITokenLockFactory _tokenLockFactory) external nonpayable returns (address result) ``` @@ -24,6 +24,7 @@ function createHATAirdrop(string _merkleTreeIPFSRef, bytes32 _root, uint256 _sta | Name | Type | Description | |---|---|---| +| _implementation | address | undefined | | _merkleTreeIPFSRef | string | undefined | | _root | bytes32 | undefined | | _startTime | uint256 | undefined | @@ -40,23 +41,6 @@ function createHATAirdrop(string _merkleTreeIPFSRef, bytes32 _root, uint256 _sta |---|---|---| | result | address | undefined | -### implementation - -```solidity -function implementation() external view returns (address) -``` - - - - - - -#### Returns - -| Name | Type | Description | -|---|---|---| -| _0 | address | undefined | - ### owner ```solidity @@ -77,7 +61,7 @@ function owner() external view returns (address) ### predictHATAirdropAddress ```solidity -function predictHATAirdropAddress(string _merkleTreeIPFSRef, bytes32 _root, uint256 _startTime, uint256 _deadline, uint256 _lockEndTime, uint256 _periods, contract IERC20 _token, contract ITokenLockFactory _tokenLockFactory) external view returns (address) +function predictHATAirdropAddress(address _implementation, string _merkleTreeIPFSRef, bytes32 _root, uint256 _startTime, uint256 _deadline, uint256 _lockEndTime, uint256 _periods, contract IERC20 _token, contract ITokenLockFactory _tokenLockFactory) external view returns (address) ``` @@ -88,6 +72,7 @@ function predictHATAirdropAddress(string _merkleTreeIPFSRef, bytes32 _root, uint | Name | Type | Description | |---|---|---| +| _implementation | address | undefined | | _merkleTreeIPFSRef | string | undefined | | _root | bytes32 | undefined | | _startTime | uint256 | undefined | @@ -130,22 +115,6 @@ function transferOwnership(address newOwner) external nonpayable |---|---|---| | newOwner | address | undefined | -### updateImplementation - -```solidity -function updateImplementation(address _newImplementation) external nonpayable -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newImplementation | address | undefined | - ### withdrawTokens ```solidity @@ -192,22 +161,6 @@ event HATAirdropCreated(address indexed _hatAirdrop, string _merkleTreeIPFSRef, | _token | contract IERC20Upgradeable | undefined | | _tokenLockFactory | contract ITokenLockFactory | undefined | -### ImplementationUpdated - -```solidity -event ImplementationUpdated(address indexed _newImplementation) -``` - - - - - -#### Parameters - -| Name | Type | Description | -|---|---|---| -| _newImplementation `indexed` | address | undefined | - ### OwnershipTransferred ```solidity diff --git a/test/tge/hatairdrop.js b/test/tge/hatairdrop.js index eba6b3e4..f22e7d0e 100644 --- a/test/tge/hatairdrop.js +++ b/test/tge/hatairdrop.js @@ -60,9 +60,10 @@ contract("HATAirdrop", (accounts) => { periods = 90; hatAirdropImplementation = await HATAirdrop.new(); - hatAirdropFactory = await HATAirdropFactory.new(hatAirdropImplementation.address); + hatAirdropFactory = await HATAirdropFactory.new(); let airdropAddress = await hatAirdropFactory.predictHATAirdropAddress( + hatAirdropImplementation.address, "QmSUXfYsk9HgrMBa7tgp3MBm8FGwDF9hnVaR9C1PMoFdS3", merkleTree.getHexRoot(), startTime, @@ -74,6 +75,7 @@ contract("HATAirdrop", (accounts) => { ); let tx = await hatAirdropFactory.createHATAirdrop( + hatAirdropImplementation.address, "QmSUXfYsk9HgrMBa7tgp3MBm8FGwDF9hnVaR9C1PMoFdS3", merkleTree.getHexRoot(), startTime, @@ -101,31 +103,12 @@ contract("HATAirdrop", (accounts) => { await token.mint(hatAirdropFactory.address, totalAmount); } - it("Update implementation", async () => { - await setupHATAirdrop(); - - await assertFunctionRaisesException( - hatAirdropFactory.updateImplementation( - accounts[3], - { from: accounts[1] } - ), - "Ownable: caller is not the owner" - ); - - assert.equal(await hatAirdropFactory.implementation(), hatAirdropImplementation.address); - - let tx = await hatAirdropFactory.updateImplementation(accounts[3]); - assert.equal(tx.logs[0].event, "ImplementationUpdated"); - assert.equal(tx.logs[0].args._newImplementation, accounts[3]); - - assert.equal(await hatAirdropFactory.implementation(), accounts[3]); - }); - it("Only owner can create airdrops", async () => { await setupHATAirdrop(); await assertFunctionRaisesException( hatAirdropFactory.createHATAirdrop( + hatAirdropImplementation.address, "QmSUXfYsk9HgrMBa7tgp3MBm8FGwDF9hnVaR9C1PMoFdS3", merkleTree.getHexRoot(), startTime,