From fbd0dffe28d159e1188f8705e37b0133da5ce1e7 Mon Sep 17 00:00:00 2001 From: Makoto Inoue <2630+makoto@users.noreply.github.com> Date: Thu, 18 Jun 2020 14:19:01 +0100 Subject: [PATCH 1/2] set clearFee on Deployer --- contracts/Deployer.sol | 19 ++++++++++++------- migrations/2_deploy_contracts.js | 5 ++--- package.json | 2 +- test/deployer.js | 30 +++++++++++++++++++++++------- 4 files changed, 38 insertions(+), 18 deletions(-) diff --git a/contracts/Deployer.sol b/contracts/Deployer.sol index 05734e0..9e192f4 100644 --- a/contracts/Deployer.sol +++ b/contracts/Deployer.sol @@ -1,5 +1,6 @@ pragma solidity ^0.5.11; +import './GroupAdmin.sol'; import './zeppelin/lifecycle/Destructible.sol'; import './DeployerInterface.sol'; @@ -7,13 +8,14 @@ import './DeployerInterface.sol'; * This is responsible for deploying a new Party. */ -contract Deployer is Destructible { +contract Deployer is Destructible, GroupAdmin { DeployerInterface ethDeployer; DeployerInterface erc20Deployer; - - constructor(address _ethDeployer, address _erc20Deployer) public { + uint public clearFee; + constructor(address _ethDeployer, address _erc20Deployer, uint _clearFee) public { ethDeployer = DeployerInterface(_ethDeployer); erc20Deployer = DeployerInterface(_erc20Deployer); + clearFee = _clearFee; } /** * Notify that a new party has been deployed. @@ -23,6 +25,10 @@ contract Deployer is Destructible { address indexed deployer ); + function changeClearFee(uint _clearFee) external onlyAdmin { + clearFee = _clearFee; + } + /** * Deploy a new contract. * @param _name The name of the event @@ -36,8 +42,7 @@ contract Deployer is Destructible { uint256 _deposit, uint _limitOfParticipants, uint _coolingPeriod, - address _tokenAddress, - uint256 _clearFee + address _tokenAddress ) external { Conference c; if(_tokenAddress != address(0)){ @@ -48,7 +53,7 @@ contract Deployer is Destructible { _coolingPeriod, msg.sender, _tokenAddress, - _clearFee + clearFee ); }else{ c = ethDeployer.deploy( @@ -58,7 +63,7 @@ contract Deployer is Destructible { _coolingPeriod, msg.sender, address(0), - _clearFee + clearFee ); } emit NewParty(address(c), msg.sender); diff --git a/migrations/2_deploy_contracts.js b/migrations/2_deploy_contracts.js index 71606e4..f65ff74 100644 --- a/migrations/2_deploy_contracts.js +++ b/migrations/2_deploy_contracts.js @@ -14,8 +14,8 @@ let config = {}; let token; let name = ''; // empty name falls back to the contract default let deposit = 0; // 0 falls back to the contract default -let tld = 'eth'; let limitOfParticipants = 0; // 0 falls back to the contract default +let clearFee = 50; // 5% const emptyAddress = '0x0000000000000000000000000000000000000000'; // eg: truffle migrate --config '{"name":"CodeUp No..", "limitOfParticipants":15}' if (yargs.argv.config) { @@ -27,7 +27,6 @@ module.exports = function(deployer) { if (config.name){ name = config.name; } - if (config.limitOfParticipants){ limitOfParticipants = config.limitOfParticipants; } @@ -43,7 +42,7 @@ module.exports = function(deployer) { const erc20Deployer = await ERC20Deployer.deployed(); await deployer.deploy(Deployer, ethDeployer.address, erc20Deployer.address); const mainDeployer = await Deployer.deployed(); - console.log([name, deposit,limitOfParticipants, coolingPeriod].join(',')); + console.log([name, deposit,limitOfParticipants, coolingPeriod, clearFee].join(',')); if(deployer.network == 'docker' || deployer.network == 'development'){ console.log('deploying a party', {name, deposit,limitOfParticipants, coolingPeriod, emptyAddress}) await mainDeployer.deploy(name, deposit,limitOfParticipants, coolingPeriod, emptyAddress); diff --git a/package.json b/package.json index 9dfcb9a..8d06eb7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wearekickback/contracts-integration", - "version": "1.3.3", + "version": "1.3.4", "description": "Kickback smart contracts", "main": "index.js", "publishConfig": { diff --git a/test/deployer.js b/test/deployer.js index 3f72425..9a0dd56 100644 --- a/test/deployer.js +++ b/test/deployer.js @@ -12,10 +12,15 @@ contract('Deployer', accounts => { let deployer, ethDeployer, erc20Deployer; let emptyAddress = '0x0000000000000000000000000000000000000000' let clearFee = 10 + let newFee = 100 beforeEach(async () => { ethDeployer = await EthDeployer.new(); erc20Deployer = await ERC20Deployer.new(); - deployer = await Deployer.new(ethDeployer.address, erc20Deployer.address) + deployer = await Deployer.new( + ethDeployer.address, + erc20Deployer.address, + clearFee + ) }) it('does not accept ETH', async () => { @@ -34,14 +39,27 @@ contract('Deployer', accounts => { await Deployer.at(address).should.be.rejected }) + it('can set clearFee', async() => { + await deployer.clearFee().should.eventually.eq(clearFee) + await deployer.changeClearFee(newFee, { from: accounts[0]}) + await deployer.clearFee().should.eventually.eq(newFee) + }) + + it('can set admins', async() => { + await deployer.changeClearFee(newFee, { from: accounts[1]}).should.be.rejected + await deployer.clearFee().should.eventually.eq(clearFee) + await deployer.grant([accounts[1]], { from: accounts[0]}) + await deployer.changeClearFee(newFee, { from: accounts[1]}).should.be.fulfilled + await deployer.clearFee().should.eventually.eq(newFee) + }) + it('can deploy a EthConference', async () => { const result = await deployer.deploy( 'test', toHex(toWei('0.02')), toHex(2), toHex(60 * 60 * 24 * 7), - emptyAddress, - clearFee + emptyAddress ) const events = await getEvents(result, 'NewParty') @@ -66,8 +84,7 @@ contract('Deployer', accounts => { toHex(10), toHex(2), toHex(60 * 60 * 24 * 7), - token.address, - clearFee + token.address ) const events = await getEvents(result, 'NewParty') @@ -93,8 +110,7 @@ contract('Deployer', accounts => { toHex(toWei('0.02')), toHex(2), toHex(60 * 60 * 24 * 7), - emptyAddress, - clearFee + emptyAddress ) const [ { args: { deployedAddress} } ] = (await getEvents(result, 'NewParty')) From 3467e5727d938bec7191bc644f574afbd6f8ef85 Mon Sep 17 00:00:00 2001 From: Makoto Inoue <2630+makoto@users.noreply.github.com> Date: Thu, 18 Jun 2020 16:45:20 +0100 Subject: [PATCH 2/2] Upgrade truffle --- package.json | 4 ++-- yarn.lock | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 8d06eb7..1564a1c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@wearekickback/contracts-integration", - "version": "1.3.4", + "version": "1.3.5", "description": "Kickback smart contracts", "main": "index.js", "publishConfig": { @@ -72,7 +72,7 @@ "solgraph": "^0.3.2", "solhint": "^2.0.0", "solidity-coverage": "^0.6.4", - "truffle": "^5.1.0", + "truffle": "^5.1.30", "truffle-hdwallet-provider": "^1.0.0-web3one.0", "truffle-plugin-verify": "^0.3.3", "uuid": "^3.0.1", diff --git a/yarn.lock b/yarn.lock index 1181590..f93b242 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8223,10 +8223,10 @@ truffle-plugin-verify@^0.3.3: querystring "^0.2.0" sol-merger "^1.1.0" -truffle@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/truffle/-/truffle-5.1.0.tgz#670d6791a2a97c6bf852d28a978e6635fe3c883a" - integrity sha512-RKij9cFhHeAb8HuP8D/llpcbe+k40fg8Q2SAeR+mkvlz9tid/opYkrWs9XN8eRQKCC0SSygrKBZLG3CMsNbXwQ== +truffle@^5.1.30: + version "5.1.30" + resolved "https://registry.yarnpkg.com/truffle/-/truffle-5.1.30.tgz#93d8fadfaf9ae58c05081569a026676d5f425364" + integrity sha512-wA88Ija0qO3ggzIEFMydg7FfxRqNRbYq1WVmb9Mdvx1D416RojRBotdML7KPH6T5lE6UKK8UeTalDTdG2KKqeQ== dependencies: app-module-path "^2.2.0" mocha "5.2.0"