Skip to content

Commit

Permalink
Add cl4rfactory (#814)
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-kaufman authored Dec 24, 2020
1 parent a5d4dc7 commit 24f5a6c
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 2 deletions.
41 changes: 41 additions & 0 deletions contracts/utils/ContinuousLocking4ReputationFactory.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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/",
Expand Down
64 changes: 64 additions & 0 deletions test/continuouslocking4reputationfactory.js
Original file line number Diff line number Diff line change
@@ -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);
});

});

0 comments on commit 24f5a6c

Please sign in to comment.