Skip to content

Commit

Permalink
Allow to change flap and flop addresses in the vow
Browse files Browse the repository at this point in the history
  • Loading branch information
gbalabasquer authored Nov 7, 2019
1 parent 0c0ac5a commit 6fd7de0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/test/vow.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,26 @@ contract VowTest is DSTest {
vow.heal(rad(wad));
}

function test_change_flap_flop() public {
Flap newFlap = new Flap(address(vat), address(gov));
Flop newFlop = new Flop(address(vat), address(gov));

newFlap.rely(address(vow));
newFlop.rely(address(vow));

assertEq(vat.can(address(vow), address(flap)), 1);
assertEq(vat.can(address(vow), address(newFlap)), 0);

vow.file('flapper', address(newFlap));
vow.file('flopper', address(newFlop));

assertEq(address(vow.flapper()), address(newFlap));
assertEq(address(vow.flopper()), address(newFlop));

assertEq(vat.can(address(vow), address(flap)), 0);
assertEq(vat.can(address(vow), address(newFlap)), 1);
}

function test_flog_wait() public {
assertEq(vow.wait(), 0);
vow.file('wait', uint(100 seconds));
Expand Down
11 changes: 11 additions & 0 deletions src/vow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ contract VatLike {
function sin (address) external view returns (uint);
function heal(uint256) external;
function hope(address) external;
function nope(address) external;
}

contract Vow is LibNote {
Expand Down Expand Up @@ -97,6 +98,16 @@ contract Vow is LibNote {
else revert("Vow/file-unrecognized-param");
}

function file(bytes32 what, address data) external note auth {
if (what == "flapper") {
vat.nope(address(flapper));
flapper = FlapLike(data);
vat.hope(data);
}
else if (what == "flopper") flopper = FlopLike(data);
else revert("Vow/file-unrecognized-param");
}

// Push to debt-queue
function fess(uint tab) external note auth {
sin[now] = add(sin[now], tab);
Expand Down

0 comments on commit 6fd7de0

Please sign in to comment.