-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore - add tinlake 0.3.0 audit report (#481) * chore - add assessor admin contract (#483) * chore: add assessor admin fab (#484)
- Loading branch information
1 parent
353c437
commit fc1f8e2
Showing
7 changed files
with
168 additions
and
4 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (C) 2020 Centrifuge | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity >=0.5.15 <0.6.0; | ||
|
||
import "tinlake-auth/auth.sol"; | ||
|
||
interface AssessorLike { | ||
function file(bytes32 name, uint value) external; | ||
} | ||
|
||
// Wrapper contract for permission restriction on the assessor. | ||
// This contract ensures that only the maxReserve size of the pool can be set | ||
contract AssessorAdmin is Auth { | ||
AssessorLike public assessor; | ||
constructor() public { | ||
wards[msg.sender] = 1; | ||
} | ||
|
||
function depend(bytes32 contractName, address addr) public auth { | ||
if (contractName == "assessor") { | ||
assessor = AssessorLike(addr); | ||
} else revert(); | ||
} | ||
|
||
function setMaxReserve(uint value) public auth { | ||
assessor.file("maxReserve", value); | ||
} | ||
} |
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,29 @@ | ||
// Copyright (C) 2020 Centrifuge | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity >=0.5.15 <0.6.0; | ||
|
||
import { AssessorAdmin } from "./../admin/assessor.sol"; | ||
|
||
contract AssessorAdminFab { | ||
function newAssessorAdmin() public returns (address assessorAdmin) { | ||
AssessorAdmin assessorAdmin = new AssessorAdmin(); | ||
|
||
assessorAdmin.rely(msg.sender); | ||
assessorAdmin.deny(address(this)); | ||
|
||
return address(assessorAdmin); | ||
} | ||
} |
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,62 @@ | ||
// Copyright (C) 2020 Centrifuge | ||
|
||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
pragma solidity >=0.5.15 <0.6.0; | ||
|
||
import "ds-test/test.sol"; | ||
|
||
import "./../assessor.sol"; | ||
import "./../admin/assessor.sol"; | ||
|
||
|
||
contract AssessorAdminTest is DSTest { | ||
|
||
Assessor assessor; | ||
AssessorAdmin assessorAdmin; | ||
|
||
address assessor_; | ||
address assessorAdmin_; | ||
|
||
function setUp() public { | ||
assessor = new Assessor(); | ||
assessorAdmin = new AssessorAdmin(); | ||
|
||
assessor_ = address(assessor); | ||
assessorAdmin_ = address(assessorAdmin); | ||
assessorAdmin.depend("assessor", assessor_); | ||
} | ||
|
||
function callMaxReserve() public { | ||
uint maxReserve = 150 ether; | ||
|
||
// call setMaxReserve | ||
assessorAdmin.setMaxReserve(maxReserve); | ||
|
||
// assert maxReserve value was set | ||
assertEq(assessor.maxReserve(), maxReserve); | ||
} | ||
|
||
function testSetMaxReserve() public { | ||
// rely assessorAdmin on assessor | ||
assessor.rely(assessorAdmin_); | ||
callMaxReserve(); | ||
} | ||
|
||
function testFailSetMaxReserveNoPermissions() public { | ||
// do not rely assessorAdmin on assessor | ||
callMaxReserve(); | ||
} | ||
} | ||
|
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