Skip to content

Commit

Permalink
chore: rename missed workspace namings
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielstoica committed Oct 31, 2024
1 parent e4e5560 commit 4dae3fc
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 76 deletions.
2 changes: 1 addition & 1 deletion src/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ library Errors {
//////////////////////////////////////////////////////////////////////////*/

/// @notice Thrown when `msg.sender` is not the {Space} contract owner
error CallerNotWorkspaceOwner();
error CallerNotSpaceOwner();

/// @notice Thrown when a native token (ETH) withdrawal fails
error NativeWithdrawFailed();
Expand Down
8 changes: 4 additions & 4 deletions src/modules/invoice-module/InvoiceModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ contract InvoiceModule is IInvoiceModule, StreamManager, ERC721 {
//////////////////////////////////////////////////////////////////////////*/

/// @dev Allow only calls from contracts implementing the {ISpace} interface
modifier onlyWorkspace() {
modifier onlySpace() {
// Checks: the sender is a valid non-zero code size contract
if (msg.sender.code.length == 0) {
revert Errors.WorkspaceZeroCodeSize();
revert Errors.SpaceZeroCodeSize();
}

// Checks: the sender implements the ERC-165 interface required by {ISpace}
bytes4 interfaceId = type(ISpace).interfaceId;
if (!ISpace(msg.sender).supportsInterface(interfaceId)) revert Errors.WorkspaceUnsupportedInterface();
if (!ISpace(msg.sender).supportsInterface(interfaceId)) revert Errors.SpaceUnsupportedInterface();
_;
}

Expand All @@ -86,7 +86,7 @@ contract InvoiceModule is IInvoiceModule, StreamManager, ERC721 {
//////////////////////////////////////////////////////////////////////////*/

/// @inheritdoc IInvoiceModule
function createInvoice(Types.Invoice calldata invoice) external onlyWorkspace returns (uint256 invoiceId) {
function createInvoice(Types.Invoice calldata invoice) external onlySpace returns (uint256 invoiceId) {
// Checks: the amount is non-zero
if (invoice.payment.amount == 0) {
revert Errors.ZeroPaymentAmount();
Expand Down
4 changes: 2 additions & 2 deletions src/modules/invoice-module/libraries/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ library Errors {
//////////////////////////////////////////////////////////////////////////*/

/// @notice Thrown when the caller is an invalid zero code contract or EOA
error WorkspaceZeroCodeSize();
error SpaceZeroCodeSize();

/// @notice Thrown when the caller is a contract that does not implement the {ISpace} interface
error WorkspaceUnsupportedInterface();
error SpaceUnsupportedInterface();

/// @notice Thrown when the end time of an invoice is in the past
error EndTimeInThePast();
Expand Down
14 changes: 7 additions & 7 deletions test/Base.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Events } from "./utils/Events.sol";
import { Users } from "./utils/Types.sol";
import { Test } from "forge-std/Test.sol";
import { MockERC20NoReturn } from "./mocks/MockERC20NoReturn.sol";
import { MockNonCompliantWorkspace } from "./mocks/MockNonCompliantWorkspace.sol";
import { MockNonCompliantSpace } from "./mocks/MockNonCompliantSpace.sol";
import { MockModule } from "./mocks/MockModule.sol";
import { MockBadReceiver } from "./mocks/MockBadReceiver.sol";
import { Space } from "./../src/Space.sol";
Expand Down Expand Up @@ -34,7 +34,7 @@ abstract contract Base_Test is Test, Events {
ModuleKeeper internal moduleKeeper;
MockERC20NoReturn internal usdt;
MockModule internal mockModule;
MockNonCompliantWorkspace internal mockNonCompliantWorkspace;
MockNonCompliantSpace internal mockNonCompliantSpace;
MockBadReceiver internal mockBadReceiver;
MockERC721Collection internal mockERC721;
MockERC1155Collection internal mockERC1155;
Expand Down Expand Up @@ -65,7 +65,7 @@ abstract contract Base_Test is Test, Events {
containerImplementation = address(new Space(entrypoint, address(stationRegistry)));

mockModule = new MockModule();
mockNonCompliantWorkspace = new MockNonCompliantWorkspace({ _owner: users.admin });
mockNonCompliantSpace = new MockNonCompliantSpace({ _owner: users.admin });
mockBadReceiver = new MockBadReceiver();
mockERC721 = new MockERC721Collection("MockERC721Collection", "MC");
mockERC1155 = new MockERC1155Collection("https://nft.com/0x1.json");
Expand All @@ -79,7 +79,7 @@ abstract contract Base_Test is Test, Events {
vm.label({ account: address(moduleKeeper), newLabel: "ModuleKeeper" });
vm.label({ account: address(usdt), newLabel: "USDT" });
vm.label({ account: address(mockModule), newLabel: "MockModule" });
vm.label({ account: address(mockNonCompliantWorkspace), newLabel: "MockNonCompliantWorkspace" });
vm.label({ account: address(mockNonCompliantSpace), newLabel: "MockNonCompliantSpace" });
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -107,11 +107,11 @@ abstract contract Base_Test is Test, Events {
}

/// @dev Deploys a new {MockBadSpace} smart account based on the provided `owner`, `moduleKeeper` and `initialModules` input params
function deployBadWorkspace(
function deployBadSpace(
address _owner,
uint256 _spaceId,
address[] memory _initialModules
) internal returns (MockBadSpace _badWorkspace) {
) internal returns (MockBadSpace _badSpace) {
vm.startPrank({ msgSender: users.admin });
for (uint256 i; i < _initialModules.length; ++i) {
allowlistModule(_initialModules[i]);
Expand All @@ -122,7 +122,7 @@ abstract contract Base_Test is Test, Events {
computeCreateAccountCalldata({ deployer: _owner, stationId: _spaceId, initialModules: _initialModules });

vm.prank({ msgSender: _owner });
_badWorkspace = MockBadSpace(payable(stationRegistry.createAccount({ _admin: _owner, _data: data })));
_badSpace = MockBadSpace(payable(stationRegistry.createAccount({ _admin: _owner, _data: data })));
vm.stopPrank();
}

Expand Down
6 changes: 3 additions & 3 deletions test/integration/Integration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ abstract contract Integration_Test is Base_Test {
SablierV2LockupLinear internal sablierV2LockupLinear;
SablierV2LockupTranched internal sablierV2LockupTranched;
MockStreamManager internal mockStreamManager;
MockBadSpace internal badWorkspace;
MockBadSpace internal badSpace;

/*//////////////////////////////////////////////////////////////////////////
SET-UP FUNCTION
Expand All @@ -41,7 +41,7 @@ abstract contract Integration_Test is Base_Test {
space = deploySpace({ _owner: users.eve, _spaceId: 0, _initialModules: modules });

// Deploy a "bad" {Space} with the `mockBadReceiver` as the owner
badWorkspace = deployBadWorkspace({ _owner: address(mockBadReceiver), _spaceId: 0, _initialModules: modules });
badSpace = deployBadSpace({ _owner: address(mockBadReceiver), _spaceId: 0, _initialModules: modules });

// Deploy the mock {StreamManager}
mockStreamManager = new MockStreamManager(sablierV2LockupLinear, sablierV2LockupTranched, users.admin);
Expand All @@ -51,7 +51,7 @@ abstract contract Integration_Test is Base_Test {
vm.label({ account: address(sablierV2LockupLinear), newLabel: "SablierV2LockupLinear" });
vm.label({ account: address(sablierV2LockupTranched), newLabel: "SablierV2LockupTranched" });
vm.label({ account: address(space), newLabel: "Eve's Space" });
vm.label({ account: address(badWorkspace), newLabel: "Bad receiver's Space" });
vm.label({ account: address(badSpace), newLabel: "Bad receiver's Space" });
}

/*//////////////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
// Make Bob the caller in this test suite which is an EOA
vm.startPrank({ msgSender: users.bob });

// Expect the call to revert with the {WorkspaceZeroCodeSize} error
vm.expectRevert(Errors.WorkspaceZeroCodeSize.selector);
// Expect the call to revert with the {SpaceZeroCodeSize} error
vm.expectRevert(Errors.SpaceZeroCodeSize.selector);

// Create an one-off transfer invoice
invoice = createInvoiceWithOneOffTransfer({ asset: address(usdt) });
Expand All @@ -27,7 +27,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
invoiceModule.createInvoice(invoice);
}

function test_RevertWhen_NonCompliantWorkspace() external whenCallerContract {
function test_RevertWhen_NonCompliantSpace() external whenCallerContract {
// Make Eve the caller in this test suite as she's the owner of the {Space} contract
vm.startPrank({ msgSender: users.eve });

Expand All @@ -39,14 +39,14 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
"createInvoice((uint8,uint40,uint40,(uint8,uint8,uint40,address,uint128,uint256)))", invoice
);

// Expect the call to revert with the {WorkspaceUnsupportedInterface} error
vm.expectRevert(Errors.WorkspaceUnsupportedInterface.selector);
// Expect the call to revert with the {SpaceUnsupportedInterface} error
vm.expectRevert(Errors.SpaceUnsupportedInterface.selector);

// Run the test
mockNonCompliantWorkspace.execute({ module: address(invoiceModule), value: 0, data: data });
mockNonCompliantSpace.execute({ module: address(invoiceModule), value: 0, data: data });
}

function test_RevertWhen_ZeroPaymentAmount() external whenCallerContract whenCompliantWorkspace {
function test_RevertWhen_ZeroPaymentAmount() external whenCallerContract whenCompliantSpace {
// Make Eve the caller in this test suite as she's the owner of the {Space} contract
vm.startPrank({ msgSender: users.eve });

Expand All @@ -71,7 +71,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_RevertWhen_StartTimeGreaterThanEndTime()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
{
// Make Eve the caller in this test suite as she's the owner of the {Space} contract
Expand Down Expand Up @@ -99,7 +99,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_RevertWhen_EndTimeInThePast()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
{
Expand Down Expand Up @@ -132,7 +132,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_CreateInvoice_PaymentMethodOneOffTransfer()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down Expand Up @@ -187,7 +187,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_RevertWhen_PaymentMethodRecurringTransfer_PaymentIntervalTooShortForSelectedRecurrence()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down Expand Up @@ -218,7 +218,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_CreateInvoice_RecurringTransfer()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down Expand Up @@ -273,7 +273,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_RevertWhen_PaymentMethodTranchedStream_RecurrenceSetToOneOff()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down Expand Up @@ -303,7 +303,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_RevertWhen_PaymentMethodTranchedStream_PaymentIntervalTooShortForSelectedRecurrence()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down Expand Up @@ -334,7 +334,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_RevertWhen_PaymentMethodTranchedStream_PaymentAssetNativeToken()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down Expand Up @@ -366,7 +366,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_CreateInvoice_Tranched()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down Expand Up @@ -421,7 +421,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_RevertWhen_PaymentMethodLinearStream_PaymentAssetNativeToken()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down Expand Up @@ -451,7 +451,7 @@ contract CreateInvoice_Integration_Concret_Test is CreateInvoice_Integration_Sha
function test_CreateInvoice_LinearStream()
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
createInvoice.t.sol
├── when the caller IS NOT a contract
│ └── it should revert with the {WorkspaceZeroCodeSize} error
│ └── it should revert with the {SpaceZeroCodeSize} error
└── when the caller IS a contract
├── when the caller contract DOES NOT implement the ERC-165 {ISpace} interface
│ └── it should revert with the {WorkspaceUnsupportedInterface} error
│ └── it should revert with the {SpaceUnsupportedInterface} error
└── when the caller contract DOES implement the ERC-165 {ISpace} interface
├── when the payment amount IS zero
│ └── it should revert with the {ZeroPaymentAmount} error
Expand Down
2 changes: 1 addition & 1 deletion test/integration/fuzz/createInvoice.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract CreateInvoice_Integration_Fuzz_Test is CreateInvoice_Integration_Shared
)
external
whenCallerContract
whenCompliantWorkspace
whenCompliantSpace
whenNonZeroPaymentAmount
whenStartTimeLowerThanEndTime
whenEndTimeInTheFuture
Expand Down
4 changes: 2 additions & 2 deletions test/integration/shared/createInvoice.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ abstract contract CreateInvoice_Integration_Shared_Test is Integration_Test {
_;
}

modifier whenCompliantWorkspace() {
modifier whenCompliantSpace() {
_;
}

Expand Down Expand Up @@ -189,7 +189,7 @@ abstract contract CreateInvoice_Integration_Shared_Test is Integration_Test {
if (user == users.eve) {
Space(space).execute({ module: address(invoiceModule), value: 0, data: data });
} else {
MockBadSpace(badWorkspace).execute({ module: address(invoiceModule), value: 0, data: data });
MockBadSpace(badSpace).execute({ module: address(invoiceModule), value: 0, data: data });
}

// Stop the active prank
Expand Down
8 changes: 4 additions & 4 deletions test/mocks/MockModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ contract MockModule {
event ModuleItemCreated(uint256 indexed id);

/// @dev Allow only calls from contracts implementing the {ISpace} interface
modifier onlyWorkspace() {
modifier onlySpace() {
// Checks: the sender is a valid non-zero code size contract
if (msg.sender.code.length == 0) {
revert Errors.WorkspaceZeroCodeSize();
revert Errors.SpaceZeroCodeSize();
}

// Checks: the sender implements the ERC-165 interface required by {ISpace}
bytes4 interfaceId = type(ISpace).interfaceId;
if (!IERC165(msg.sender).supportsInterface(interfaceId)) revert Errors.WorkspaceUnsupportedInterface();
if (!IERC165(msg.sender).supportsInterface(interfaceId)) revert Errors.SpaceUnsupportedInterface();
_;
}

function createModuleItem() external onlyWorkspace returns (uint256 id) {
function createModuleItem() external onlySpace returns (uint256 id) {
// Get the next module item ID
id = _nextItemIf;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ pragma solidity ^0.8.26;
import { ExcessivelySafeCall } from "@nomad-xyz/excessively-safe-call/src/ExcessivelySafeCall.sol";
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/// @title Space
/// @notice A mock non-compliant space contract that do not support the {ISpace} interface
contract MockNonCompliantWorkspace is IERC165 {
/// @title MockNonCompliantSpace
/// @notice A mock non-compliant {Space} contract that do not support the {ISpace} interface
contract MockNonCompliantSpace is IERC165 {
using ExcessivelySafeCall for address;

address public owner;
Expand Down
4 changes: 2 additions & 2 deletions test/unit/concrete/space/withdraw-erc20/withdrawERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ contract WithdrawERC20_Unit_Concrete_Test is Space_Unit_Concrete_Test {
space.withdrawERC20({ asset: IERC20(address(usdt)), amount: 10e6 });

// Assert the USDT balance of the {Space} contract
uint256 actualBalanceOfWorkspace = usdt.balanceOf(address(space));
assertEq(actualBalanceOfWorkspace, 90e6);
uint256 actualBalanceOfSpace = usdt.balanceOf(address(space));
assertEq(actualBalanceOfSpace, 90e6);

// Assert the USDT balance of Eve
uint256 actualBalanceOfEve = usdt.balanceOf(users.eve);
Expand Down
Loading

0 comments on commit 4dae3fc

Please sign in to comment.