Skip to content

Commit

Permalink
Merge pull request #191 from xuhcc/recipient-registry-reuse
Browse files Browse the repository at this point in the history
Contracts: Don't control recipient registry limit from funding round factory
  • Loading branch information
xuhcc authored Nov 16, 2020
2 parents 75cd3f1 + cdef94d commit e50d7bd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
5 changes: 0 additions & 5 deletions contracts/contracts/FundingRoundFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ contract FundingRoundFactory is Ownable, MACISharedObjs {
maciFactory = _maciFactory;
verifiedUserRegistry = _verifiedUserRegistry;
recipientRegistry = _recipientRegistry;
recipientRegistry.setController();
(,, uint256 maxVoteOptions) = maciFactory.maxValues();
recipientRegistry.setMaxRecipients(maxVoteOptions);
}

/**
Expand Down Expand Up @@ -98,8 +95,6 @@ contract FundingRoundFactory is Ownable, MACISharedObjs {
_signUpDuration,
_votingDuration
);
(,, uint256 maxVoteOptions) = maciFactory.maxValues();
recipientRegistry.setMaxRecipients(maxVoteOptions);
}

/**
Expand Down
2 changes: 2 additions & 0 deletions contracts/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ describe('End-to-end Tests', function () {
verifiedUserRegistry = await SimpleUserRegistry.deploy()
const SimpleRecipientRegistry = await ethers.getContractFactory('SimpleRecipientRegistry', deployer)
recipientRegistry = await SimpleRecipientRegistry.deploy()
await recipientRegistry.setController()
await recipientRegistry.setMaxRecipients(24)
const FundingRoundFactory = await ethers.getContractFactory('FundingRoundFactory', deployer)
fundingRoundFactory = await FundingRoundFactory.deploy(
maciFactory.address,
Expand Down
2 changes: 2 additions & 0 deletions contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ async function main() {
deployer,
)
const recipientRegistry = await SimpleRecipientRegistry.deploy()
await recipientRegistry.setController()
await recipientRegistry.setMaxRecipients(24)

const FundingRoundFactory = await ethers.getContractFactory(
'FundingRoundFactory',
Expand Down
2 changes: 1 addition & 1 deletion contracts/scripts/deployTestRound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import MACIFactoryArtifact from '../build/contracts/MACIFactory.json'
async function main() {
// We're hardcoding factory address due to a buidler limitation:
// https://github.com/nomiclabs/buidler/issues/651
const factoryAddress = '0x1A1FEe7EeD918BD762173e4dc5EfDB8a78C924A8'
const factoryAddress = '0xc4905364b78a742ccce7B890A89514061E47068D'
const [
deployer,
coordinator,
Expand Down
8 changes: 5 additions & 3 deletions contracts/tests/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ describe('Funding Round Factory', () => {

const SimpleRecipientRegistry = await ethers.getContractFactory('SimpleRecipientRegistry', deployer)
recipientRegistry = await SimpleRecipientRegistry.deploy()
await recipientRegistry.setController()
await recipientRegistry.setMaxRecipients(24)

const FundingRoundFactory = await ethers.getContractFactory('FundingRoundFactory', deployer)
factory = await FundingRoundFactory.deploy(
Expand All @@ -58,7 +60,7 @@ describe('Funding Round Factory', () => {
expect(await factory.nativeToken()).to.equal(ZERO_ADDRESS)
expect(await factory.maciFactory()).to.equal(maciFactory.address)
expect(await factory.recipientRegistry()).to.equal(recipientRegistry.address)
expect(await recipientRegistry.controller()).to.equal(factory.address)
expect(await recipientRegistry.controller()).to.equal(deployer.address)
expect(await recipientRegistry.maxRecipients())
.to.equal(5 ** maciParameters.voteOptionTreeDepth - 1)
})
Expand Down Expand Up @@ -118,8 +120,8 @@ describe('Funding Round Factory', () => {
maciParameters.update({ voteOptionTreeDepth: 3 })
await expect(factory.setMaciParameters(...maciParameters.values()))
.to.emit(maciFactory, 'MaciParametersChanged')
expect(await recipientRegistry.maxRecipients())
.to.equal(5 ** maciParameters.voteOptionTreeDepth - 1)
const treeDepths = await maciFactory.treeDepths()
expect(treeDepths.voteOptionTreeDepth).to.equal(3)
});

it('allows only owner to set MACI parameters', async () => {
Expand Down
2 changes: 1 addition & 1 deletion vue-app/.env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VUE_APP_ETHEREUM_API_URL=http://localhost:18545
VUE_APP_BLOCK_EXPLORER=https://etherscan.io/tx/
VUE_APP_IPFS_GATEWAY_URL=https://ipfs.io/ipfs/
VUE_APP_CLRFUND_FACTORY_ADDRESS=0x1A1FEe7EeD918BD762173e4dc5EfDB8a78C924A8
VUE_APP_CLRFUND_FACTORY_ADDRESS=0xc4905364b78a742ccce7B890A89514061E47068D
VUE_APP_USER_REGISTRY_TYPE=simple

0 comments on commit e50d7bd

Please sign in to comment.