-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
345 additions
and
59 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 |
---|---|---|
|
@@ -22,29 +22,36 @@ jobs: | |
- name: Run tests | ||
run: forge test | ||
|
||
# coverage_report: | ||
# name: Generate coverage report | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
|
||
# - name: Install Foundry | ||
# uses: onbjerg/foundry-toolchain@v1 | ||
# with: | ||
# version: nightly | ||
|
||
# - name: Install submodules | ||
# run: | | ||
# git config --global url."https://github.com/".insteadOf "[email protected]:" | ||
# git submodule update --init --recursive | ||
# - name: Generate coverage report | ||
# run: | | ||
# forge coverage --report lcov | ||
# - name: Report code coverage | ||
# uses: zgosalvez/github-actions-report-lcov@v1 | ||
# with: | ||
# coverage-files: lcov.info | ||
# minimum-coverage: 95 | ||
# artifact-name: code-coverage-report | ||
# github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# working-directory: ./ | ||
coverage_report: | ||
name: Generate coverage report | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Foundry | ||
uses: onbjerg/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Install submodules | ||
run: | | ||
git config --global url."https://github.com/".insteadOf "[email protected]:" | ||
git submodule update --init --recursive | ||
- name: Generate coverage report | ||
run: | | ||
forge coverage --report lcov | ||
- name: Install lcov | ||
run: sudo apt-get install lcov | ||
|
||
- name: Remove Tests from coverage | ||
run: lcov --remove ./lcov.info -o ./lcov.info.pruned 'tests/*' | ||
|
||
- name: Report code coverage | ||
uses: zgosalvez/github-actions-report-lcov@v1 | ||
with: | ||
coverage-files: lcov.info.pruned | ||
minimum-coverage: 90 | ||
artifact-name: code-coverage-report | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
working-directory: ./ |
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 |
---|---|---|
|
@@ -28,29 +28,36 @@ jobs: | |
env: | ||
FOUNDRY_PROFILE: production | ||
|
||
# coverage_report: | ||
# name: Generate coverage report | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
|
||
# - name: Install Foundry | ||
# uses: onbjerg/foundry-toolchain@v1 | ||
# with: | ||
# version: nightly | ||
|
||
# - name: Install submodules | ||
# run: | | ||
# git config --global url."https://github.com/".insteadOf "[email protected]:" | ||
# git submodule update --init --recursive | ||
# - name: Generate coverage report | ||
# run: | | ||
# forge coverage --report lcov | ||
# - name: Report code coverage | ||
# uses: zgosalvez/github-actions-report-lcov@v1 | ||
# with: | ||
# coverage-files: lcov.info | ||
# minimum-coverage: 95 | ||
# artifact-name: code-coverage-report | ||
# github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# working-directory: ./ | ||
coverage_report: | ||
name: Generate coverage report | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install Foundry | ||
uses: onbjerg/foundry-toolchain@v1 | ||
with: | ||
version: nightly | ||
|
||
- name: Install submodules | ||
run: | | ||
git config --global url."https://github.com/".insteadOf "[email protected]:" | ||
git submodule update --init --recursive | ||
- name: Generate coverage report | ||
run: | | ||
forge coverage --report lcov | ||
- name: Install lcov | ||
run: sudo apt-get install lcov | ||
|
||
- name: Remove Tests from coverage | ||
run: lcov --remove ./lcov.info -o ./lcov.info.pruned 'tests/*' | ||
|
||
- name: Report code coverage | ||
uses: zgosalvez/github-actions-report-lcov@v1 | ||
with: | ||
coverage-files: lcov.info.pruned | ||
minimum-coverage: 90 | ||
artifact-name: code-coverage-report | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
working-directory: ./ |
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 |
---|---|---|
@@ -1,9 +1,74 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.18; | ||
|
||
import { ERC20 } from "../modules/erc20/contracts/ERC20.sol"; | ||
import { ERC20Proxied } from "../modules/erc20/contracts/ERC20Proxied.sol"; | ||
import { NonTransparentProxied } from "../modules/ntp/contracts/NonTransparentProxied.sol"; | ||
|
||
import { IMapleToken } from "./interfaces/IMapleToken.sol"; | ||
import { IGlobalsLike } from "./interfaces/Interfaces.sol"; | ||
import { IMapleToken, IERC20 } from "./interfaces/IMapleToken.sol"; | ||
|
||
abstract contract MapleToken is IMapleToken, ERC20, NonTransparentProxied { } | ||
contract MapleToken is IMapleToken, ERC20Proxied, NonTransparentProxied { | ||
|
||
bytes32 internal constant GLOBALS_SLOT = bytes32(uint256(keccak256("eip1967.proxy.globals")) - 1); | ||
|
||
mapping(address => bool) public isBurner; | ||
mapping(address => bool) public isMinter; | ||
|
||
modifier onlyGovernor { | ||
require(msg.sender == IGlobalsLike(globals()).governor(), "MT:NOT_GOVERNOR"); | ||
_; | ||
} | ||
|
||
/**************************************************************************************************************************************/ | ||
/*** External Functions ***/ | ||
/**************************************************************************************************************************************/ | ||
|
||
// Note: technically, a module can be removed with this function, but that's alright, since it's more restrictive than removeModule() | ||
function addModule(address module, bool burner, bool minter) external onlyGovernor { | ||
require(burner || minter, "MT:AM:INVALID_MODULE"); | ||
// TODO: add scheduling | ||
|
||
isBurner[module] = burner; | ||
isMinter[module] = minter; | ||
} | ||
|
||
function removeModule(address module) external onlyGovernor { | ||
delete isBurner[module]; | ||
delete isMinter[module]; | ||
} | ||
|
||
function burn(address from_, uint256 amount_) external { | ||
require(isBurner[msg.sender], "MT:B:NOT_BURNER"); | ||
_burn(from_, amount_); | ||
} | ||
|
||
function mint(address to_, uint256 amount_) external { | ||
require(isMinter[msg.sender], "MT:M:NOT_MINTER"); | ||
_mint(to_, amount_); | ||
} | ||
|
||
/**************************************************************************************************************************************/ | ||
/*** Pure Functions ***/ | ||
/**************************************************************************************************************************************/ | ||
|
||
function decimals() public pure override(ERC20Proxied, IERC20) returns (uint8 decimals_) { | ||
decimals_ = 18; | ||
} | ||
|
||
function name() public pure override(ERC20Proxied, IERC20) returns (string memory name_) { | ||
name_ = "MPL"; | ||
} | ||
|
||
function symbol() public pure override(ERC20Proxied, IERC20) returns (string memory symbol_) { | ||
symbol_ = "MPL"; | ||
} | ||
|
||
/**************************************************************************************************************************************/ | ||
/*** View Functions ***/ | ||
/**************************************************************************************************************************************/ | ||
|
||
function globals() public view override returns (address globals_) { | ||
globals_ = _getAddress(GLOBALS_SLOT); | ||
} | ||
|
||
} |
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,24 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.18; | ||
|
||
import { NonTransparentProxy } from "../modules/ntp/contracts/NonTransparentProxy.sol"; | ||
|
||
contract MapleTokenProxy is NonTransparentProxy { | ||
|
||
bytes32 internal constant GLOBALS_SLOT = bytes32(uint256(keccak256("eip1967.proxy.globals")) - 1); | ||
|
||
constructor(address admin_, address implementation_, address globals_) NonTransparentProxy(admin_, implementation_) { | ||
_setAddress(GLOBALS_SLOT, globals_); | ||
} | ||
|
||
/**************************************************************************************************************************************/ | ||
/*** Overridden Functions ***/ | ||
/**************************************************************************************************************************************/ | ||
|
||
function setImplementation(address newImplementation_) override external { | ||
// TODO: Check globals for scheduled call | ||
require(msg.sender == _admin(), "NTP:SI:NOT_ADMIN"); | ||
_setAddress(IMPLEMENTATION_SLOT, newImplementation_); | ||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,2 +1,10 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.18; | ||
|
||
interface IGlobalsLike { | ||
|
||
function governor() external view returns (address governor); | ||
|
||
function mapleTreasury() external view returns (address mapleTreasury); | ||
|
||
} |
Submodule erc20
updated
4 files
+171 −0 | contracts/ERC20Proxied.sol | |
+3 −5 | contracts/test/ERC20.t.sol | |
+1 −1 | contracts/test/mocks/MockERC20.sol | |
+4 −4 | foundry.toml |
Submodule ntp
updated
2 files
+1 −1 | contracts/NonTransparentProxied.sol | |
+4 −4 | contracts/NonTransparentProxy.sol |
Oops, something went wrong.