From 24f5a6cca5d8191fd61cdf0de2f5b245fd49cc39 Mon Sep 17 00:00:00 2001 From: benk10 Date: Thu, 24 Dec 2020 15:31:33 +0200 Subject: [PATCH] Add cl4rfactory (#814) --- .../ContinuousLocking4ReputationFactory.sol | 41 ++++++++++++ package-lock.json | 2 +- package.json | 2 +- test/continuouslocking4reputationfactory.js | 64 +++++++++++++++++++ 4 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 contracts/utils/ContinuousLocking4ReputationFactory.sol create mode 100644 test/continuouslocking4reputationfactory.js diff --git a/contracts/utils/ContinuousLocking4ReputationFactory.sol b/contracts/utils/ContinuousLocking4ReputationFactory.sol new file mode 100644 index 00000000..7389134b --- /dev/null +++ b/contracts/utils/ContinuousLocking4ReputationFactory.sol @@ -0,0 +1,41 @@ +pragma solidity 0.5.17; + +import "../schemes/ContinuousLocking4Reputation.sol"; + +/** + * @title ContinuousLocking4ReputationFactory + */ +contract ContinuousLocking4ReputationFactory { + + event NewCL4R(address continuousLocking4Reputation); + + function createCL4R( + Avatar _avatar, + uint256 _reputationReward, + uint256 _startTime, + uint256 _batchTime, + uint256 _redeemEnableTime, + uint256 _maxLockingBatches, + uint256 _repRewardConstA, + uint256 _repRewardConstB, + uint256 _batchesIndexCap, + IERC20 _token, + bytes32 _agreementHash) public returns(address) { + ContinuousLocking4Reputation continuousLocking4Reputation = new ContinuousLocking4Reputation(); + continuousLocking4Reputation.initialize( + _avatar, + _reputationReward, + _startTime, + _batchTime, + _redeemEnableTime, + _maxLockingBatches, + _repRewardConstA, + _repRewardConstB, + _batchesIndexCap, + _token, + _agreementHash + ); + emit NewCL4R(address(continuousLocking4Reputation)); + return address(continuousLocking4Reputation); + } +} diff --git a/package-lock.json b/package-lock.json index b9768144..92e76447 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.54", + "version": "0.0.1-rc.55", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index ac34acb5..1a08e1ca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@daostack/arc", - "version": "0.0.1-rc.54", + "version": "0.0.1-rc.55", "description": "A platform for building DAOs", "files": [ "contracts/", diff --git a/test/continuouslocking4reputationfactory.js b/test/continuouslocking4reputationfactory.js new file mode 100644 index 00000000..d87881fc --- /dev/null +++ b/test/continuouslocking4reputationfactory.js @@ -0,0 +1,64 @@ +const helpers = require('./helpers'); + +const ERC20Mock = artifacts.require('./test/ERC20Mock.sol'); +const ContinuousLocking4Reputation = artifacts.require('./ContinuousLocking4Reputation.sol'); +const ContinuousLocking4ReputationFactory = artifacts.require('./ContinuousLocking4ReputationFactory.sol'); + +const setup = async function () { + var testSetup = new helpers.TestSetup(); + testSetup.continuousLocking4ReputationFactory = await ContinuousLocking4ReputationFactory.new(); + return testSetup; +}; + +contract('competitionFactory', function(accounts) { + it('initialize', async () => { + let testSetup = await setup(); + testSetup.lockingToken = await ERC20Mock.new(accounts[0], web3.utils.toWei('100', "ether")); + testSetup.startTime = (await web3.eth.getBlock("latest")).timestamp; + testSetup.redeemEnableTime = (await web3.eth.getBlock("latest")).timestamp + (30*60*60); + testSetup.continuousLocking4Reputation = await ContinuousLocking4Reputation.new(); + testSetup.periodsUnit = (30*60*60); + testSetup.agreementHash = helpers.SOME_HASH; + testSetup.maxLockingPeriod = 12; + + testSetup.repRewardConstA = 85000; + testSetup.repRewardConstB = 900; + testSetup.reputationReward = 850000; + testSetup.periodsCap = 100; + let cl4rAddress = await testSetup.continuousLocking4ReputationFactory.createCL4R.call( + helpers.SOME_ADDRESS, + testSetup.reputationReward, + testSetup.startTime, + testSetup.periodsUnit, + testSetup.redeemEnableTime, + testSetup.maxLockingPeriod, + testSetup.repRewardConstA, + testSetup.repRewardConstB, + testSetup.periodsCap, + testSetup.lockingToken.address, + testSetup.agreementHash + ); + await testSetup.continuousLocking4ReputationFactory.createCL4R( + helpers.SOME_ADDRESS, + testSetup.reputationReward, + testSetup.startTime, + testSetup.periodsUnit, + testSetup.redeemEnableTime, + testSetup.maxLockingPeriod, + testSetup.repRewardConstA, + testSetup.repRewardConstB, + testSetup.periodsCap, + testSetup.lockingToken.address, + testSetup.agreementHash + ); + let continuousLocking4Reputation = await ContinuousLocking4Reputation.at(cl4rAddress); + assert.equal(await continuousLocking4Reputation.reputationRewardLeft(),testSetup.reputationReward); + assert.equal(await continuousLocking4Reputation.startTime(),testSetup.startTime); + assert.equal(await continuousLocking4Reputation.redeemEnableTime(),testSetup.redeemEnableTime); + assert.equal(await continuousLocking4Reputation.token(),testSetup.lockingToken.address); + assert.equal(await continuousLocking4Reputation.batchTime(),testSetup.periodsUnit); + assert.equal(await continuousLocking4Reputation.getAgreementHash(),testSetup.agreementHash); + assert.equal(await continuousLocking4Reputation.batchesIndexCap(),testSetup.periodsCap); + }); + +});