forked from jbx-protocol/juice-contracts-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: JBDirectory controller whitelist (jbx-protocol#37)
* Initial implementation, no tests * Whoops * feat: whitelist mapping * gitignore update: vscode * wip: override needs to be in knownControllers * fix: changed isKnownController in IJBDirectory * Fix: I swear I compiled it * WIP: Review access logic for setControllerOf(...) * feat: override in setControllerOf(...) * feat: isKnownController in test for 100% coverage * fix: unused var * fix: test wording * Feat: setControllerAllowList * wip * feat: allowedToSetController+tests * Update .gitignore * fix: review comment implem * Fix: camel case + other format Co-authored-by: Exekias <[email protected]>
- Loading branch information
1 parent
e065870
commit 81654c5
Showing
12 changed files
with
302 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,7 @@ deployments/localhost/** | |
coverage/ | ||
coverage.json | ||
|
||
*.txt | ||
*.txt | ||
|
||
# VSCode | ||
workspace.code-workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { expect } from 'chai'; | ||
import { ethers } from 'hardhat'; | ||
|
||
import { deployMockContract } from '@ethereum-waffle/mock-contract'; | ||
|
||
import jbController from '../../artifacts/contracts/interfaces/IJBController.sol/IJBController.json'; | ||
import jbOperatoreStore from '../../artifacts/contracts/JBOperatorStore.sol/JBOperatorStore.json'; | ||
import jbProjects from '../../artifacts/contracts/JBProjects.sol/JBProjects.json'; | ||
|
||
describe('JBDirectory::addToSetControllerAllowlist(...)', function () { | ||
|
||
async function setup() { | ||
let [deployer, ...addrs] = await ethers.getSigners(); | ||
|
||
let mockJbOperatorStore = await deployMockContract(deployer, jbOperatoreStore.abi); | ||
let mockJbProjects = await deployMockContract(deployer, jbProjects.abi); | ||
let mockJbController = await deployMockContract(deployer, jbController.abi); | ||
|
||
let jbDirectoryFactory = await ethers.getContractFactory('JBDirectory'); | ||
let jbDirectory = await jbDirectoryFactory.deploy( | ||
mockJbOperatorStore.address, | ||
mockJbProjects.address, | ||
); | ||
|
||
return { | ||
deployer, | ||
addrs, | ||
jbDirectory, | ||
mockJbController | ||
}; | ||
} | ||
|
||
it('Should add known controller and emit events if caller is JBDirectory owner', async function () { | ||
const { deployer, jbDirectory, mockJbController } = await setup(); | ||
|
||
await expect( | ||
jbDirectory.connect(deployer).addToSetControllerAllowlist(mockJbController.address) | ||
).to.emit(jbDirectory, 'AddToSetControllerAllowlist') | ||
.withArgs(mockJbController.address, deployer.address); | ||
|
||
expect( | ||
await jbDirectory.isAllowedToSetController(mockJbController.address) | ||
).to.be.true; | ||
}); | ||
|
||
it('Can\'t add known controller if caller is not JBDirectory owner', async function () { | ||
const { addrs, jbDirectory, mockJbController } = await setup(); | ||
|
||
await expect( | ||
jbDirectory.connect(addrs[0]).addToSetControllerAllowlist(mockJbController.address) | ||
).to.revertedWith('Ownable: caller is not the owner'); | ||
}); | ||
|
||
it('Can\'t add the same known controller twice', async function () { | ||
const { deployer, jbDirectory, mockJbController } = await setup(); | ||
|
||
await jbDirectory.connect(deployer).addToSetControllerAllowlist(mockJbController.address) | ||
|
||
await expect( | ||
jbDirectory.connect(deployer).addToSetControllerAllowlist(mockJbController.address) | ||
).to.revertedWith('0x30: ALREADY_ADDED'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.