Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "lib/fvm-solidity"]
path = lib/fvm-solidity
url = https://github.com/filecoin-project/fvm-solidity
[submodule "lib/safe-smart-account"]
path = lib/safe-smart-account
url = https://github.com/safe-fndn/safe-smart-account
6 changes: 0 additions & 6 deletions foundry.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,5 @@
},
"lib/fvm-solidity": {
"rev": "ea1fe65367d7539236be111916a6e2781bcf7a1b"
},
"lib/safe-smart-account": {
"tag": {
"name": "v1.5.0",
"rev": "77901a5a1ad835b74ad3b72f73a8412cfe491c57"
}
}
}
1 change: 0 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ bytecode_hash = "none"
remappings = [
'forge-std/=lib/forge-std/src/',
'fvm-solidity/=lib/fvm-solidity/src/',
'@safe/=lib/safe-smart-account/contracts/',
]

[lint]
Expand Down
1 change: 0 additions & 1 deletion lib/safe-smart-account
Submodule safe-smart-account deleted from 77901a
12 changes: 3 additions & 9 deletions src/StreamWeightActor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {FVMRewards} from "./lib/FVMRewards.sol";
import {PendingOp, Share, WeightRecord, WeightRecordUpdate} from "./lib/FVMRewardTypes.sol";
import {OwnersLibrary} from "./lib/Owners.sol";
import {UnanimousGovernance} from "./lib/UnanimousGovernance.sol";
import {IsASafe} from "./lib/IsASafe.sol";

uint64 constant SERVICE_ID = 2;

Expand All @@ -20,21 +19,17 @@ int256 constant STEP = 5e16; // 5%
/// @dev Writes require unanimous owner approval, except `cancelPending`/`cancelPendingWeight`
/// (any single owner, immediate) and `quarterlyGateCheck` (fully permissionless).
contract StreamWeightActor is UnanimousGovernance {
using IsASafe for address;
using OwnersLibrary for address;

IServiceRewardsActor immutable SRA;
Epoch immutable QUARTER;
Epoch immutable HOLD;

/// @notice Deploys the actor with its two initial owners, bound to a Service Rewards Actor.
/// @param owner1 First owner; must be a Safe.
/// @param owner2 Second owner; must be a Safe.
/// @param owner1 First owner.
/// @param owner2 Second owner.
/// @param sra Service Rewards Actor supplying QUARTER/HOLD and gating `quarterlyGateCheck`.
constructor(address owner1, address owner2, IServiceRewardsActor sra) {
owner1.isProbablyASafe();
owner2.isProbablyASafe();

Comment on lines -35 to -37

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we go with this approach, I still want to verify that the owners are contracts. like address.code.length > 0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable. Maybe if we land there I could update #32 instead of this one, and put in address.code.length > 0 in addition to or even instead of the multisig owner count calls.

Just because all the check plumbing is still there.

owner1.addOwner();
owner2.addOwner();

Expand Down Expand Up @@ -118,9 +113,8 @@ contract StreamWeightActor is UnanimousGovernance {

/// @notice Replaces one of the two owners.
/// @param prevOwner Owner being removed.
/// @param newOwner Owner being added; must be a Safe.
/// @param newOwner Owner being added.
function replaceOwner(address prevOwner, address newOwner) external unanimousNoHold(keccak256(msg.data)) {
newOwner.isProbablyASafe();
prevOwner.removeOwner();
newOwner.addOwner();
}
Expand Down
18 changes: 0 additions & 18 deletions src/lib/IsASafe.sol

This file was deleted.

20 changes: 3 additions & 17 deletions test/StreamWeightActor.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
pragma solidity ^0.8.36;

import {SafeProxy} from "@safe/proxies/SafeProxy.sol";

import {USR_FORBIDDEN, USR_ILLEGAL_ARGUMENT, USR_NOT_FOUND} from "fvm-solidity/FVMErrors.sol";

import {MockRewardTest} from "./mocks/MockRewardTest.sol";
Expand All @@ -27,8 +25,8 @@ contract StreamWeightActorTest is MockRewardTest {

function setUp() public override {
super.setUp();
owner1 = _makeSafeOwner("owner1");
owner2 = _makeSafeOwner("owner2");
owner1 = makeAddr("owner1");
owner2 = makeAddr("owner2");

address sra = makeAddr("sra");
vm.mockCall(
Expand All @@ -40,18 +38,6 @@ contract StreamWeightActorTest is MockRewardTest {
rewardActor().mockSwa(address(actor));
}

function _makeSafeOwner(string memory label) internal returns (address proxyAddr) {
address masterCopy = makeAddr(string.concat(label, "-mastercopy"));
vm.etch(masterCopy, new bytes(8001));

SafeProxy real = new SafeProxy(masterCopy);
bytes memory code = address(real).code;

proxyAddr = makeAddr(label);
vm.etch(proxyAddr, code);
vm.store(proxyAddr, bytes32(0), bytes32(uint256(uint160(masterCopy))));
}

// -------------------------------------------------------------------------
// Helpers
// -------------------------------------------------------------------------
Expand Down Expand Up @@ -285,7 +271,7 @@ contract StreamWeightActorTest is MockRewardTest {
// -------------------------------------------------------------------------

function test_ReplaceOwner_Success_SwapsApprovalRights() public {
address newOwner = _makeSafeOwner("newOwner");
address newOwner = makeAddr("newOwner");

vm.prank(owner1);
actor.replaceOwner(owner2, newOwner);
Expand Down