Skip to content

Commit

Permalink
Merge pull request #14 from chimera-defi/ci
Browse files Browse the repository at this point in the history
chore(ci): cleanup build and run process + add CI
  • Loading branch information
chimera-defi authored May 30, 2024
2 parents ae40f84 + 6d08708 commit 5138d9f
Show file tree
Hide file tree
Showing 44 changed files with 2,794 additions and 2,602 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [20.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install -g yarn
- run: yarn install
- run: yarn sol
- run: yarn test
6 changes: 3 additions & 3 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ printWidth: 120
singleQuote: false
tabWidth: 2
trailingComma: all

plugins: ["prettier-plugin-solidity"]
overrides:
- files: "contracts/*.sol"
- files: "contracts/**/*.sol"
options:
tabWidth: 4
explicitTypes: 'always'
parser: "solidity-parse"
4 changes: 2 additions & 2 deletions .solhint.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"constructor-syntax": "error",
"func-visibility": ["error", {"ignoreConstructors": true}],
"max-line-length": ["error", 200],
"not-rely-on-time": "off",
"not-rely-on-time": "warn",
"avoid-suicide": "error",
"avoid-sha3": "warn",
"prettier/prettier": [
"error",
"warm",
{
"endOfLine": "auto"
}
Expand Down
5 changes: 5 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ deploy_log.json

contracts/governance/SimpleVesting.sol
contracts/util/SingleTokenVestingNonRevocable.sol
contracts/v2/periphery/*.sol
./**/*.js
test/**/*
./**/*.md
./**/*.json
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ See deploy_log.md for new deployed contract addresses
```
yarn install
yarn sol
yarn test
```

- Deployments and hardhat
Run anvil for local host deploy

```
anvil --fork-url https://mainnet.sharedtools.org/apecoinrpc
anvil --fork-url https://rpc.sharedtools.org/rpc
npx hardhat run --network ...
```

Expand Down
6 changes: 1 addition & 5 deletions arguments.js
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
module.exports = [
1000000,
32,
true
]
module.exports = [1000000, 32, true];
72 changes: 36 additions & 36 deletions contracts/governance/FundDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,53 @@ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract FundDistributor is Ownable, Initializable {
using SafeMath for uint256;
using SafeERC20 for IERC20;
using SafeMath for uint256;
using SafeERC20 for IERC20;

IERC20 public reward;
uint256 public missingDecimals;
IERC20 public reward;
uint256 public missingDecimals;

// CONTRACTS
mapping(address => bool) public requesters;
// CONTRACTS
mapping(address => bool) public requesters;

/* ========== EVENTS ========================= */
/* ========== EVENTS ========================= */

event RequesterAdded(address indexed requester);
event RequesterRemoved(address indexed requester);
event FundRequested(uint256 indexed amount);
event RequesterAdded(address indexed requester);
event RequesterRemoved(address indexed requester);
event FundRequested(uint256 indexed amount);

/* ========== MODIFIER ========== */
/* ========== MODIFIER ========== */

modifier onlyRequester() {
require(requesters[_msgSender()], "FD:NA");
_;
}
modifier onlyRequester() {
require(requesters[_msgSender()], "FD:NA");
_;
}

function initialize(address _reward) external initializer {
reward = IERC20(_reward);
missingDecimals = 18 - ERC20(_reward).decimals();
}
function initialize(address _reward) external initializer {
reward = IERC20(_reward);
missingDecimals = 18 - ERC20(_reward).decimals();
}

/* ========== MUTATIVE ====================== */
/* ========== MUTATIVE ====================== */

function distributeTo(address _receiver, uint256 _amount) external onlyRequester {
require(_receiver != address(0), "FD:0AD");
if (_amount > 0) {
IERC20(reward).safeTransfer(_receiver, _amount.div(10 ** missingDecimals));
function distributeTo(address _receiver, uint256 _amount) external onlyRequester {
require(_receiver != address(0), "FD:0AD");
if (_amount > 0) {
IERC20(reward).safeTransfer(_receiver, _amount.div(10 ** missingDecimals));
}
}
}

/* ========== RESTRICTED FUNCTIONS ========== */
/* ========== RESTRICTED FUNCTIONS ========== */

function addRequester(address _requester) external onlyOwner {
require(!requesters[_requester], "FD:AE");
requesters[_requester] = true;
emit RequesterAdded(_requester);
}
function addRequester(address _requester) external onlyOwner {
require(!requesters[_requester], "FD:AE");
requesters[_requester] = true;
emit RequesterAdded(_requester);
}

function removeRequester(address _requester) external onlyOwner {
require(requesters[_requester], "FD:NA");
delete requesters[_requester];
emit RequesterRemoved(_requester);
}
function removeRequester(address _requester) external onlyOwner {
require(requesters[_requester], "FD:NA");
delete requesters[_requester];
emit RequesterRemoved(_requester);
}
}
Loading

0 comments on commit 5138d9f

Please sign in to comment.