Skip to content
Merged
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: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/openzeppelin/openzeppelin-contracts
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# <TITLE>
# Spark ALM Controller

<!-- ![Foundry CI](https://github.com/{org}/{repo}/actions/workflows/ci.yml/badge.svg)
![Foundry CI](https://github.com/marsfoundation/spark-alm-controller/actions/workflows/ci.yml/badge.svg)
[![Foundry][foundry-badge]][foundry]
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://github.com/{org}/{repo}/blob/master/LICENSE) -->
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://github.com/marsfoundation/spark-alm-controller/blob/master/LICENSE)

[foundry]: https://getfoundry.sh/
[foundry-badge]: https://img.shields.io/badge/Built%20with-Foundry-FFDB1C.svg

Description of project goes here.
Smart contracts to perform onchain actions on behalf of the ALM Planner.

## Usage

Expand All @@ -22,4 +22,4 @@ forge test
```

***
*The IP in this repository was assigned to Mars SPC Limited in respect of the MarsOne SP*
*The IP in this repository was assigned to Mars SPC Limited in respect of the MarsOne SP*
5 changes: 5 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ libs = ["lib"]
solc_version = '0.8.20'
optimizer = true
optimizer_runs = 200
remappings = [
"openzeppelin-contracts=lib/openzeppelin-contracts",
"upgradeable-proxy=lib/upgradeable-proxy/src",
"forge-std=lib/forge-std/src",
]

[fuzz]
runs = 1000
Expand Down
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at dbb610
12 changes: 0 additions & 12 deletions script/Counter.s.sol

This file was deleted.

14 changes: 0 additions & 14 deletions src/Counter.sol

This file was deleted.

39 changes: 39 additions & 0 deletions src/L1Controller.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;

import { AccessControl } from "openzeppelin-contracts/contracts/access/AccessControl.sol";

contract L1Controller is AccessControl {

bytes32 public constant FREEZER = keccak256("FREEZER");
bytes32 public constant RELAYER = keccak256("RELAYER");

bool public active;

/**********************************************************************************************/
/*** Initialization ***/
/**********************************************************************************************/

constructor() {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}

/**********************************************************************************************/
/*** Freezer Functions ***/
/**********************************************************************************************/

function setActive(bool active_) external onlyRole(FREEZER) {
active = active_;
}

/**********************************************************************************************/
/*** Relayer Functions ***/
/**********************************************************************************************/

// TODO: Placeholder for relayer functions
function doAction() external onlyRole(RELAYER) {
// Do something
}

}

32 changes: 32 additions & 0 deletions test/ACL.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;

import "./UnitTestBase.t.sol";

contract L1ControllerACLTests is UnitTestBase {

function test_setActive() public {
vm.expectRevert(abi.encodeWithSignature(
"AccessControlUnauthorizedAccount(address,bytes32)",
address(this),
FREEZER
));
l1Controller.setActive(true);

vm.prank(freezer);
l1Controller.setActive(true);
}

function test_doAction() public {
vm.expectRevert(abi.encodeWithSignature(
"AccessControlUnauthorizedAccount(address,bytes32)",
address(this),
RELAYER
));
l1Controller.doAction();

vm.prank(relayer);
l1Controller.doAction();
}

}
25 changes: 0 additions & 25 deletions test/Counter.t.sol

This file was deleted.

41 changes: 41 additions & 0 deletions test/UnitTestBase.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.13;

import "forge-std/Test.sol";

import { L1Controller } from "src/L1Controller.sol";

contract RolesMock {

function canCall(bytes32, address, address, bytes4) external pure returns (bool) {
return true;
}

}

contract UnitTestBase is Test {

address admin = makeAddr("admin");
address freezer = makeAddr("freezer");
address relayer = makeAddr("relayer");

bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

bytes32 public constant FREEZER = keccak256("FREEZER");
bytes32 public constant RELAYER = keccak256("RELAYER");

L1Controller l1Controller;

address conduit;
address vault;

function setUp() public virtual {
l1Controller = new L1Controller();

l1Controller.grantRole(DEFAULT_ADMIN_ROLE, admin);

l1Controller.grantRole(FREEZER, freezer);
l1Controller.grantRole(RELAYER, relayer);
}

}